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 = ''; $('#net-update').hide() } else { $('#net-update').show() }
95 $('#net-update').html(net);
96 var home = $(this).find('home').text();
97 if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
98 $('#home-update').html(home);
99 var mail = $(this).find('mail').text();
100 if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
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 if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() }
108 $('#notify-update').html(intro);
113 timer = setTimeout(NavUpdate,30000);
116 function liveUpdate() {
117 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
118 if(($('.comment-edit-text-full').length) || (in_progress)) {
119 livetime = setTimeout(liveUpdate, 10000);
122 prev = 'live-' + src;
125 var udargs = ((netargs.length) ? '/' + netargs : '');
126 var update_url = 'update_' + src + udargs + '?p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
128 $.get(update_url,function(data) {
130 $('.ccollapse-wrapper',data).each(function() {
131 var ident = $(this).attr('id');
132 if($('#' + ident).length) {
133 $('#' + ident).replaceWith($(this));
136 $('.wall-item-outside-wrapper',data).each(function() {
137 var ident = $(this).attr('id');
138 if($('#' + ident).length == 0) {
139 $('img',this).each(function() {
140 $(this).attr('src',$(this).attr('dst'));
142 $('#' + prev).after($(this));
146 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
147 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
148 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
149 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
150 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
151 $(this).attr('src',$(this).attr('dst'));
156 $('.like-rotator').hide();
159 $('body').css('cursor', 'auto');
164 function imgbright(node) {
165 $(node).removeClass("drophide").addClass("drop");
168 function imgdull(node) {
169 $(node).removeClass("drop").addClass("drophide");
172 // Since our ajax calls are asynchronous, we will give a few
173 // seconds for the first ajax call (setting like/dislike), then
174 // run the updater to pick up any changes and display on the page.
175 // The updater will turn any rotators off when it's done.
176 // This function will have returned long before any of these
177 // events have completed and therefore there won't be any
178 // visible feedback that anything changed without all this
179 // trickery. This still could cause confusion if the "like" ajax call
180 // is delayed and NavUpdate runs before it completes.
182 function dolike(ident,verb) {
183 $('#like-rotator-' + ident.toString()).show();
184 $.get('like/' + ident.toString() + '?verb=' + verb );
185 if(timer) clearTimeout(timer);
186 timer = setTimeout(NavUpdate,3000);
190 function getPosition(e) {
191 var cursor = {x:0, y:0};
192 if ( e.pageX || e.pageY ) {
197 if( e.clientX || e.clientY ) {
198 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
199 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
211 var lockvisible = false;
213 function lockview(event,id) {
214 event = event || window.event;
215 cursor = getPosition(event);
221 $.get('lockview/' + id, function(data) {
222 $('#panel').html(data);
223 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
229 function lockviewhide() {
234 function post_comment(id) {
236 $('body').css('cursor', 'wait');
239 $("#comment-edit-form-" + id).serialize(),
242 $("#comment-edit-wrapper-" + id).hide();
243 $("#comment-edit-text-" + id).val('');
244 var tarea = document.getElementById("comment-edit-text-" + id);
246 commentClose(tarea,id);
247 if(timer) clearTimeout(timer);
248 timer = setTimeout(NavUpdate,10);
251 window.location.href=data.reload;
261 // Converts the binary representation of data to hex
264 // discuss at: http://phpjs.org/functions/bin2hex
265 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
266 // + bugfixed by: Onno Marsman
267 // + bugfixed by: Linuxworld
268 // * example 1: bin2hex('Kev');
269 // * returns 1: '4b6576'
270 // * example 2: bin2hex(String.fromCharCode(0x00));
272 var v,i, f = 0, a = [];
276 for (i = 0; i<f; i++) {
277 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
283 function groupChangeMember(gid,cid) {
284 $('body .fakelink').css('cursor', 'wait');
285 $.get('group/' + gid + '/' + cid, function(data) {
286 $('#group-update-wrapper').html(data);
287 $('body .fakelink').css('cursor', 'auto');
291 function profChangeMember(gid,cid) {
292 $('body .fakelink').css('cursor', 'wait');
293 $.get('profperm/' + gid + '/' + cid, function(data) {
294 $('#prof-update-wrapper').html(data);
295 $('body .fakelink').css('cursor', 'auto');