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;
32 $(document).ready(function() {
33 $.ajaxSetup({cache: false});
35 msie = $.browser.msie ;
37 // Allow folks to stop the ajax page updates with the pause/break key
38 $(document).keypress(function(event) {
39 if(event.keyCode == '19') {
40 event.preventDefault();
41 if(stopped == false) {
43 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
50 // F8 - show/hide language selector
51 if(event.keyCode == '119') {
54 $('#language-selector').hide();
58 $('#language-selector').show();
62 // this is shift-home on FF, but $ on IE, disabling until I figure out why the diff.
63 // update: incompatible usage of onKeyDown vs onKeyPress
64 // if(event.keyCode == '36' && event.shiftKey == true) {
65 // if(homebase !== undefined) {
66 // event.preventDefault();
67 // document.location = homebase;
73 function NavUpdate() {
75 if($('#live-network').length) { src = 'network'; liveUpdate(); }
76 if($('#live-profile').length) { src = 'profile'; 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 var net = $(this).find('net').text();
94 if(net == 0) { net = ''; }
95 $('#net-update').html(net);
96 var home = $(this).find('home').text();
97 if(home == 0) { home = ''; }
98 $('#home-update').html(home);
99 var mail = $(this).find('mail').text();
100 if(mail == 0) { mail = ''; }
101 $('#mail-update').html(mail);
102 var intro = $(this).find('intro').text();
103 var register = $(this).find('register').text();
104 if(intro == 0) { intro = ''; }
105 if(register != 0 && intro != '') { intro = intro+'/'+register; }
106 if(register != 0 && intro == '') { intro = '0/'+register; }
107 $('#notify-update').html(intro);
112 timer = setTimeout(NavUpdate,30000);
115 function liveUpdate() {
116 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
117 if(($('.comment-edit-text-full').length) || (in_progress)) {
118 livetime = setTimeout(liveUpdate, 10000);
121 prev = 'live-' + src;
124 var udargs = ((netargs.length) ? '/' + netargs : '');
125 var update_url = 'update_' + src + udargs + '?p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
127 $.get(update_url,function(data) {
129 $('.ccollapse-wrapper',data).each(function() {
130 var ident = $(this).attr('id');
131 if($('#' + ident).length) {
132 $('#' + ident).replaceWith($(this));
135 $('.wall-item-outside-wrapper',data).each(function() {
136 var ident = $(this).attr('id');
137 if($('#' + ident).length == 0) {
138 $('img',this).each(function() {
139 $(this).attr('src',$(this).attr('dst'));
141 $('#' + prev).after($(this));
145 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
146 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
147 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
148 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
149 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
150 $(this).attr('src',$(this).attr('dst'));
155 $('.like-rotator').hide();
158 $('body').css('cursor', 'auto');
163 function imgbright(node) {
164 $(node).attr("src",$(node).attr("src").replace('hide','show'));
165 $(node).css('width',24);
166 $(node).css('height',24);
169 function imgdull(node) {
170 $(node).attr("src",$(node).attr("src").replace('show','hide'));
171 $(node).css('width',16);
172 $(node).css('height',16);
175 // Since our ajax calls are asynchronous, we will give a few
176 // seconds for the first ajax call (setting like/dislike), then
177 // run the updater to pick up any changes and display on the page.
178 // The updater will turn any rotators off when it's done.
179 // This function will have returned long before any of these
180 // events have completed and therefore there won't be any
181 // visible feedback that anything changed without all this
182 // trickery. This still could cause confusion if the "like" ajax call
183 // is delayed and NavUpdate runs before it completes.
185 function dolike(ident,verb) {
186 $('#like-rotator-' + ident.toString()).show();
187 $.get('like/' + ident.toString() + '?verb=' + verb );
188 if(timer) clearTimeout(timer);
189 timer = setTimeout(NavUpdate,3000);
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');