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.html("<li><a href='"+baseurl+"/notifications/network'>Show All Notifications</a></li>");
106 //nnm.attr('popup','true');
107 eNotif.children("note").each(function(){
109 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
110 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
115 $("#nav-notifications-linkmenu").removeClass("on");
116 $("#nav-notifications-menu").html(notifications_empty);
118 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
119 $('#notify-update').html(notif);
121 var eSysmsg = $(data).find('sysmsgs');
122 eSysmsg.children("notice").each(function(){
123 text = $(this).text();
124 $.jGrowl(text, { sticky: true, theme: 'notice' });
126 eSysmsg.children("info").each(function(){
127 text = $(this).text();
128 $.jGrowl(text, { sticky: false, theme: 'info' });
135 // Allow folks to stop the ajax page updates with the pause/break key
136 $(document).keypress(function(event) {
137 if(event.keyCode == '19') {
138 event.preventDefault();
139 if(stopped == false) {
141 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
145 $('#pause').html('');
150 if(stopped == true) {
152 $('#pause').html('');
159 function NavUpdate() {
161 if($('#live-network').length) { src = 'network'; liveUpdate(); }
162 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
163 if($('#live-community').length) { src = 'community'; liveUpdate(); }
164 if($('#live-notes').length) { src = 'notes'; liveUpdate(); }
165 if($('#live-display').length) {
168 window.location.href=window.location.href
171 if($('#live-photos').length) {
174 window.location.href=window.location.href
179 $.get("ping",function(data) {
180 $(data).find('result').each(function() {
181 // send nav-update event
182 $('nav').trigger('nav-update', this);
186 timer = setTimeout(NavUpdate,30000);
189 function liveUpdate() {
190 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
191 if(($('.comment-edit-text-full').length) || (in_progress)) {
192 livetime = setTimeout(liveUpdate, 10000);
195 prev = 'live-' + src;
198 var udargs = ((netargs.length) ? '/' + netargs : '');
199 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
201 $.get(update_url,function(data) {
203 $('.ccollapse-wrapper',data).each(function() {
204 var ident = $(this).attr('id');
205 var is_hidden = $('#' + ident).is(':hidden');
206 if($('#' + ident).length) {
207 $('#' + ident).replaceWith($(this));
209 $('#' + ident).hide();
212 $('.wall-item-outside-wrapper',data).each(function() {
213 var ident = $(this).attr('id');
214 if($('#' + ident).length == 0) {
215 $('img',this).each(function() {
216 $(this).attr('src',$(this).attr('dst'));
218 $('#' + prev).after($(this));
222 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
223 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
224 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
225 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
226 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
227 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
228 $(this).attr('src',$(this).attr('dst'));
233 $('.like-rotator').hide();
236 $('body').css('cursor', 'auto');
241 function imgbright(node) {
242 $(node).removeClass("drophide").addClass("drop");
245 function imgdull(node) {
246 $(node).removeClass("drop").addClass("drophide");
249 // Since our ajax calls are asynchronous, we will give a few
250 // seconds for the first ajax call (setting like/dislike), then
251 // run the updater to pick up any changes and display on the page.
252 // The updater will turn any rotators off when it's done.
253 // This function will have returned long before any of these
254 // events have completed and therefore there won't be any
255 // visible feedback that anything changed without all this
256 // trickery. This still could cause confusion if the "like" ajax call
257 // is delayed and NavUpdate runs before it completes.
259 function dolike(ident,verb) {
260 $('#like-rotator-' + ident.toString()).show();
261 $.get('like/' + ident.toString() + '?verb=' + verb );
262 if(timer) clearTimeout(timer);
263 timer = setTimeout(NavUpdate,3000);
267 function dostar(ident) {
268 ident = ident.toString();
269 $('#like-rotator-' + ident).show();
270 $.get('starred/' + ident, function(data) {
271 if(data.match(/1/)) {
272 $('#starred-' + ident).addClass('starred');
273 $('#starred-' + ident).removeClass('unstarred');
274 $('#star-' + ident).addClass('hidden');
275 $('#unstar-' + ident).removeClass('hidden');
278 $('#starred-' + ident).addClass('unstarred');
279 $('#starred-' + ident).removeClass('starred');
280 $('#star-' + ident).removeClass('hidden');
281 $('#unstar-' + ident).addClass('hidden');
283 $('#like-rotator-' + ident).hide();
287 function getPosition(e) {
288 var cursor = {x:0, y:0};
289 if ( e.pageX || e.pageY ) {
294 if( e.clientX || e.clientY ) {
295 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
296 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
308 var lockvisible = false;
310 function lockview(event,id) {
311 event = event || window.event;
312 cursor = getPosition(event);
318 $.get('lockview/' + id, function(data) {
319 $('#panel').html(data);
320 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
326 function lockviewhide() {
331 function post_comment(id) {
333 $('body').css('cursor', 'wait');
336 $("#comment-edit-form-" + id).serialize(),
339 $("#comment-edit-wrapper-" + id).hide();
340 $("#comment-edit-text-" + id).val('');
341 var tarea = document.getElementById("comment-edit-text-" + id);
343 commentClose(tarea,id);
344 if(timer) clearTimeout(timer);
345 timer = setTimeout(NavUpdate,10);
348 window.location.href=data.reload;
358 // Converts the binary representation of data to hex
361 // discuss at: http://phpjs.org/functions/bin2hex
362 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
363 // + bugfixed by: Onno Marsman
364 // + bugfixed by: Linuxworld
365 // * example 1: bin2hex('Kev');
366 // * returns 1: '4b6576'
367 // * example 2: bin2hex(String.fromCharCode(0x00));
369 var v,i, f = 0, a = [];
373 for (i = 0; i<f; i++) {
374 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
380 function groupChangeMember(gid,cid) {
381 $('body .fakelink').css('cursor', 'wait');
382 $.get('group/' + gid + '/' + cid, function(data) {
383 $('#group-update-wrapper').html(data);
384 $('body .fakelink').css('cursor', 'auto');
388 function profChangeMember(gid,cid) {
389 $('body .fakelink').css('cursor', 'wait');
390 $.get('profperm/' + gid + '/' + cid, function(data) {
391 $('#prof-update-wrapper').html(data);
392 $('body .fakelink').css('cursor', 'auto');
396 function contactgroupChangeMember(gid,cid) {
397 $('body').css('cursor', 'wait');
398 $.get('contactgroup/' + gid + '/' + cid, function(data) {
399 $('body').css('cursor', 'auto');
404 function checkboxhighlight(box) {
405 if($(box).is(':checked')) {
406 $(box).addClass('checkeditem');
409 $(box).removeClass('checkeditem');
413 function setupFieldRichtext(){
416 mode : "specific_textareas",
417 editor_selector: "fieldRichtext",
418 plugins : "bbcode,paste",
419 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
420 theme_advanced_buttons2 : "",
421 theme_advanced_buttons3 : "",
422 theme_advanced_toolbar_location : "top",
423 theme_advanced_toolbar_align : "center",
424 theme_advanced_blockformats : "blockquote,code",
425 paste_text_sticky : true,
426 entity_encoding : "raw",
427 add_unload_trigger : false,
428 remove_linebreaks : false,
429 force_p_newlines : false,
430 force_br_newlines : true,
431 forced_root_block : '',
433 content_css: baseurl+"/view/custom_tinymce.css",
434 theme_advanced_path : false,
439 * sprintf in javascript
440 * "{0} and {1}".format('zero','uno');
442 String.prototype.format = function() {
443 var formatted = this;
444 for (var i = 0; i < arguments.length; i++) {
445 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
446 formatted = formatted.replace(regexp, arguments[i]);
451 Array.prototype.remove = function(item) {
452 to=undefined; from=this.indexOf(item);
453 var rest = this.slice((to || from) + 1 || this.length);
454 this.length = from < 0 ? this.length + from : from;
455 return this.push.apply(this, rest);