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 eNotif = $(data).find('notif')
99 notif = eNotif.attr('count');
101 $("#nav-notifications-linkmenu").addClass("on");
102 nnm = $("#nav-notifications-menu");
105 nnm.html("<li><a href='/notifications/network'>Show All Notifications</a></li>");
107 //nnm.attr('popup','true');
108 eNotif.children("note").each(function(){
110 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
111 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
116 $("#nav-notifications-linkmenu").removeClass("on");
117 $("#nav-notifications-menu").html(notifications_empty);
119 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
120 $('#notify-update').html(notif);
122 var eSysmsg = $(data).find('sysmsgs');
123 eSysmsg.children("notice").each(function(){
124 text = $(this).text();
125 $.jGrowl(text, { sticky: true, theme: 'notice' });
127 eSysmsg.children("info").each(function(){
128 text = $(this).text();
129 $.jGrowl(text, { sticky: false, theme: 'info' });
136 // Allow folks to stop the ajax page updates with the pause/break key
137 $(document).keypress(function(event) {
138 if(event.keyCode == '19') {
139 event.preventDefault();
140 if(stopped == false) {
142 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
146 $('#pause').html('');
151 if(stopped == true) {
153 $('#pause').html('');
160 function NavUpdate() {
162 if($('#live-network').length) { src = 'network'; liveUpdate(); }
163 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
164 if($('#live-community').length) { src = 'community'; liveUpdate(); }
165 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
166 if($('#live-display').length) {
169 window.location.href=window.location.href
172 if($('#live-photos').length) {
175 window.location.href=window.location.href
180 $.get("ping",function(data) {
181 $(data).find('result').each(function() {
182 // send nav-update event
183 $('nav').trigger('nav-update', this);
187 timer = setTimeout(NavUpdate,30000);
190 function liveUpdate() {
191 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
192 if(($('.comment-edit-text-full').length) || (in_progress)) {
193 livetime = setTimeout(liveUpdate, 10000);
196 prev = 'live-' + src;
199 var udargs = ((netargs.length) ? '/' + netargs : '');
200 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
202 $.get(update_url,function(data) {
204 $('.ccollapse-wrapper',data).each(function() {
205 var ident = $(this).attr('id');
206 var is_hidden = $('#' + ident).is(':hidden');
207 if($('#' + ident).length) {
208 $('#' + ident).replaceWith($(this));
210 $('#' + ident).hide();
213 $('.wall-item-outside-wrapper',data).each(function() {
214 var ident = $(this).attr('id');
215 if($('#' + ident).length == 0) {
216 $('img',this).each(function() {
217 $(this).attr('src',$(this).attr('dst'));
219 $('#' + prev).after($(this));
223 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
224 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
225 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
226 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
227 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
228 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
229 $(this).attr('src',$(this).attr('dst'));
234 $('.like-rotator').hide();
237 $('body').css('cursor', 'auto');
242 function imgbright(node) {
243 $(node).removeClass("drophide").addClass("drop");
246 function imgdull(node) {
247 $(node).removeClass("drop").addClass("drophide");
250 // Since our ajax calls are asynchronous, we will give a few
251 // seconds for the first ajax call (setting like/dislike), then
252 // run the updater to pick up any changes and display on the page.
253 // The updater will turn any rotators off when it's done.
254 // This function will have returned long before any of these
255 // events have completed and therefore there won't be any
256 // visible feedback that anything changed without all this
257 // trickery. This still could cause confusion if the "like" ajax call
258 // is delayed and NavUpdate runs before it completes.
260 function dolike(ident,verb) {
261 $('#like-rotator-' + ident.toString()).show();
262 $.get('like/' + ident.toString() + '?verb=' + verb );
263 if(timer) clearTimeout(timer);
264 timer = setTimeout(NavUpdate,3000);
268 function dostar(ident) {
269 ident = ident.toString();
270 $('#like-rotator-' + ident).show();
271 $.get('starred/' + ident, function(data) {
272 if(data.match(/1/)) {
273 $('#starred-' + ident).addClass('starred');
274 $('#starred-' + ident).removeClass('unstarred');
275 $('#star-' + ident).addClass('hidden');
276 $('#unstar-' + ident).removeClass('hidden');
279 $('#starred-' + ident).addClass('unstarred');
280 $('#starred-' + ident).removeClass('starred');
281 $('#star-' + ident).removeClass('hidden');
282 $('#unstar-' + ident).addClass('hidden');
284 $('#like-rotator-' + ident).hide();
288 function getPosition(e) {
289 var cursor = {x:0, y:0};
290 if ( e.pageX || e.pageY ) {
295 if( e.clientX || e.clientY ) {
296 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
297 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
309 var lockvisible = false;
311 function lockview(event,id) {
312 event = event || window.event;
313 cursor = getPosition(event);
319 $.get('lockview/' + id, function(data) {
320 $('#panel').html(data);
321 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
327 function lockviewhide() {
332 function post_comment(id) {
334 $('body').css('cursor', 'wait');
337 $("#comment-edit-form-" + id).serialize(),
340 $("#comment-edit-wrapper-" + id).hide();
341 $("#comment-edit-text-" + id).val('');
342 var tarea = document.getElementById("comment-edit-text-" + id);
344 commentClose(tarea,id);
345 if(timer) clearTimeout(timer);
346 timer = setTimeout(NavUpdate,10);
349 window.location.href=data.reload;
359 // Converts the binary representation of data to hex
362 // discuss at: http://phpjs.org/functions/bin2hex
363 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
364 // + bugfixed by: Onno Marsman
365 // + bugfixed by: Linuxworld
366 // * example 1: bin2hex('Kev');
367 // * returns 1: '4b6576'
368 // * example 2: bin2hex(String.fromCharCode(0x00));
370 var v,i, f = 0, a = [];
374 for (i = 0; i<f; i++) {
375 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
381 function groupChangeMember(gid,cid) {
382 $('body .fakelink').css('cursor', 'wait');
383 $.get('group/' + gid + '/' + cid, function(data) {
384 $('#group-update-wrapper').html(data);
385 $('body .fakelink').css('cursor', 'auto');
389 function profChangeMember(gid,cid) {
390 $('body .fakelink').css('cursor', 'wait');
391 $.get('profperm/' + gid + '/' + cid, function(data) {
392 $('#prof-update-wrapper').html(data);
393 $('body .fakelink').css('cursor', 'auto');
397 function contactgroupChangeMember(gid,cid) {
398 $('body').css('cursor', 'wait');
399 $.get('contactgroup/' + gid + '/' + cid, function(data) {
400 $('body').css('cursor', 'auto');
405 function checkboxhighlight(box) {
406 if($(box).is(':checked')) {
407 $(box).addClass('checkeditem');
410 $(box).removeClass('checkeditem');
414 function setupFieldRichtext(){
417 mode : "specific_textareas",
418 editor_selector: "fieldRichtext",
419 plugins : "bbcode,paste",
420 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
421 theme_advanced_buttons2 : "",
422 theme_advanced_buttons3 : "",
423 theme_advanced_toolbar_location : "top",
424 theme_advanced_toolbar_align : "center",
425 theme_advanced_blockformats : "blockquote,code",
426 paste_text_sticky : true,
427 entity_encoding : "raw",
428 add_unload_trigger : false,
429 remove_linebreaks : false,
430 force_p_newlines : false,
431 force_br_newlines : true,
432 forced_root_block : '',
434 content_css: baseurl+"/view/custom_tinymce.css",
435 theme_advanced_path : false,
440 * sprintf in javascript
441 * "{0} and {1}".format('zero','uno');
443 String.prototype.format = function() {
444 var formatted = this;
445 for (var i = 0; i < arguments.length; i++) {
446 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
447 formatted = formatted.replace(regexp, arguments[i]);
452 Array.prototype.remove = function(item) {
453 to=undefined; from=this.indexOf(item);
454 var rest = this.slice((to || from) + 1 || this.length);
455 this.length = from < 0 ? this.length + from : from;
456 return this.push.apply(this, rest);