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') );
75 if (menu.attr('popup')=="false") return false;
76 $(this).parent().toggleClass("selected");
83 /* notifications template */
84 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
85 var notifications_empty = unescape($("#nav-notifications-menu").html());
87 /* nav update event */
88 $('nav').bind('nav-update', function(e,data){;
89 var net = $(data).find('net').text();
90 if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
91 $('#net-update').html(net);
93 var home = $(data).find('home').text();
94 if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
95 $('#home-update').html(home);
97 var eNotif = $(data).find('notif')
98 notif = eNotif.attr('count');
100 $("#nav-notifications-linkmenu").addClass("on");
101 nnm = $("#nav-notifications-menu");
103 //nnm.attr('popup','true');
104 eNotif.children("note").each(function(){
106 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
107 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
111 $("#nav-notifications-linkmenu").removeClass("on");
112 $("#nav-notifications-menu").html(notifications_empty);
114 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
115 $('#notify-update').html(notif);
117 var eSysmsg = $(data).find('sysmsgs');
118 eSysmsg.children("notice").each(function(){
119 text = $(this).text();
120 $.jGrowl(text, { sticky: true, theme: 'notice' });
122 eSysmsg.children("info").each(function(){
123 text = $(this).text();
124 $.jGrowl(text, { sticky: false, theme: 'info' });
131 // Allow folks to stop the ajax page updates with the pause/break key
132 $(document).keypress(function(event) {
133 if(event.keyCode == '19') {
134 event.preventDefault();
135 if(stopped == false) {
137 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
141 $('#pause').html('');
146 if(stopped == true) {
148 $('#pause').html('');
155 function NavUpdate() {
157 if($('#live-network').length) { src = 'network'; liveUpdate(); }
158 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
159 if($('#live-community').length) { src = 'community'; liveUpdate(); }
160 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
161 if($('#live-display').length) {
164 window.location.href=window.location.href
167 if($('#live-photos').length) {
170 window.location.href=window.location.href
175 $.get("ping",function(data) {
176 $(data).find('result').each(function() {
177 // send nav-update event
178 $('nav').trigger('nav-update', this);
182 timer = setTimeout(NavUpdate,30000);
185 function liveUpdate() {
186 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
187 if(($('.comment-edit-text-full').length) || (in_progress)) {
188 livetime = setTimeout(liveUpdate, 10000);
191 prev = 'live-' + src;
194 var udargs = ((netargs.length) ? '/' + netargs : '');
195 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
197 $.get(update_url,function(data) {
199 $('.ccollapse-wrapper',data).each(function() {
200 var ident = $(this).attr('id');
201 var is_hidden = $('#' + ident).is(':hidden');
202 if($('#' + ident).length) {
203 $('#' + ident).replaceWith($(this));
205 $('#' + ident).hide();
208 $('.wall-item-outside-wrapper',data).each(function() {
209 var ident = $(this).attr('id');
210 if($('#' + ident).length == 0) {
211 $('img',this).each(function() {
212 $(this).attr('src',$(this).attr('dst'));
214 $('#' + prev).after($(this));
218 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
219 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
220 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
221 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
222 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
223 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
224 $(this).attr('src',$(this).attr('dst'));
229 $('.like-rotator').hide();
232 $('body').css('cursor', 'auto');
237 function imgbright(node) {
238 $(node).removeClass("drophide").addClass("drop");
241 function imgdull(node) {
242 $(node).removeClass("drop").addClass("drophide");
245 // Since our ajax calls are asynchronous, we will give a few
246 // seconds for the first ajax call (setting like/dislike), then
247 // run the updater to pick up any changes and display on the page.
248 // The updater will turn any rotators off when it's done.
249 // This function will have returned long before any of these
250 // events have completed and therefore there won't be any
251 // visible feedback that anything changed without all this
252 // trickery. This still could cause confusion if the "like" ajax call
253 // is delayed and NavUpdate runs before it completes.
255 function dolike(ident,verb) {
256 $('#like-rotator-' + ident.toString()).show();
257 $.get('like/' + ident.toString() + '?verb=' + verb );
258 if(timer) clearTimeout(timer);
259 timer = setTimeout(NavUpdate,3000);
263 function dostar(ident) {
264 $('#like-rotator-' + ident.toString()).show();
265 $.get('starred/' + ident.toString(), function(data) {
266 if(data.match(/1/)) {
267 $('#starred-' + ident.toString()).addClass('starred');
268 $('#starred-' + ident.toString()).removeClass('unstarred');
271 $('#starred-' + ident.toString()).addClass('unstarred');
272 $('#starred-' + ident.toString()).removeClass('starred');
274 $('#like-rotator-' + ident.toString()).hide();
278 function getPosition(e) {
279 var cursor = {x:0, y:0};
280 if ( e.pageX || e.pageY ) {
285 if( e.clientX || e.clientY ) {
286 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
287 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
299 var lockvisible = false;
301 function lockview(event,id) {
302 event = event || window.event;
303 cursor = getPosition(event);
309 $.get('lockview/' + id, function(data) {
310 $('#panel').html(data);
311 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
317 function lockviewhide() {
322 function post_comment(id) {
324 $('body').css('cursor', 'wait');
327 $("#comment-edit-form-" + id).serialize(),
330 $("#comment-edit-wrapper-" + id).hide();
331 $("#comment-edit-text-" + id).val('');
332 var tarea = document.getElementById("comment-edit-text-" + id);
334 commentClose(tarea,id);
335 if(timer) clearTimeout(timer);
336 timer = setTimeout(NavUpdate,10);
339 window.location.href=data.reload;
349 // Converts the binary representation of data to hex
352 // discuss at: http://phpjs.org/functions/bin2hex
353 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
354 // + bugfixed by: Onno Marsman
355 // + bugfixed by: Linuxworld
356 // * example 1: bin2hex('Kev');
357 // * returns 1: '4b6576'
358 // * example 2: bin2hex(String.fromCharCode(0x00));
360 var v,i, f = 0, a = [];
364 for (i = 0; i<f; i++) {
365 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
371 function groupChangeMember(gid,cid) {
372 $('body .fakelink').css('cursor', 'wait');
373 $.get('group/' + gid + '/' + cid, function(data) {
374 $('#group-update-wrapper').html(data);
375 $('body .fakelink').css('cursor', 'auto');
379 function profChangeMember(gid,cid) {
380 $('body .fakelink').css('cursor', 'wait');
381 $.get('profperm/' + gid + '/' + cid, function(data) {
382 $('#prof-update-wrapper').html(data);
383 $('body .fakelink').css('cursor', 'auto');
387 function contactgroupChangeMember(gid,cid) {
388 $('body').css('cursor', 'wait');
389 $.get('contactgroup/' + gid + '/' + cid, function(data) {
390 $('body').css('cursor', 'auto');
395 function checkboxhighlight(box) {
396 if($(box).is(':checked')) {
397 $(box).addClass('checkeditem');
400 $(box).removeClass('checkeditem');
404 function setupFieldRichtext(){
407 mode : "specific_textareas",
408 editor_selector: "fieldRichtext",
409 plugins : "bbcode,paste",
410 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
411 theme_advanced_buttons2 : "",
412 theme_advanced_buttons3 : "",
413 theme_advanced_toolbar_location : "top",
414 theme_advanced_toolbar_align : "center",
415 theme_advanced_blockformats : "blockquote,code",
416 paste_text_sticky : true,
417 entity_encoding : "raw",
418 add_unload_trigger : false,
419 remove_linebreaks : false,
420 force_p_newlines : false,
421 force_br_newlines : true,
422 forced_root_block : '',
424 content_css: baseurl+"/view/custom_tinymce.css",
425 theme_advanced_path : false,
430 * sprintf in javascript
431 * "{0} and {1}".format('zero','uno');
433 String.prototype.format = function() {
434 var formatted = this;
435 for (var i = 0; i < arguments.length; i++) {
436 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
437 formatted = formatted.replace(regexp, arguments[i]);
442 Array.prototype.remove = function(item) {
443 to=undefined; from=this.indexOf(item);
444 var rest = this.slice((to || from) + 1 || this.length);
445 this.length = from < 0 ? this.length + from : from;
446 return this.push.apply(this, rest);