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;
31 $(document).ready(function() {
32 $.ajaxSetup({cache: false});
34 msie = $.browser.msie ;
36 // Allow folks to stop the ajax page updates with the pause/break key
37 $(document).keypress(function(event) {
38 if(event.keyCode == '19') {
39 event.preventDefault();
40 if(stopped == false) {
42 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
49 // F8 - show/hide language selector
50 if(event.keyCode == '119') {
53 $('#language-selector').hide();
57 $('#language-selector').show();
61 // this is shift-home on FF, but $ on IE, disabling until I figure out why the diff.
62 // update: incompatible usage of onKeyDown vs onKeyPress
63 // if(event.keyCode == '36' && event.shiftKey == true) {
64 // if(homebase !== undefined) {
65 // event.preventDefault();
66 // document.location = homebase;
72 function NavUpdate() {
74 if($('#live-network').length) { src = 'network'; liveUpdate(); }
75 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
76 if($('#live-display').length) {
79 window.location.href=window.location.href
82 if($('#live-photos').length) {
85 window.location.href=window.location.href
90 $.get("ping",function(data) {
91 $(data).find('result').each(function() {
92 var net = $(this).find('net').text();
93 if(net == 0) { net = ''; }
94 $('#net-update').html(net);
95 var home = $(this).find('home').text();
96 if(home == 0) { home = ''; }
97 $('#home-update').html(home);
98 var mail = $(this).find('mail').text();
99 if(mail == 0) { mail = ''; }
100 $('#mail-update').html(mail);
101 var intro = $(this).find('intro').text();
102 var register = $(this).find('register').text();
103 if(intro == 0) { intro = ''; }
104 if(register != 0 && intro != '') { intro = intro+'/'+register; }
105 if(register != 0 && intro == '') { intro = '0/'+register; }
106 $('#notify-update').html(intro);
111 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();
160 function imgbright(node) {
161 $(node).attr("src",$(node).attr("src").replace('hide','show'));
162 $(node).css('width',24);
163 $(node).css('height',24);
166 function imgdull(node) {
167 $(node).attr("src",$(node).attr("src").replace('show','hide'));
168 $(node).css('width',16);
169 $(node).css('height',16);
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) {
237 $("#comment-edit-form-" + id).serialize(),
240 $("#comment-edit-wrapper-" + id).hide();
241 $("#comment-edit-text-" + id).val('');
242 var tarea = document.getElementById("comment-edit-text-" + id);
244 commentClose(tarea,id);
245 if(timer) clearTimeout(timer);
246 timer = setTimeout(NavUpdate,10);
249 window.location.href=data.reload;
260 // Converts the binary representation of data to hex
263 // discuss at: http://phpjs.org/functions/bin2hex
264 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
265 // + bugfixed by: Onno Marsman
266 // + bugfixed by: Linuxworld
267 // * example 1: bin2hex('Kev');
268 // * returns 1: '4b6576'
269 // * example 2: bin2hex(String.fromCharCode(0x00));
271 var v,i, f = 0, a = [];
275 for (i = 0; i<f; i++) {
276 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
282 function groupChangeMember(gid,cid) {
283 $('body .fakelink').css('cursor', 'wait');
284 $.get('group/' + gid + '/' + cid, function(data) {
285 $('#group-update-wrapper').html(data);
286 $('body .fakelink').css('cursor', 'auto');
290 function profChangeMember(gid,cid) {
291 $('body .fakelink').css('cursor', 'wait');
292 $.get('profperm/' + gid + '/' + cid, function(data) {
293 $('#prof-update-wrapper').html(data);
294 $('body .fakelink').css('cursor', 'auto');