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);
100 var intro = $(data).find('intro').text();
101 if(intro == 0) { intro = ''; $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
102 $('#intro-update').html(intro);
104 var mail = $(data).find('mail').text();
105 if(mail == 0) { mail = ''; $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
106 $('#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.html("<li><a href='"+baseurl+"/notifications/network'>Show All Notifications</a></li>");
116 //nnm.attr('popup','true');
117 eNotif.children("note").each(function(){
119 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
120 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
125 $("#nav-notifications-linkmenu").removeClass("on");
126 $("#nav-notifications-menu").html(notifications_empty);
128 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
129 $('#notify-update').html(notif);
131 var eSysmsg = $(data).find('sysmsgs');
132 eSysmsg.children("notice").each(function(){
133 text = $(this).text();
134 $.jGrowl(text, { sticky: true, theme: 'notice' });
136 eSysmsg.children("info").each(function(){
137 text = $(this).text();
138 $.jGrowl(text, { sticky: false, theme: 'info' });
145 // Allow folks to stop the ajax page updates with the pause/break key
146 $(document).keypress(function(event) {
147 if(event.keyCode == '19') {
148 event.preventDefault();
149 if(stopped == false) {
151 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
155 $('#pause').html('');
160 if(stopped == true) {
162 $('#pause').html('');
169 function NavUpdate() {
171 if($('#live-network').length) { src = 'network'; liveUpdate(); }
172 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
173 if($('#live-community').length) { src = 'community'; liveUpdate(); }
174 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
175 if($('#live-display').length) {
178 window.location.href=window.location.href
181 if($('#live-photos').length) {
184 window.location.href=window.location.href
189 $.get("ping",function(data) {
190 $(data).find('result').each(function() {
191 // send nav-update event
192 $('nav').trigger('nav-update', this);
196 timer = setTimeout(NavUpdate,30000);
199 function liveUpdate() {
200 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
201 if(($('.comment-edit-text-full').length) || (in_progress)) {
202 livetime = setTimeout(liveUpdate, 10000);
205 prev = 'live-' + src;
208 var udargs = ((netargs.length) ? '/' + netargs : '');
209 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
211 $.get(update_url,function(data) {
213 $('.ccollapse-wrapper',data).each(function() {
214 var ident = $(this).attr('id');
215 var is_hidden = $('#' + ident).is(':hidden');
216 if($('#' + ident).length) {
217 $('#' + ident).replaceWith($(this));
219 $('#' + ident).hide();
222 $('.wall-item-outside-wrapper',data).each(function() {
223 var ident = $(this).attr('id');
224 if($('#' + ident).length == 0) {
225 $('img',this).each(function() {
226 $(this).attr('src',$(this).attr('dst'));
228 $('#' + prev).after($(this));
232 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
233 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
234 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
235 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
236 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
237 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
238 $(this).attr('src',$(this).attr('dst'));
243 $('.like-rotator').hide();
246 $('body').css('cursor', 'auto');
251 function imgbright(node) {
252 $(node).removeClass("drophide").addClass("drop");
255 function imgdull(node) {
256 $(node).removeClass("drop").addClass("drophide");
259 // Since our ajax calls are asynchronous, we will give a few
260 // seconds for the first ajax call (setting like/dislike), then
261 // run the updater to pick up any changes and display on the page.
262 // The updater will turn any rotators off when it's done.
263 // This function will have returned long before any of these
264 // events have completed and therefore there won't be any
265 // visible feedback that anything changed without all this
266 // trickery. This still could cause confusion if the "like" ajax call
267 // is delayed and NavUpdate runs before it completes.
269 function dolike(ident,verb) {
270 $('#like-rotator-' + ident.toString()).show();
271 $.get('like/' + ident.toString() + '?verb=' + verb );
272 if(timer) clearTimeout(timer);
273 timer = setTimeout(NavUpdate,3000);
277 function dostar(ident) {
278 ident = ident.toString();
279 $('#like-rotator-' + ident).show();
280 $.get('starred/' + ident, function(data) {
281 if(data.match(/1/)) {
282 $('#starred-' + ident).addClass('starred');
283 $('#starred-' + ident).removeClass('unstarred');
284 $('#star-' + ident).addClass('hidden');
285 $('#unstar-' + ident).removeClass('hidden');
288 $('#starred-' + ident).addClass('unstarred');
289 $('#starred-' + ident).removeClass('starred');
290 $('#star-' + ident).removeClass('hidden');
291 $('#unstar-' + ident).addClass('hidden');
293 $('#like-rotator-' + ident).hide();
297 function getPosition(e) {
298 var cursor = {x:0, y:0};
299 if ( e.pageX || e.pageY ) {
304 if( e.clientX || e.clientY ) {
305 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
306 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
318 var lockvisible = false;
320 function lockview(event,id) {
321 event = event || window.event;
322 cursor = getPosition(event);
328 $.get('lockview/' + id, function(data) {
329 $('#panel').html(data);
330 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
336 function lockviewhide() {
341 function post_comment(id) {
343 $('body').css('cursor', 'wait');
346 $("#comment-edit-form-" + id).serialize(),
349 $("#comment-edit-wrapper-" + id).hide();
350 $("#comment-edit-text-" + id).val('');
351 var tarea = document.getElementById("comment-edit-text-" + id);
353 commentClose(tarea,id);
354 if(timer) clearTimeout(timer);
355 timer = setTimeout(NavUpdate,10);
358 window.location.href=data.reload;
368 // Converts the binary representation of data to hex
371 // discuss at: http://phpjs.org/functions/bin2hex
372 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
373 // + bugfixed by: Onno Marsman
374 // + bugfixed by: Linuxworld
375 // * example 1: bin2hex('Kev');
376 // * returns 1: '4b6576'
377 // * example 2: bin2hex(String.fromCharCode(0x00));
379 var v,i, f = 0, a = [];
383 for (i = 0; i<f; i++) {
384 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
390 function groupChangeMember(gid,cid) {
391 $('body .fakelink').css('cursor', 'wait');
392 $.get('group/' + gid + '/' + cid, function(data) {
393 $('#group-update-wrapper').html(data);
394 $('body .fakelink').css('cursor', 'auto');
398 function profChangeMember(gid,cid) {
399 $('body .fakelink').css('cursor', 'wait');
400 $.get('profperm/' + gid + '/' + cid, function(data) {
401 $('#prof-update-wrapper').html(data);
402 $('body .fakelink').css('cursor', 'auto');
406 function contactgroupChangeMember(gid,cid) {
407 $('body').css('cursor', 'wait');
408 $.get('contactgroup/' + gid + '/' + cid, function(data) {
409 $('body').css('cursor', 'auto');
414 function checkboxhighlight(box) {
415 if($(box).is(':checked')) {
416 $(box).addClass('checkeditem');
419 $(box).removeClass('checkeditem');
423 function setupFieldRichtext(){
426 mode : "specific_textareas",
427 editor_selector: "fieldRichtext",
428 plugins : "bbcode,paste",
429 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
430 theme_advanced_buttons2 : "",
431 theme_advanced_buttons3 : "",
432 theme_advanced_toolbar_location : "top",
433 theme_advanced_toolbar_align : "center",
434 theme_advanced_blockformats : "blockquote,code",
435 paste_text_sticky : true,
436 entity_encoding : "raw",
437 add_unload_trigger : false,
438 remove_linebreaks : false,
439 force_p_newlines : false,
440 force_br_newlines : true,
441 forced_root_block : '',
443 content_css: baseurl+"/view/custom_tinymce.css",
444 theme_advanced_path : false,
449 * sprintf in javascript
450 * "{0} and {1}".format('zero','uno');
452 String.prototype.format = function() {
453 var formatted = this;
454 for (var i = 0; i < arguments.length; i++) {
455 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
456 formatted = formatted.replace(regexp, arguments[i]);
461 Array.prototype.remove = function(item) {
462 to=undefined; from=this.indexOf(item);
463 var rest = this.slice((to || from) + 1 || this.length);
464 this.length = from < 0 ? this.length + from : from;
465 return this.push.apply(this, rest);