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"
24 var totStopped = false;
28 var in_progress = false;
29 var langSelect = false;
30 var commentBusy = false;
33 $.ajaxSetup({cache: false});
35 msie = $.browser.msie ;
38 $("a,.tt").each(function(){
41 if (e.hasClass("tttop")) pos="top";
42 if (e.hasClass("ttbottom")) pos="bottom";
43 if (e.hasClass("ttleft")) pos="left";
44 if (e.hasClass("ttright")) pos="right";
45 e.tipTip({defaultPosition: pos, edgeOffset: 8});
50 /* setup onoff widgets */
51 $(".onoff input").each(function(){
53 id = $(this).attr("id");
54 $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
57 $(".onoff > a").click(function(event){
58 event.preventDefault();
59 var input = $(this).siblings("input");
60 var val = 1-input.val();
61 var id = input.attr("id");
62 $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
63 $("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
68 /* setup field_richtext */
72 $('a[rel^=#]').click(function(e){
73 menu = $( $(this).attr('rel') );
76 if (menu.attr('popup')=="false") return false;
77 $(this).parent().toggleClass("selected");
83 $("a.popupbox").fancybox({
84 'transitionIn' : 'elastic',
85 'transitionOut' : 'elastic'
89 /* notifications template */
90 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
91 var notifications_all = unescape($('<div>').append( $("#nav-notifications-see-all").clone() ).html()); //outerHtml hack
92 var notifications_empty = unescape($("#nav-notifications-menu").html());
94 /* nav update event */
95 $('nav').bind('nav-update', function(e,data){;
96 var net = $(data).find('net').text();
97 if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
98 $('#net-update').html(net);
100 var home = $(data).find('home').text();
101 if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
102 $('#home-update').html(home);
106 var intro = $(data).find('intro').text();
107 if(intro == 0) { intro = ''; $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
108 $('#intro-update').html(intro);
110 var mail = $(data).find('mail').text();
111 if(mail == 0) { mail = ''; $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
112 $('#mail-update').html(mail);
114 var eNotif = $(data).find('notif')
115 notif = eNotif.attr('count');
117 $("#nav-notifications-linkmenu").addClass("on");
118 nnm = $("#nav-notifications-menu");
120 nnm.html(notifications_all);
122 //nnm.attr('popup','true');
123 eNotif.children("note").each(function(){
125 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
126 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
131 $("#nav-notifications-linkmenu").removeClass("on");
132 $("#nav-notifications-menu").html(notifications_empty);
134 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
135 $('#notify-update').html(notif);
137 var eSysmsg = $(data).find('sysmsgs');
138 eSysmsg.children("notice").each(function(){
139 text = $(this).text();
140 $.jGrowl(text, { sticky: true, theme: 'notice' });
142 eSysmsg.children("info").each(function(){
143 text = $(this).text();
144 $.jGrowl(text, { sticky: false, theme: 'info', life: 10000 });
151 // Allow folks to stop the ajax page updates with the pause/break key
152 $(document).keydown(function(event) {
153 if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
154 event.preventDefault();
155 if(stopped == false) {
160 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
174 function NavUpdate() {
177 $.get("ping",function(data) {
178 $(data).find('result').each(function() {
179 // send nav-update event
180 $('nav').trigger('nav-update', this);
185 if($('#live-network').length) { src = 'network'; liveUpdate(); }
186 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
187 if($('#live-community').length) { src = 'community'; liveUpdate(); }
188 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
189 if($('#live-display').length) {
192 window.location.href=window.location.href
195 if($('#live-photos').length) {
198 window.location.href=window.location.href
208 timer = setTimeout(NavUpdate,updateInterval);
211 function liveUpdate() {
212 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
213 if(($('.comment-edit-text-full').length) || (in_progress)) {
215 clearTimeout(livetime);
217 livetime = setTimeout(liveUpdate, 10000);
223 prev = 'live-' + src;
226 var udargs = ((netargs.length) ? '/' + netargs : '');
227 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
229 $.get(update_url,function(data) {
231 // $('.collapsed-comments',data).each(function() {
232 // var ident = $(this).attr('id');
233 // var is_hidden = $('#' + ident).is(':hidden');
234 // if($('#' + ident).length) {
235 // $('#' + ident).replaceWith($(this));
237 // $('#' + ident).hide();
243 $('.tread-wrapper',data).each(function() {
244 var ident = $(this).attr('id');
246 if($('#' + ident).length == 0 && profile_page == 1) {
247 $('img',this).each(function() {
248 $(this).attr('src',$(this).attr('dst'));
250 $('#' + prev).after($(this));
253 $('img',this).each(function() {
254 $(this).attr('src',$(this).attr('dst'));
256 $('#' + ident).replaceWith($(this));
261 // reset vars for inserting individual items
263 /* prev = 'live-' + src;
265 $('.wall-item-outside-wrapper',data).each(function() {
266 var ident = $(this).attr('id');
268 if($('#' + ident).length == 0 && prev != 'live-' + src) {
269 $('img',this).each(function() {
270 $(this).attr('src',$(this).attr('dst'));
272 $('#' + prev).after($(this));
275 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
276 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
277 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
278 $('#' + ident + ' ' + '.hide-comments-total').replaceWith($(this).find('.hide-comments-total'));
279 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
280 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
281 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
282 $(this).attr('src',$(this).attr('dst'));
288 $('.like-rotator').hide();
291 $('body').css('cursor', 'auto');
293 /* autocomplete @nicknames */
294 $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
298 function imgbright(node) {
299 $(node).removeClass("drophide").addClass("drop");
302 function imgdull(node) {
303 $(node).removeClass("drop").addClass("drophide");
306 // Since our ajax calls are asynchronous, we will give a few
307 // seconds for the first ajax call (setting like/dislike), then
308 // run the updater to pick up any changes and display on the page.
309 // The updater will turn any rotators off when it's done.
310 // This function will have returned long before any of these
311 // events have completed and therefore there won't be any
312 // visible feedback that anything changed without all this
313 // trickery. This still could cause confusion if the "like" ajax call
314 // is delayed and NavUpdate runs before it completes.
316 function dolike(ident,verb) {
318 $('#like-rotator-' + ident.toString()).show();
319 $.get('like/' + ident.toString() + '?verb=' + verb );
320 if(timer) clearTimeout(timer);
321 timer = setTimeout(NavUpdate,3000);
325 function dostar(ident) {
326 ident = ident.toString();
327 $('#like-rotator-' + ident).show();
328 $.get('starred/' + ident, function(data) {
329 if(data.match(/1/)) {
330 $('#starred-' + ident).addClass('starred');
331 $('#starred-' + ident).removeClass('unstarred');
332 $('#star-' + ident).addClass('hidden');
333 $('#unstar-' + ident).removeClass('hidden');
336 $('#starred-' + ident).addClass('unstarred');
337 $('#starred-' + ident).removeClass('starred');
338 $('#star-' + ident).removeClass('hidden');
339 $('#unstar-' + ident).addClass('hidden');
341 $('#like-rotator-' + ident).hide();
345 function getPosition(e) {
346 var cursor = {x:0, y:0};
347 if ( e.pageX || e.pageY ) {
352 if( e.clientX || e.clientY ) {
353 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
354 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
366 var lockvisible = false;
368 function lockview(event,id) {
369 event = event || window.event;
370 cursor = getPosition(event);
376 $.get('lockview/' + id, function(data) {
377 $('#panel').html(data);
378 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
384 function lockviewhide() {
389 function post_comment(id) {
392 $('body').css('cursor', 'wait');
393 $("#comment-preview-inp-" + id).val("0");
396 $("#comment-edit-form-" + id).serialize(),
399 $("#comment-edit-wrapper-" + id).hide();
400 $("#comment-edit-text-" + id).val('');
401 var tarea = document.getElementById("comment-edit-text-" + id);
403 commentClose(tarea,id);
404 if(timer) clearTimeout(timer);
405 timer = setTimeout(NavUpdate,10);
408 window.location.href=data.reload;
417 function preview_comment(id) {
418 $("#comment-preview-inp-" + id).val("1");
419 $("#comment-edit-preview-" + id).show();
422 $("#comment-edit-form-" + id).serialize(),
426 $("#comment-edit-preview-" + id).html(data.preview);
427 $("#comment-edit-preview-" + id + " a").click(function() { return false; });
437 function preview_post() {
438 $("#jot-preview").val("1");
439 $("#jot-preview-content").show();
440 tinyMCE.triggerSave();
443 $("#profile-jot-form").serialize(),
446 $("#jot-preview-content").html(data.preview);
447 $("#jot-preview-content" + " a").click(function() { return false; });
452 $("#jot-preview").val("0");
458 // unpause auto reloads if they are currently stopped
461 $('#pause').html('');
466 // Converts the binary representation of data to hex
469 // discuss at: http://phpjs.org/functions/bin2hex
470 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
471 // + bugfixed by: Onno Marsman
472 // + bugfixed by: Linuxworld
473 // * example 1: bin2hex('Kev');
474 // * returns 1: '4b6576'
475 // * example 2: bin2hex(String.fromCharCode(0x00));
477 var v,i, f = 0, a = [];
481 for (i = 0; i<f; i++) {
482 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
488 function groupChangeMember(gid,cid) {
489 $('body .fakelink').css('cursor', 'wait');
490 $.get('group/' + gid + '/' + cid, function(data) {
491 $('#group-update-wrapper').html(data);
492 $('body .fakelink').css('cursor', 'auto');
496 function profChangeMember(gid,cid) {
497 $('body .fakelink').css('cursor', 'wait');
498 $.get('profperm/' + gid + '/' + cid, function(data) {
499 $('#prof-update-wrapper').html(data);
500 $('body .fakelink').css('cursor', 'auto');
504 function contactgroupChangeMember(gid,cid) {
505 $('body').css('cursor', 'wait');
506 $.get('contactgroup/' + gid + '/' + cid, function(data) {
507 $('body').css('cursor', 'auto');
512 function checkboxhighlight(box) {
513 if($(box).is(':checked')) {
514 $(box).addClass('checkeditem');
517 $(box).removeClass('checkeditem');
521 function setupFieldRichtext(){
524 mode : "specific_textareas",
525 editor_selector: "fieldRichtext",
526 plugins : "bbcode,paste",
527 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
528 theme_advanced_buttons2 : "",
529 theme_advanced_buttons3 : "",
530 theme_advanced_toolbar_location : "top",
531 theme_advanced_toolbar_align : "center",
532 theme_advanced_blockformats : "blockquote,code",
533 paste_text_sticky : true,
534 entity_encoding : "raw",
535 add_unload_trigger : false,
536 remove_linebreaks : false,
537 force_p_newlines : false,
538 force_br_newlines : true,
539 forced_root_block : '',
541 content_css: baseurl+"/view/custom_tinymce.css",
542 theme_advanced_path : false,
548 * sprintf in javascript
549 * "{0} and {1}".format('zero','uno');
551 String.prototype.format = function() {
552 var formatted = this;
553 for (var i = 0; i < arguments.length; i++) {
554 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
555 formatted = formatted.replace(regexp, arguments[i]);
560 Array.prototype.remove = function(item) {
561 to=undefined; from=this.indexOf(item);
562 var rest = this.slice((to || from) + 1 || this.length);
563 this.length = from < 0 ? this.length + from : from;
564 return this.push.apply(this, rest);