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");
84 /* notifications template */
85 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
86 var notifications_empty = unescape($("#nav-notifications-menu").html());
88 /* nav update event */
89 $('nav').bind('nav-update', function(e,data){;
90 var net = $(data).find('net').text();
91 if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
92 $('#net-update').html(net);
94 var home = $(data).find('home').text();
95 if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
96 $('#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);
108 var eNotif = $(data).find('notif')
109 notif = eNotif.attr('count');
111 $("#nav-notifications-linkmenu").addClass("on");
112 nnm = $("#nav-notifications-menu");
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'));
122 $("#nav-notifications-linkmenu").removeClass("on");
123 $("#nav-notifications-menu").html(notifications_empty);
125 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
126 $('#notify-update').html(notif);
128 var eSysmsg = $(data).find('sysmsgs');
129 eSysmsg.children("notice").each(function(){
130 text = $(this).text();
131 $.jGrowl(text, { sticky: true, theme: 'notice' });
133 eSysmsg.children("info").each(function(){
134 text = $(this).text();
135 $.jGrowl(text, { sticky: false, theme: 'info' });
142 // Allow folks to stop the ajax page updates with the pause/break key
143 $(document).keypress(function(event) {
144 if(event.keyCode == '19') {
145 event.preventDefault();
146 if(stopped == false) {
148 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
152 $('#pause').html('');
157 if(stopped == true) {
159 $('#pause').html('');
166 function NavUpdate() {
168 $.get("ping",function(data) {
169 $(data).find('result').each(function() {
170 // send nav-update event
171 $('nav').trigger('nav-update', this);
177 if($('#live-network').length) { src = 'network'; liveUpdate(); }
178 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
179 if($('#live-community').length) { src = 'community'; liveUpdate(); }
180 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
181 if($('#live-display').length) {
184 window.location.href=window.location.href
187 if($('#live-photos').length) {
190 window.location.href=window.location.href
194 timer = setTimeout(NavUpdate,30000);
197 function liveUpdate() {
198 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
199 if(($('.comment-edit-text-full').length) || (in_progress)) {
200 livetime = setTimeout(liveUpdate, 10000);
203 prev = 'live-' + src;
206 var udargs = ((netargs.length) ? '/' + netargs : '');
207 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
209 $.get(update_url,function(data) {
211 $('.ccollapse-wrapper',data).each(function() {
212 var ident = $(this).attr('id');
213 var is_hidden = $('#' + ident).is(':hidden');
214 if($('#' + ident).length) {
215 $('#' + ident).replaceWith($(this));
217 $('#' + ident).hide();
220 $('.wall-item-outside-wrapper',data).each(function() {
221 var ident = $(this).attr('id');
222 if($('#' + ident).length == 0) {
223 $('img',this).each(function() {
224 $(this).attr('src',$(this).attr('dst'));
226 $('#' + prev).after($(this));
230 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
231 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
232 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
233 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
234 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
235 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
236 $(this).attr('src',$(this).attr('dst'));
241 $('.like-rotator').hide();
244 $('body').css('cursor', 'auto');
249 function imgbright(node) {
250 $(node).removeClass("drophide").addClass("drop");
253 function imgdull(node) {
254 $(node).removeClass("drop").addClass("drophide");
257 // Since our ajax calls are asynchronous, we will give a few
258 // seconds for the first ajax call (setting like/dislike), then
259 // run the updater to pick up any changes and display on the page.
260 // The updater will turn any rotators off when it's done.
261 // This function will have returned long before any of these
262 // events have completed and therefore there won't be any
263 // visible feedback that anything changed without all this
264 // trickery. This still could cause confusion if the "like" ajax call
265 // is delayed and NavUpdate runs before it completes.
267 function dolike(ident,verb) {
268 $('#like-rotator-' + ident.toString()).show();
269 $.get('like/' + ident.toString() + '?verb=' + verb );
270 if(timer) clearTimeout(timer);
271 timer = setTimeout(NavUpdate,3000);
275 function dostar(ident) {
276 ident = ident.toString();
277 $('#like-rotator-' + ident).show();
278 $.get('starred/' + ident, function(data) {
279 if(data.match(/1/)) {
280 $('#starred-' + ident).addClass('starred');
281 $('#starred-' + ident).removeClass('unstarred');
282 $('#star-' + ident).addClass('hidden');
283 $('#unstar-' + ident).removeClass('hidden');
286 $('#starred-' + ident).addClass('unstarred');
287 $('#starred-' + ident).removeClass('starred');
288 $('#star-' + ident).removeClass('hidden');
289 $('#unstar-' + ident).addClass('hidden');
291 $('#like-rotator-' + ident).hide();
295 function getPosition(e) {
296 var cursor = {x:0, y:0};
297 if ( e.pageX || e.pageY ) {
302 if( e.clientX || e.clientY ) {
303 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
304 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
316 var lockvisible = false;
318 function lockview(event,id) {
319 event = event || window.event;
320 cursor = getPosition(event);
326 $.get('lockview/' + id, function(data) {
327 $('#panel').html(data);
328 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
334 function lockviewhide() {
339 function post_comment(id) {
341 $('body').css('cursor', 'wait');
344 $("#comment-edit-form-" + id).serialize(),
347 $("#comment-edit-wrapper-" + id).hide();
348 $("#comment-edit-text-" + id).val('');
349 var tarea = document.getElementById("comment-edit-text-" + id);
351 commentClose(tarea,id);
352 if(timer) clearTimeout(timer);
353 timer = setTimeout(NavUpdate,10);
356 window.location.href=data.reload;
366 // Converts the binary representation of data to hex
369 // discuss at: http://phpjs.org/functions/bin2hex
370 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
371 // + bugfixed by: Onno Marsman
372 // + bugfixed by: Linuxworld
373 // * example 1: bin2hex('Kev');
374 // * returns 1: '4b6576'
375 // * example 2: bin2hex(String.fromCharCode(0x00));
377 var v,i, f = 0, a = [];
381 for (i = 0; i<f; i++) {
382 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
388 function groupChangeMember(gid,cid) {
389 $('body .fakelink').css('cursor', 'wait');
390 $.get('group/' + gid + '/' + cid, function(data) {
391 $('#group-update-wrapper').html(data);
392 $('body .fakelink').css('cursor', 'auto');
396 function profChangeMember(gid,cid) {
397 $('body .fakelink').css('cursor', 'wait');
398 $.get('profperm/' + gid + '/' + cid, function(data) {
399 $('#prof-update-wrapper').html(data);
400 $('body .fakelink').css('cursor', 'auto');
404 function contactgroupChangeMember(gid,cid) {
405 $('body').css('cursor', 'wait');
406 $.get('contactgroup/' + gid + '/' + cid, function(data) {
407 $('body').css('cursor', 'auto');
412 function checkboxhighlight(box) {
413 if($(box).is(':checked')) {
414 $(box).addClass('checkeditem');
417 $(box).removeClass('checkeditem');
421 function setupFieldRichtext(){
424 mode : "specific_textareas",
425 editor_selector: "fieldRichtext",
426 plugins : "bbcode,paste",
427 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
428 theme_advanced_buttons2 : "",
429 theme_advanced_buttons3 : "",
430 theme_advanced_toolbar_location : "top",
431 theme_advanced_toolbar_align : "center",
432 theme_advanced_blockformats : "blockquote,code",
433 paste_text_sticky : true,
434 entity_encoding : "raw",
435 add_unload_trigger : false,
436 remove_linebreaks : false,
437 force_p_newlines : false,
438 force_br_newlines : true,
439 forced_root_block : '',
441 content_css: baseurl+"/view/custom_tinymce.css",
442 theme_advanced_path : false,
447 * sprintf in javascript
448 * "{0} and {1}".format('zero','uno');
450 String.prototype.format = function() {
451 var formatted = this;
452 for (var i = 0; i < arguments.length; i++) {
453 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
454 formatted = formatted.replace(regexp, arguments[i]);
459 Array.prototype.remove = function(item) {
460 to=undefined; from=this.indexOf(item);
461 var rest = this.slice((to || from) + 1 || this.length);
462 this.length = from < 0 ? this.length + from : from;
463 return this.push.apply(this, rest);