2 function openClose(theID) {
3 if(document.getElementById(theID).style.display == "block") {
4 document.getElementById(theID).style.display = "none"
7 document.getElementById(theID).style.display = "block"
11 function openMenu(theID) {
12 document.getElementById(theID).style.display = "block"
15 function closeMenu(theID) {
16 document.getElementById(theID).style.display = "none"
28 var in_progress = false;
29 var langSelect = false;
30 var commentBusy = false;
33 $.ajaxSetup({cache: false});
35 msie = $.browser.msie ;
38 /* setup onoff widgets */
39 $(".onoff input").each(function(){
41 id = $(this).attr("id");
42 $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
45 $(".onoff > a").click(function(event){
46 event.preventDefault();
47 var input = $(this).siblings("input");
48 var val = 1-input.val();
49 var id = input.attr("id");
50 $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
51 $("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
56 /* setup field_richtext */
59 /* load tinyMCE if needed and setup field_richtext */
60 /*if(typeof tinyMCE == "undefined") {
61 window.tinyMCEPreInit = {
63 base: baseurl+"/library/tinymce/jscripts/tiny_mce/",
66 $.getScript(baseurl +"/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js", setupFieldRichtext);
72 /* nav update event */
73 $('nav').bind('nav-update', function(e,data){;
74 var net = $(data).find('net').text();
75 if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
76 $('#net-update').html(net);
77 var home = $(data).find('home').text();
78 if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
79 $('#home-update').html(home);
80 var mail = $(data).find('mail').text();
81 if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
82 $('#mail-update').html(mail);
83 var intro = $(data).find('intro').text();
84 if(intro == 0) { intro = ''; $('#notify-update').hide() } else { $('#notify-update').show() }
85 $('#notify-update').html(intro);
90 // Allow folks to stop the ajax page updates with the pause/break key
91 $(document).keypress(function(event) {
92 if(event.keyCode == '19') {
93 event.preventDefault();
94 if(stopped == false) {
96 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
100 $('#pause').html('');
105 if(stopped == true) {
107 $('#pause').html('');
114 function NavUpdate() {
116 if($('#live-network').length) { src = 'network'; liveUpdate(); }
117 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
118 if($('#live-community').length) { src = 'community'; liveUpdate(); }
119 if($('#live-display').length) {
122 window.location.href=window.location.href
125 if($('#live-photos').length) {
128 window.location.href=window.location.href
133 $.get("ping",function(data) {
134 $(data).find('result').each(function() {
135 // send nav-update event
136 $('nav').trigger('nav-update', this);
140 timer = setTimeout(NavUpdate,30000);
143 function liveUpdate() {
144 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
145 if(($('.comment-edit-text-full').length) || (in_progress)) {
146 livetime = setTimeout(liveUpdate, 10000);
149 prev = 'live-' + src;
152 var udargs = ((netargs.length) ? '/' + netargs : '');
153 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
155 $.get(update_url,function(data) {
157 $('.ccollapse-wrapper',data).each(function() {
158 var ident = $(this).attr('id');
159 var is_hidden = $('#' + ident).is(':hidden');
160 if($('#' + ident).length) {
161 $('#' + ident).replaceWith($(this));
163 $('#' + ident).hide();
166 $('.wall-item-outside-wrapper',data).each(function() {
167 var ident = $(this).attr('id');
168 if($('#' + ident).length == 0) {
169 $('img',this).each(function() {
170 $(this).attr('src',$(this).attr('dst'));
172 $('#' + prev).after($(this));
176 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
177 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
178 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
179 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
180 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
181 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
182 $(this).attr('src',$(this).attr('dst'));
187 $('.like-rotator').hide();
190 $('body').css('cursor', 'auto');
195 function imgbright(node) {
196 $(node).removeClass("drophide").addClass("drop");
199 function imgdull(node) {
200 $(node).removeClass("drop").addClass("drophide");
203 // Since our ajax calls are asynchronous, we will give a few
204 // seconds for the first ajax call (setting like/dislike), then
205 // run the updater to pick up any changes and display on the page.
206 // The updater will turn any rotators off when it's done.
207 // This function will have returned long before any of these
208 // events have completed and therefore there won't be any
209 // visible feedback that anything changed without all this
210 // trickery. This still could cause confusion if the "like" ajax call
211 // is delayed and NavUpdate runs before it completes.
213 function dolike(ident,verb) {
214 $('#like-rotator-' + ident.toString()).show();
215 $.get('like/' + ident.toString() + '?verb=' + verb );
216 if(timer) clearTimeout(timer);
217 timer = setTimeout(NavUpdate,3000);
221 function dostar(ident) {
222 $('#like-rotator-' + ident.toString()).show();
223 $.get('starred/' + ident.toString(), function(data) {
224 if(data.match(/1/)) {
225 $('#starred-' + ident.toString()).addClass('starred');
226 $('#starred-' + ident.toString()).removeClass('unstarred');
229 $('#starred-' + ident.toString()).addClass('unstarred');
230 $('#starred-' + ident.toString()).removeClass('starred');
232 $('#like-rotator-' + ident.toString()).hide();
236 function getPosition(e) {
237 var cursor = {x:0, y:0};
238 if ( e.pageX || e.pageY ) {
243 if( e.clientX || e.clientY ) {
244 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
245 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
257 var lockvisible = false;
259 function lockview(event,id) {
260 event = event || window.event;
261 cursor = getPosition(event);
267 $.get('lockview/' + id, function(data) {
268 $('#panel').html(data);
269 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
275 function lockviewhide() {
280 function post_comment(id) {
282 $('body').css('cursor', 'wait');
285 $("#comment-edit-form-" + id).serialize(),
288 $("#comment-edit-wrapper-" + id).hide();
289 $("#comment-edit-text-" + id).val('');
290 var tarea = document.getElementById("comment-edit-text-" + id);
292 commentClose(tarea,id);
293 if(timer) clearTimeout(timer);
294 timer = setTimeout(NavUpdate,10);
297 window.location.href=data.reload;
307 // Converts the binary representation of data to hex
310 // discuss at: http://phpjs.org/functions/bin2hex
311 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
312 // + bugfixed by: Onno Marsman
313 // + bugfixed by: Linuxworld
314 // * example 1: bin2hex('Kev');
315 // * returns 1: '4b6576'
316 // * example 2: bin2hex(String.fromCharCode(0x00));
318 var v,i, f = 0, a = [];
322 for (i = 0; i<f; i++) {
323 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
329 function groupChangeMember(gid,cid) {
330 $('body .fakelink').css('cursor', 'wait');
331 $.get('group/' + gid + '/' + cid, function(data) {
332 $('#group-update-wrapper').html(data);
333 $('body .fakelink').css('cursor', 'auto');
337 function profChangeMember(gid,cid) {
338 $('body .fakelink').css('cursor', 'wait');
339 $.get('profperm/' + gid + '/' + cid, function(data) {
340 $('#prof-update-wrapper').html(data);
341 $('body .fakelink').css('cursor', 'auto');
345 function contactgroupChangeMember(gid,cid) {
346 $('body').css('cursor', 'wait');
347 $.get('contactgroup/' + gid + '/' + cid, function(data) {
348 $('body').css('cursor', 'auto');
353 function checkboxhighlight(box) {
354 if($(box).is(':checked')) {
355 $(box).addClass('checkeditem');
358 $(box).removeClass('checkeditem');
362 function setupFieldRichtext(){
365 mode : "specific_textareas",
366 editor_selector: "fieldRichtext",
367 plugins : "bbcode,paste",
368 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
369 theme_advanced_buttons2 : "",
370 theme_advanced_buttons3 : "",
371 theme_advanced_toolbar_location : "top",
372 theme_advanced_toolbar_align : "center",
373 theme_advanced_blockformats : "blockquote,code",
374 paste_text_sticky : true,
375 entity_encoding : "raw",
376 add_unload_trigger : false,
377 remove_linebreaks : false,
378 force_p_newlines : false,
379 force_br_newlines : true,
380 forced_root_block : '',
382 content_css: baseurl+"/view/custom_tinymce.css",
383 theme_advanced_path : false,
388 * sprintf in javascript
389 * "{0} and {1}".format('zero','uno');
391 String.prototype.format = function() {
392 var formatted = this;
393 for (var i = 0; i < arguments.length; i++) {
394 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
395 formatted = formatted.replace(regexp, arguments[i]);
400 Array.prototype.remove = function(item) {
401 to=undefined; from=this.indexOf(item);
402 var rest = this.slice((to || from) + 1 || this.length);
403 this.length = from < 0 ? this.length + from : from;
404 return this.push.apply(this, rest);