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 /* nav update event */
39 $('nav').bind('nav-update', function(e,data){;
40 var net = $(data).find('net').text();
41 if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
42 $('#net-update').html(net);
43 var home = $(data).find('home').text();
44 if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
45 $('#home-update').html(home);
46 var mail = $(data).find('mail').text();
47 if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
48 $('#mail-update').html(mail);
49 var intro = $(data).find('intro').text();
50 if(intro == 0) { intro = ''; $('#notify-update').hide() } else { $('#notify-update').show() }
51 $('#notify-update').html(intro);
56 // Allow folks to stop the ajax page updates with the pause/break key
57 $(document).keypress(function(event) {
58 if(event.keyCode == '19') {
59 event.preventDefault();
60 if(stopped == false) {
62 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
72 function NavUpdate() {
74 if($('#live-network').length) { src = 'network'; liveUpdate(); }
75 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
76 if($('#live-community').length) { src = 'community'; liveUpdate(); }
77 if($('#live-display').length) {
80 window.location.href=window.location.href
83 if($('#live-photos').length) {
86 window.location.href=window.location.href
91 $.get("ping",function(data) {
92 $(data).find('result').each(function() {
93 // send nav-update event
94 $('nav').trigger('nav-update', this);
98 timer = setTimeout(NavUpdate,30000);
101 function liveUpdate() {
102 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
103 if(($('.comment-edit-text-full').length) || (in_progress)) {
104 livetime = setTimeout(liveUpdate, 10000);
107 prev = 'live-' + src;
110 var udargs = ((netargs.length) ? '/' + netargs : '');
111 var update_url = 'update_' + src + udargs + '?p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
113 $.get(update_url,function(data) {
115 $('.ccollapse-wrapper',data).each(function() {
116 var ident = $(this).attr('id');
117 var is_hidden = $('#' + ident).is(':hidden');
118 if($('#' + ident).length) {
119 $('#' + ident).replaceWith($(this));
121 $('#' + ident).hide();
124 $('.wall-item-outside-wrapper',data).each(function() {
125 var ident = $(this).attr('id');
126 if($('#' + ident).length == 0) {
127 $('img',this).each(function() {
128 $(this).attr('src',$(this).attr('dst'));
130 $('#' + prev).after($(this));
134 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
135 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
136 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
137 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
138 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
139 $(this).attr('src',$(this).attr('dst'));
144 $('.like-rotator').hide();
147 $('body').css('cursor', 'auto');
152 function imgbright(node) {
153 $(node).removeClass("drophide").addClass("drop");
156 function imgdull(node) {
157 $(node).removeClass("drop").addClass("drophide");
160 // Since our ajax calls are asynchronous, we will give a few
161 // seconds for the first ajax call (setting like/dislike), then
162 // run the updater to pick up any changes and display on the page.
163 // The updater will turn any rotators off when it's done.
164 // This function will have returned long before any of these
165 // events have completed and therefore there won't be any
166 // visible feedback that anything changed without all this
167 // trickery. This still could cause confusion if the "like" ajax call
168 // is delayed and NavUpdate runs before it completes.
170 function dolike(ident,verb) {
171 $('#like-rotator-' + ident.toString()).show();
172 $.get('like/' + ident.toString() + '?verb=' + verb );
173 if(timer) clearTimeout(timer);
174 timer = setTimeout(NavUpdate,3000);
178 function dostar(ident) {
179 $('#like-rotator-' + ident.toString()).show();
180 $.get('starred/' + ident.toString(), function(data) {
181 if(data.match(/1/)) {
182 $('#starred-' + ident.toString()).addClass('starred');
183 $('#starred-' + ident.toString()).removeClass('unstarred');
186 $('#starred-' + ident.toString()).addClass('unstarred');
187 $('#starred-' + ident.toString()).removeClass('starred');
189 $('#like-rotator-' + ident.toString()).hide();
193 function getPosition(e) {
194 var cursor = {x:0, y:0};
195 if ( e.pageX || e.pageY ) {
200 if( e.clientX || e.clientY ) {
201 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
202 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
214 var lockvisible = false;
216 function lockview(event,id) {
217 event = event || window.event;
218 cursor = getPosition(event);
224 $.get('lockview/' + id, function(data) {
225 $('#panel').html(data);
226 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
232 function lockviewhide() {
237 function post_comment(id) {
239 $('body').css('cursor', 'wait');
242 $("#comment-edit-form-" + id).serialize(),
245 $("#comment-edit-wrapper-" + id).hide();
246 $("#comment-edit-text-" + id).val('');
247 var tarea = document.getElementById("comment-edit-text-" + id);
249 commentClose(tarea,id);
250 if(timer) clearTimeout(timer);
251 timer = setTimeout(NavUpdate,10);
254 window.location.href=data.reload;
264 // Converts the binary representation of data to hex
267 // discuss at: http://phpjs.org/functions/bin2hex
268 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
269 // + bugfixed by: Onno Marsman
270 // + bugfixed by: Linuxworld
271 // * example 1: bin2hex('Kev');
272 // * returns 1: '4b6576'
273 // * example 2: bin2hex(String.fromCharCode(0x00));
275 var v,i, f = 0, a = [];
279 for (i = 0; i<f; i++) {
280 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
286 function groupChangeMember(gid,cid) {
287 $('body .fakelink').css('cursor', 'wait');
288 $.get('group/' + gid + '/' + cid, function(data) {
289 $('#group-update-wrapper').html(data);
290 $('body .fakelink').css('cursor', 'auto');
294 function profChangeMember(gid,cid) {
295 $('body .fakelink').css('cursor', 'wait');
296 $.get('profperm/' + gid + '/' + cid, function(data) {
297 $('#prof-update-wrapper').html(data);
298 $('body .fakelink').css('cursor', 'auto');
302 function checkboxhighlight(box) {
303 if($(box).is(':checked')) {
304 $(box).addClass('checkeditem');
307 $(box).removeClass('checkeditem');
314 * sprintf in javascript
315 * "{0} and {1}".format('zero','uno');
317 String.prototype.format = function() {
318 var formatted = this;
319 for (var i = 0; i < arguments.length; i++) {
320 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
321 formatted = formatted.replace(regexp, arguments[i]);