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");
104 //nnm.attr('popup','true');
105 eNotif.children("note").each(function(){
107 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
108 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
112 $("#nav-notifications-linkmenu").removeClass("on");
113 $("#nav-notifications-menu").html(notifications_empty);
115 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
116 $('#notify-update').html(notif);
118 var eSysmsg = $(data).find('sysmsgs');
119 eSysmsg.children("notice").each(function(){
120 text = $(this).text();
121 $.jGrowl(text, { sticky: true, theme: 'notice' });
123 eSysmsg.children("info").each(function(){
124 text = $(this).text();
125 $.jGrowl(text, { sticky: false, theme: 'info' });
132 // Allow folks to stop the ajax page updates with the pause/break key
133 $(document).keypress(function(event) {
134 if(event.keyCode == '19') {
135 event.preventDefault();
136 if(stopped == false) {
138 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
142 $('#pause').html('');
147 if(stopped == true) {
149 $('#pause').html('');
156 function NavUpdate() {
158 if($('#live-network').length) { src = 'network'; liveUpdate(); }
159 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
160 if($('#live-community').length) { src = 'community'; liveUpdate(); }
161 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
162 if($('#live-display').length) {
165 window.location.href=window.location.href
168 if($('#live-photos').length) {
171 window.location.href=window.location.href
176 $.get("ping",function(data) {
177 $(data).find('result').each(function() {
178 // send nav-update event
179 $('nav').trigger('nav-update', this);
183 timer = setTimeout(NavUpdate,30000);
186 function liveUpdate() {
187 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
188 if(($('.comment-edit-text-full').length) || (in_progress)) {
189 livetime = setTimeout(liveUpdate, 10000);
192 prev = 'live-' + src;
195 var udargs = ((netargs.length) ? '/' + netargs : '');
196 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
198 $.get(update_url,function(data) {
200 $('.ccollapse-wrapper',data).each(function() {
201 var ident = $(this).attr('id');
202 var is_hidden = $('#' + ident).is(':hidden');
203 if($('#' + ident).length) {
204 $('#' + ident).replaceWith($(this));
206 $('#' + ident).hide();
209 $('.wall-item-outside-wrapper',data).each(function() {
210 var ident = $(this).attr('id');
211 if($('#' + ident).length == 0) {
212 $('img',this).each(function() {
213 $(this).attr('src',$(this).attr('dst'));
215 $('#' + prev).after($(this));
219 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
220 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
221 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
222 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
223 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
224 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
225 $(this).attr('src',$(this).attr('dst'));
230 $('.like-rotator').hide();
233 $('body').css('cursor', 'auto');
238 function imgbright(node) {
239 $(node).removeClass("drophide").addClass("drop");
242 function imgdull(node) {
243 $(node).removeClass("drop").addClass("drophide");
246 // Since our ajax calls are asynchronous, we will give a few
247 // seconds for the first ajax call (setting like/dislike), then
248 // run the updater to pick up any changes and display on the page.
249 // The updater will turn any rotators off when it's done.
250 // This function will have returned long before any of these
251 // events have completed and therefore there won't be any
252 // visible feedback that anything changed without all this
253 // trickery. This still could cause confusion if the "like" ajax call
254 // is delayed and NavUpdate runs before it completes.
256 function dolike(ident,verb) {
257 $('#like-rotator-' + ident.toString()).show();
258 $.get('like/' + ident.toString() + '?verb=' + verb );
259 if(timer) clearTimeout(timer);
260 timer = setTimeout(NavUpdate,3000);
264 function dostar(ident) {
265 ident = ident.toString();
266 $('#like-rotator-' + ident).show();
267 $.get('starred/' + ident, function(data) {
268 if(data.match(/1/)) {
269 $('#starred-' + ident).addClass('starred');
270 $('#starred-' + ident).removeClass('unstarred');
271 $('#star-' + ident).addClass('hidden');
272 $('#unstar-' + ident).removeClass('hidden');
275 $('#starred-' + ident).addClass('unstarred');
276 $('#starred-' + ident).removeClass('starred');
277 $('#star-' + ident).removeClass('hidden');
278 $('#unstar-' + ident).addClass('hidden');
280 $('#like-rotator-' + ident).hide();
284 function getPosition(e) {
285 var cursor = {x:0, y:0};
286 if ( e.pageX || e.pageY ) {
291 if( e.clientX || e.clientY ) {
292 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
293 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
305 var lockvisible = false;
307 function lockview(event,id) {
308 event = event || window.event;
309 cursor = getPosition(event);
315 $.get('lockview/' + id, function(data) {
316 $('#panel').html(data);
317 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
323 function lockviewhide() {
328 function post_comment(id) {
330 $('body').css('cursor', 'wait');
333 $("#comment-edit-form-" + id).serialize(),
336 $("#comment-edit-wrapper-" + id).hide();
337 $("#comment-edit-text-" + id).val('');
338 var tarea = document.getElementById("comment-edit-text-" + id);
340 commentClose(tarea,id);
341 if(timer) clearTimeout(timer);
342 timer = setTimeout(NavUpdate,10);
345 window.location.href=data.reload;
355 // Converts the binary representation of data to hex
358 // discuss at: http://phpjs.org/functions/bin2hex
359 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
360 // + bugfixed by: Onno Marsman
361 // + bugfixed by: Linuxworld
362 // * example 1: bin2hex('Kev');
363 // * returns 1: '4b6576'
364 // * example 2: bin2hex(String.fromCharCode(0x00));
366 var v,i, f = 0, a = [];
370 for (i = 0; i<f; i++) {
371 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
377 function groupChangeMember(gid,cid) {
378 $('body .fakelink').css('cursor', 'wait');
379 $.get('group/' + gid + '/' + cid, function(data) {
380 $('#group-update-wrapper').html(data);
381 $('body .fakelink').css('cursor', 'auto');
385 function profChangeMember(gid,cid) {
386 $('body .fakelink').css('cursor', 'wait');
387 $.get('profperm/' + gid + '/' + cid, function(data) {
388 $('#prof-update-wrapper').html(data);
389 $('body .fakelink').css('cursor', 'auto');
393 function contactgroupChangeMember(gid,cid) {
394 $('body').css('cursor', 'wait');
395 $.get('contactgroup/' + gid + '/' + cid, function(data) {
396 $('body').css('cursor', 'auto');
401 function checkboxhighlight(box) {
402 if($(box).is(':checked')) {
403 $(box).addClass('checkeditem');
406 $(box).removeClass('checkeditem');
410 function setupFieldRichtext(){
413 mode : "specific_textareas",
414 editor_selector: "fieldRichtext",
415 plugins : "bbcode,paste",
416 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
417 theme_advanced_buttons2 : "",
418 theme_advanced_buttons3 : "",
419 theme_advanced_toolbar_location : "top",
420 theme_advanced_toolbar_align : "center",
421 theme_advanced_blockformats : "blockquote,code",
422 paste_text_sticky : true,
423 entity_encoding : "raw",
424 add_unload_trigger : false,
425 remove_linebreaks : false,
426 force_p_newlines : false,
427 force_br_newlines : true,
428 forced_root_block : '',
430 content_css: baseurl+"/view/custom_tinymce.css",
431 theme_advanced_path : false,
436 * sprintf in javascript
437 * "{0} and {1}".format('zero','uno');
439 String.prototype.format = function() {
440 var formatted = this;
441 for (var i = 0; i < arguments.length; i++) {
442 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
443 formatted = formatted.replace(regexp, arguments[i]);
448 Array.prototype.remove = function(item) {
449 to=undefined; from=this.indexOf(item);
450 var rest = this.slice((to || from) + 1 || this.length);
451 this.length = from < 0 ? this.length + from : from;
452 return this.push.apply(this, rest);