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') );
75 if (menu.attr('popup')=="false") return false;
76 $(this).parent().toggleClass("selected");
83 /* notifications template */
84 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
85 var notifications_empty = unescape($("#nav-notifications-menu").html());
87 /* nav update event */
88 $('nav').bind('nav-update', function(e,data){;
89 var net = $(data).find('net').text();
90 if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
91 $('#net-update').html(net);
93 var home = $(data).find('home').text();
94 if(home == 0) { home = ''; $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
95 $('#home-update').html(home);
97 var eNotif = $(data).find('notif')
98 notif = eNotif.attr('count');
100 nnm = $("#nav-notifications-menu");
102 nnm.attr('popup','true');
103 eNotif.children("note").each(function(){
105 text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
106 html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'));
110 $("#nav-notifications-menu").html(notifications_empty);
112 if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
113 $('#notify-update').html(notif);
115 var eSysmsg = $(data).find('sysmsgs');
116 eSysmsg.children("notice").each(function(){
117 text = $(this).text();
118 $.jGrowl(text, { sticky: true, theme: 'notice' });
120 eSysmsg.children("info").each(function(){
121 text = $(this).text();
122 $.jGrowl(text, { sticky: false, theme: 'info' });
129 // Allow folks to stop the ajax page updates with the pause/break key
130 $(document).keypress(function(event) {
131 if(event.keyCode == '19') {
132 event.preventDefault();
133 if(stopped == false) {
135 $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
139 $('#pause').html('');
144 if(stopped == true) {
146 $('#pause').html('');
153 function NavUpdate() {
155 if($('#live-network').length) { src = 'network'; liveUpdate(); }
156 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
157 if($('#live-community').length) { src = 'community'; liveUpdate(); }
158 if($('#live-display').length) {
161 window.location.href=window.location.href
164 if($('#live-photos').length) {
167 window.location.href=window.location.href
172 $.get("ping",function(data) {
173 $(data).find('result').each(function() {
174 // send nav-update event
175 $('nav').trigger('nav-update', this);
179 timer = setTimeout(NavUpdate,30000);
182 function liveUpdate() {
183 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
184 if(($('.comment-edit-text-full').length) || (in_progress)) {
185 livetime = setTimeout(liveUpdate, 10000);
188 prev = 'live-' + src;
191 var udargs = ((netargs.length) ? '/' + netargs : '');
192 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
194 $.get(update_url,function(data) {
196 $('.ccollapse-wrapper',data).each(function() {
197 var ident = $(this).attr('id');
198 var is_hidden = $('#' + ident).is(':hidden');
199 if($('#' + ident).length) {
200 $('#' + ident).replaceWith($(this));
202 $('#' + ident).hide();
205 $('.wall-item-outside-wrapper',data).each(function() {
206 var ident = $(this).attr('id');
207 if($('#' + ident).length == 0) {
208 $('img',this).each(function() {
209 $(this).attr('src',$(this).attr('dst'));
211 $('#' + prev).after($(this));
215 $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
216 if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
217 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
218 $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
219 $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
220 $('#' + ident + ' ' + '.my-comment-photo').each(function() {
221 $(this).attr('src',$(this).attr('dst'));
226 $('.like-rotator').hide();
229 $('body').css('cursor', 'auto');
234 function imgbright(node) {
235 $(node).removeClass("drophide").addClass("drop");
238 function imgdull(node) {
239 $(node).removeClass("drop").addClass("drophide");
242 // Since our ajax calls are asynchronous, we will give a few
243 // seconds for the first ajax call (setting like/dislike), then
244 // run the updater to pick up any changes and display on the page.
245 // The updater will turn any rotators off when it's done.
246 // This function will have returned long before any of these
247 // events have completed and therefore there won't be any
248 // visible feedback that anything changed without all this
249 // trickery. This still could cause confusion if the "like" ajax call
250 // is delayed and NavUpdate runs before it completes.
252 function dolike(ident,verb) {
253 $('#like-rotator-' + ident.toString()).show();
254 $.get('like/' + ident.toString() + '?verb=' + verb );
255 if(timer) clearTimeout(timer);
256 timer = setTimeout(NavUpdate,3000);
260 function dostar(ident) {
261 $('#like-rotator-' + ident.toString()).show();
262 $.get('starred/' + ident.toString(), function(data) {
263 if(data.match(/1/)) {
264 $('#starred-' + ident.toString()).addClass('starred');
265 $('#starred-' + ident.toString()).removeClass('unstarred');
268 $('#starred-' + ident.toString()).addClass('unstarred');
269 $('#starred-' + ident.toString()).removeClass('starred');
271 $('#like-rotator-' + ident.toString()).hide();
275 function getPosition(e) {
276 var cursor = {x:0, y:0};
277 if ( e.pageX || e.pageY ) {
282 if( e.clientX || e.clientY ) {
283 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
284 cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
296 var lockvisible = false;
298 function lockview(event,id) {
299 event = event || window.event;
300 cursor = getPosition(event);
306 $.get('lockview/' + id, function(data) {
307 $('#panel').html(data);
308 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
314 function lockviewhide() {
319 function post_comment(id) {
321 $('body').css('cursor', 'wait');
324 $("#comment-edit-form-" + id).serialize(),
327 $("#comment-edit-wrapper-" + id).hide();
328 $("#comment-edit-text-" + id).val('');
329 var tarea = document.getElementById("comment-edit-text-" + id);
331 commentClose(tarea,id);
332 if(timer) clearTimeout(timer);
333 timer = setTimeout(NavUpdate,10);
336 window.location.href=data.reload;
346 // Converts the binary representation of data to hex
349 // discuss at: http://phpjs.org/functions/bin2hex
350 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
351 // + bugfixed by: Onno Marsman
352 // + bugfixed by: Linuxworld
353 // * example 1: bin2hex('Kev');
354 // * returns 1: '4b6576'
355 // * example 2: bin2hex(String.fromCharCode(0x00));
357 var v,i, f = 0, a = [];
361 for (i = 0; i<f; i++) {
362 a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
368 function groupChangeMember(gid,cid) {
369 $('body .fakelink').css('cursor', 'wait');
370 $.get('group/' + gid + '/' + cid, function(data) {
371 $('#group-update-wrapper').html(data);
372 $('body .fakelink').css('cursor', 'auto');
376 function profChangeMember(gid,cid) {
377 $('body .fakelink').css('cursor', 'wait');
378 $.get('profperm/' + gid + '/' + cid, function(data) {
379 $('#prof-update-wrapper').html(data);
380 $('body .fakelink').css('cursor', 'auto');
384 function contactgroupChangeMember(gid,cid) {
385 $('body').css('cursor', 'wait');
386 $.get('contactgroup/' + gid + '/' + cid, function(data) {
387 $('body').css('cursor', 'auto');
392 function checkboxhighlight(box) {
393 if($(box).is(':checked')) {
394 $(box).addClass('checkeditem');
397 $(box).removeClass('checkeditem');
401 function setupFieldRichtext(){
404 mode : "specific_textareas",
405 editor_selector: "fieldRichtext",
406 plugins : "bbcode,paste",
407 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
408 theme_advanced_buttons2 : "",
409 theme_advanced_buttons3 : "",
410 theme_advanced_toolbar_location : "top",
411 theme_advanced_toolbar_align : "center",
412 theme_advanced_blockformats : "blockquote,code",
413 paste_text_sticky : true,
414 entity_encoding : "raw",
415 add_unload_trigger : false,
416 remove_linebreaks : false,
417 force_p_newlines : false,
418 force_br_newlines : true,
419 forced_root_block : '',
421 content_css: baseurl+"/view/custom_tinymce.css",
422 theme_advanced_path : false,
427 * sprintf in javascript
428 * "{0} and {1}".format('zero','uno');
430 String.prototype.format = function() {
431 var formatted = this;
432 for (var i = 0; i < arguments.length; i++) {
433 var regexp = new RegExp('\\{'+i+'\\}', 'gi');
434 formatted = formatted.replace(regexp, arguments[i]);
439 Array.prototype.remove = function(item) {
440 to=undefined; from=this.indexOf(item);
441 var rest = this.slice((to || from) + 1 || this.length);
442 this.length = from < 0 ? this.length + from : from;
443 return this.push.apply(this, rest);