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 $("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});
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");
82 /* notifications template */
83 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
84 var notifications_empty = unescape($("#nav-notifications-menu").html());
86 /* nav update event */
87 $('nav').bind('nav-update', function(e,data){;
88 var net = $(data).find('net').text();
89 if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
90 $('#net-update').html(net);
92 var home = $(data).find('home').text();
93 if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
94 $('#home-update').html(home);
98 var intro = $(data).find('intro').text();
99 if(intro == 0) { intro = ''; $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
100 $('#intro-update').html(intro);
102 var mail = $(data).find('mail').text();
103 if(mail == 0) { mail = ''; $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
104 $('#mail-update').html(mail);
106 var eNotif = $(data).find('notif')
107 notif = eNotif.attr('count');
109 $("#nav-notifications-linkmenu").addClass("on");
110 nnm = $("#nav-notifications-menu");
112 nnm.html("<li><a href='"+baseurl+"/notifications/network'>Show All Notifications</a></li>");
114 //nnm.attr('popup','true');
115 eNotif.children("note").each(function(){
117 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
118 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
123 $("#nav-notifications-linkmenu").removeClass("on");
124 $("#nav-notifications-menu").html(notifications_empty);
126 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
127 $('#notify-update').html(notif);
129 var eSysmsg = $(data).find('sysmsgs');
130 eSysmsg.children("notice").each(function(){
131 text = $(this).text();
132 $.jGrowl(text, { sticky: true, theme: 'notice' });
134 eSysmsg.children("info").each(function(){
135 text = $(this).text();
136 $.jGrowl(text, { sticky: false, theme: 'info' });
143 // Allow folks to stop the ajax page updates with the pause/break key
144 $(document).keypress(function(event) {
145 if(event.keyCode == '19') {
146 event.preventDefault();
147 if(stopped == false) {
149 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
153 $('#pause').html('');
158 if(stopped == true) {
160 $('#pause').html('');
169 function NavUpdate() {
172 $.get("ping",function(data) {
173 $(data).find('result').each(function() {
174 // send nav-update event
175 $('nav').trigger('nav-update', this);
180 if($('#live-network').length) { src = 'network'; liveUpdate(); }
181 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
182 if($('#live-community').length) { src = 'community'; liveUpdate(); }
183 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
184 if($('#live-display').length) {
187 window.location.href=window.location.href
190 if($('#live-photos').length) {
193 window.location.href=window.location.href
203 timer = setTimeout(NavUpdate,30000);
206 function liveUpdate() {
207 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
208 if(($('.comment-edit-text-full').length) || (in_progress)) {
209 livetime = setTimeout(liveUpdate, 10000);
212 prev = 'live-' + src;
215 var udargs = ((netargs.length) ? '/' + netargs : '');
216 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
218 $.get(update_url,function(data) {
220 $('.ccollapse-wrapper',data).each(function() {
221 var ident = $(this).attr('id');
222 var is_hidden = $('#' + ident).is(':hidden');
223 if($('#' + ident).length) {
224 $('#' + ident).replaceWith($(this));
226 $('#' + ident).hide();
229 $('.wall-item-outside-wrapper',data).each(function() {
230 var ident = $(this).attr('id');
231 if($('#' + ident).length == 0) {
232 $('img',this).each(function() {
233 $(this).attr('src',$(this).attr('dst'));
235 $('#' + prev).after($(this));
239 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
240 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
241 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
242 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
243 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
244 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
245 $(this).attr('src',$(this).attr('dst'));
250 $('.like-rotator').hide();
253 $('body').css('cursor', 'auto');
255 /* autocomplete @nicknames */
256 $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
260 function imgbright(node) {
261 $(node).removeClass("drophide").addClass("drop");
264 function imgdull(node) {
265 $(node).removeClass("drop").addClass("drophide");
268 // Since our ajax calls are asynchronous, we will give a few
269 // seconds for the first ajax call (setting like/dislike), then
270 // run the updater to pick up any changes and display on the page.
271 // The updater will turn any rotators off when it's done.
272 // This function will have returned long before any of these
273 // events have completed and therefore there won't be any
274 // visible feedback that anything changed without all this
275 // trickery. This still could cause confusion if the "like" ajax call
276 // is delayed and NavUpdate runs before it completes.
278 function dolike(ident,verb) {
279 $('#like-rotator-' + ident.toString()).show();
280 $.get('like/' + ident.toString() + '?verb=' + verb );
281 if(timer) clearTimeout(timer);
282 timer = setTimeout(NavUpdate,3000);
286 function dostar(ident) {
287 ident = ident.toString();
288 $('#like-rotator-' + ident).show();
289 $.get('starred/' + ident, function(data) {
290 if(data.match(/1/)) {
291 $('#starred-' + ident).addClass('starred');
292 $('#starred-' + ident).removeClass('unstarred');
293 $('#star-' + ident).addClass('hidden');
294 $('#unstar-' + ident).removeClass('hidden');
297 $('#starred-' + ident).addClass('unstarred');
298 $('#starred-' + ident).removeClass('starred');
299 $('#star-' + ident).removeClass('hidden');
300 $('#unstar-' + ident).addClass('hidden');
302 $('#like-rotator-' + ident).hide();
306 function getPosition(e) {
307 var cursor = {x:0, y:0};
308 if ( e.pageX || e.pageY ) {
313 if( e.clientX || e.clientY ) {
314 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
315 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
327 var lockvisible = false;
329 function lockview(event,id) {
330 event = event || window.event;
331 cursor = getPosition(event);
337 $.get('lockview/' + id, function(data) {
338 $('#panel').html(data);
339 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
345 function lockviewhide() {
350 function post_comment(id) {
352 $('body').css('cursor', 'wait');
355 $("#comment-edit-form-" + id).serialize(),
358 $("#comment-edit-wrapper-" + id).hide();
359 $("#comment-edit-text-" + id).val('');
360 var tarea = document.getElementById("comment-edit-text-" + id);
362 commentClose(tarea,id);
363 if(timer) clearTimeout(timer);
364 timer = setTimeout(NavUpdate,10);
367 window.location.href=data.reload;
377 // Converts the binary representation of data to hex
380 // discuss at: http://phpjs.org/functions/bin2hex
381 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
382 // + bugfixed by: Onno Marsman
383 // + bugfixed by: Linuxworld
384 // * example 1: bin2hex('Kev');
385 // * returns 1: '4b6576'
386 // * example 2: bin2hex(String.fromCharCode(0x00));
388 var v,i, f = 0, a = [];
392 for (i = 0; i<f; i++) {
393 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
399 function groupChangeMember(gid,cid) {
400 $('body .fakelink').css('cursor', 'wait');
401 $.get('group/' + gid + '/' + cid, function(data) {
402 $('#group-update-wrapper').html(data);
403 $('body .fakelink').css('cursor', 'auto');
407 function profChangeMember(gid,cid) {
408 $('body .fakelink').css('cursor', 'wait');
409 $.get('profperm/' + gid + '/' + cid, function(data) {
410 $('#prof-update-wrapper').html(data);
411 $('body .fakelink').css('cursor', 'auto');
415 function contactgroupChangeMember(gid,cid) {
416 $('body').css('cursor', 'wait');
417 $.get('contactgroup/' + gid + '/' + cid, function(data) {
418 $('body').css('cursor', 'auto');
423 function checkboxhighlight(box) {
424 if($(box).is(':checked')) {
425 $(box).addClass('checkeditem');
428 $(box).removeClass('checkeditem');
432 function setupFieldRichtext(){
435 mode : "specific_textareas",
436 editor_selector: "fieldRichtext",
437 plugins : "bbcode,paste",
438 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
439 theme_advanced_buttons2 : "",
440 theme_advanced_buttons3 : "",
441 theme_advanced_toolbar_location : "top",
442 theme_advanced_toolbar_align : "center",
443 theme_advanced_blockformats : "blockquote,code",
444 paste_text_sticky : true,
445 entity_encoding : "raw",
446 add_unload_trigger : false,
447 remove_linebreaks : false,
448 force_p_newlines : false,
449 force_br_newlines : true,
450 forced_root_block : '',
452 content_css: baseurl+"/view/custom_tinymce.css",
453 theme_advanced_path : false,
459 * sprintf in javascript
460 * "{0} and {1}".format('zero','uno');
462 String.prototype.format = function() {
463 var formatted = this;
464 for (var i = 0; i < arguments.length; i++) {
465 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
466 formatted = formatted.replace(regexp, arguments[i]);
471 Array.prototype.remove = function(item) {
472 to=undefined; from=this.indexOf(item);
473 var rest = this.slice((to || from) + 1 || this.length);
474 this.length = from < 0 ? this.length + from : from;
475 return this.push.apply(this, rest);