]> git.mxchange.org Git - friendica.git/blob - view/theme/frost-mobile/js/main.js
c13cbef13c208e8e226e6da11f69218b443be997
[friendica.git] / view / theme / frost-mobile / js / main.js
1
2   function openClose(theID) {
3     if(document.getElementById(theID).style.display == "block") { 
4       document.getElementById(theID).style.display = "none" 
5     }
6     else { 
7       document.getElementById(theID).style.display = "block" 
8     } 
9   }
10
11   function openMenu(theID) {
12       document.getElementById(theID).style.display = "block" 
13   }
14
15   function closeMenu(theID) {
16       document.getElementById(theID).style.display = "none" 
17   }
18
19
20
21         var src = null;
22         var prev = null;
23         var livetime = null;
24         var msie = false;
25         var stopped = false;
26         var totStopped = false;
27         var timer = null;
28         var pr = 0;
29         var liking = 0;
30         var in_progress = false;
31         var langSelect = false;
32         var commentBusy = false;
33         var last_popup_menu = null;
34         var last_popup_button = null;
35
36         $j(function() {
37                 $j.ajaxSetup({cache: false});
38
39                 msie = $j.browser.msie ;
40                 
41                 /* setup tooltips *//*
42                 $j("a,.tt").each(function(){
43                         var e = $j(this);
44                         var pos="bottom";
45                         if (e.hasClass("tttop")) pos="top";
46                         if (e.hasClass("ttbottom")) pos="bottom";
47                         if (e.hasClass("ttleft")) pos="left";
48                         if (e.hasClass("ttright")) pos="right";
49                         e.tipTip({defaultPosition: pos, edgeOffset: 8});
50                 });*/
51                 
52                 
53                 
54                 /* setup onoff widgets */
55                 $j(".onoff input").each(function(){
56                         val = $j(this).val();
57                         id = $j(this).attr("id");
58                         $j("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
59                         
60                 });
61                 $j(".onoff > a").click(function(event){
62                         event.preventDefault(); 
63                         var input = $j(this).siblings("input");
64                         var val = 1-input.val();
65                         var id = input.attr("id");
66                         $j("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
67                         $j("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
68                         input.val(val);
69                         //console.log(id);
70                 });
71                 
72                 /* setup field_richtext */
73                 /*setupFieldRichtext();*/
74
75                 /* popup menus */
76                 function close_last_popup_menu(e) {
77
78                         if( last_popup_menu ) {
79                                 if( '#' + last_popup_menu.attr('id') !== $j(e.target).attr('rel')) {
80                                         last_popup_menu.hide();
81                                         if (last_popup_menu.attr('id') == "nav-notifications-menu" ) $j('section').show();
82                                         last_popup_button.removeClass("selected");
83                                         last_popup_menu = null;
84                                         last_popup_button = null;
85                                 }
86                         }
87                 }
88                 $j('img[rel^=#]').click(function(e){
89
90                         close_last_popup_menu(e);
91                         menu = $j( $j(this).attr('rel') );
92                         e.preventDefault();
93                         e.stopPropagation();
94
95                         if (menu.attr('popup')=="false") return false;
96
97 //                      $j(this).parent().toggleClass("selected");
98 //                      menu.toggle();
99
100                         if (menu.css("display") == "none") {
101                                 $j(this).parent().addClass("selected");
102                                 menu.show();
103                                 if (menu.attr('id') == "nav-notifications-menu" ) $j('section').hide();
104                                 last_popup_menu = menu;
105                                 last_popup_button = $j(this).parent();
106                         } else {
107                                 $j(this).parent().removeClass("selected");
108                                 menu.hide();
109                                 if (menu.attr('id') == "nav-notifications-menu" ) $j('section').show();
110                                 last_popup_menu = null;
111                                 last_popup_button = null;
112                         }
113                         return false;
114                 });
115                 $j('html').click(function(e) {
116                         close_last_popup_menu(e);
117                 });
118                 
119                 // fancyboxes
120                 /*$j("a.popupbox").fancybox({
121                         'transitionIn' : 'elastic',
122                         'transitionOut' : 'elastic'
123                 });*/
124                 
125
126                 /* notifications template */
127                 var notifications_tpl= unescape($j("#nav-notifications-template[rel=template]").html());
128                 var notifications_all = unescape($j('<div>').append( $j("#nav-notifications-see-all").clone() ).html()); //outerHtml hack
129                 var notifications_mark = unescape($j('<div>').append( $j("#nav-notifications-mark-all").clone() ).html()); //outerHtml hack
130                 var notifications_empty = unescape($j("#nav-notifications-menu").html());
131                 
132                 /* nav update event  */
133                 $j('nav').bind('nav-update', function(e,data){;
134                         var invalid = $j(data).find('invalid').text();
135                         if(invalid == 1) { window.location.href=window.location.href }
136
137                         var net = $j(data).find('net').text();
138                         if(net == 0) { net = ''; $j('#net-update').removeClass('show') } else { $j('#net-update').addClass('show') }
139                         $j('#net-update').html(net);
140
141                         var home = $j(data).find('home').text();
142                         if(home == 0) { home = '';  $j('#home-update').removeClass('show') } else { $j('#home-update').addClass('show') }
143                         $j('#home-update').html(home);
144                         
145                         var intro = $j(data).find('intro').text();
146                         if(intro == 0) { intro = '';  $j('#intro-update').removeClass('show') } else { $j('#intro-update').addClass('show') }
147                         $j('#intro-update').html(intro);
148
149                         var mail = $j(data).find('mail').text();
150                         if(mail == 0) { mail = '';  $j('#mail-update').removeClass('show') } else { $j('#mail-update').addClass('show') }
151                         $j('#mail-update').html(mail);
152                         
153                         var intro = $j(data).find('intro').text();
154                         if(intro == 0) { intro = '';  $j('#intro-update-li').removeClass('show') } else { $j('#intro-update-li').addClass('show') }
155                         $j('#intro-update-li').html(intro);
156
157                         var mail = $j(data).find('mail').text();
158                         if(mail == 0) { mail = '';  $j('#mail-update-li').removeClass('show') } else { $j('#mail-update-li').addClass('show') }
159                         $j('#mail-update-li').html(mail);
160
161                         var eNotif = $j(data).find('notif')
162                         
163                         if (eNotif.children("note").length==0){
164                                 $j("#nav-notifications-menu").html(notifications_empty);
165                         } else {
166                                 nnm = $j("#nav-notifications-menu");
167                                 nnm.html(notifications_all + notifications_mark);
168                                 //nnm.attr('popup','true');
169                                 eNotif.children("note").each(function(){
170                                         e = $j(this);
171                                         text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
172                                         html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen'));
173                                         nnm.append(html);
174                                 });
175                         }
176                         notif = eNotif.attr('count');
177                         if (notif>0){
178                                 $j("#nav-notifications-linkmenu").addClass("on");
179                         } else {
180                                 $j("#nav-notifications-linkmenu").removeClass("on");
181                         }
182                         if(notif == 0) { notif = ''; $j('#notify-update').removeClass('show') } else { $j('#notify-update').addClass('show') }
183                         $j('#notify-update').html(notif);
184                         
185                         var eSysmsg = $j(data).find('sysmsgs');
186                         eSysmsg.children("notice").each(function(){
187                                 text = $j(this).text();
188                                 $j.jGrowl(text, { sticky: false, theme: 'notice', life: 1500 });
189                         });
190                         eSysmsg.children("info").each(function(){
191                                 text = $j(this).text();
192                                 $j.jGrowl(text, { sticky: false, theme: 'info', life: 1000 });
193                         });
194                         
195                 });
196                 
197                 
198                 NavUpdate(); 
199                 // Allow folks to stop the ajax page updates with the pause/break key
200 /*              $j(document).keydown(function(event) {
201                         if(event.keyCode == '8') {
202                                 var target = event.target || event.srcElement;
203                                 if (!/input|textarea/i.test(target.nodeName)) {
204                                         return false;
205                                 }
206                         }
207                         if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
208                                 event.preventDefault();
209                                 if(stopped == false) {
210                                         stopped = true;
211                                         if (event.ctrlKey) {
212                                                 totStopped = true;
213                                         }
214                                         $j('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
215                                 } else {
216                                         unpause();
217                                 }
218                         } else {
219                                 if (!totStopped) {
220                                         unpause();
221                                 }
222                         }
223                 });*/
224                 
225                 
226         });
227
228         function NavUpdate() {
229
230                 if(! stopped) {
231                         var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
232                         $j.get(pingCmd,function(data) {
233                                 $j(data).find('result').each(function() {
234                                         // send nav-update event
235                                         $j('nav').trigger('nav-update', this);
236                                         
237                                         
238                                         // start live update
239
240                                         
241
242                                         if($j('#live-network').length)   { src = 'network'; liveUpdate(); }
243                                         if($j('#live-profile').length)   { src = 'profile'; liveUpdate(); }
244                                         if($j('#live-community').length) { src = 'community'; liveUpdate(); }
245                                         if($j('#live-notes').length)     { src = 'notes'; liveUpdate(); }
246                                         if($j('#live-display').length) {
247                                                 if(liking) {
248                                                         liking = 0;
249                                                         window.location.href=window.location.href 
250                                                 }
251                                         }
252                                         if($j('#live-photos').length) {
253                                                 if(liking) {
254                                                         liking = 0;
255                                                         window.location.href=window.location.href 
256                                                 }
257                                         }
258
259                                         
260                                         
261                                         
262                                 });
263                         }) ;
264                 }
265                 timer = setTimeout(NavUpdate,updateInterval);
266         }
267
268         function liveUpdate() {
269                 if((src == null) || (stopped) || (! profile_uid)) { $j('.like-rotator').hide(); return; }
270                 if(($j('.comment-edit-text-full').length) || (in_progress)) {
271                         if(livetime) {
272                                 clearTimeout(livetime);
273                         }
274                         livetime = setTimeout(liveUpdate, 10000);
275                         return;
276                 }
277                 if(livetime != null)
278                         livetime = null;
279
280                 prev = 'live-' + src;
281
282                 in_progress = true;
283                 var udargs = ((netargs.length) ? '/' + netargs : '');
284                 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
285
286                 $j.get(update_url,function(data) {
287                         in_progress = false;
288                         //                      $j('.collapsed-comments',data).each(function() {
289                         //      var ident = $j(this).attr('id');
290                         //      var is_hidden = $j('#' + ident).is(':hidden');
291                         //      if($j('#' + ident).length) {
292                         //              $j('#' + ident).replaceWith($j(this));
293                         //              if(is_hidden)
294                         //                      $j('#' + ident).hide();
295                         //      }
296                         //});
297
298                         // add a new thread
299
300                         $j('.toplevel_item',data).each(function() {
301                                 var ident = $j(this).attr('id');
302
303                                 if($j('#' + ident).length == 0 && profile_page == 1) {
304                                         $j('img',this).each(function() {
305                                                 $j(this).attr('src',$j(this).attr('dst'));
306                                         });
307                                         $j('#' + prev).after($j(this));
308                                 }
309                                 else {
310                                         $j('img',this).each(function() {
311                                                 $j(this).attr('src',$j(this).attr('dst'));
312                                         });
313                                         $j('#' + ident).replaceWith($j(this));
314                                 }
315                                 prev = ident;
316                         });
317
318                         // reset vars for inserting individual items
319
320                         /*prev = 'live-' + src;
321
322                         $j('.wall-item-outside-wrapper',data).each(function() {
323                                 var ident = $j(this).attr('id');
324
325                                 if($j('#' + ident).length == 0 && prev != 'live-' + src) {
326                                                 $j('img',this).each(function() {
327                                                         $j(this).attr('src',$j(this).attr('dst'));
328                                                 });
329                                                 $j('#' + prev).after($j(this));
330                                 }
331                                 else { 
332                                         $j('#' + ident + ' ' + '.wall-item-ago').replaceWith($j(this).find('.wall-item-ago')); 
333                                         if($j('#' + ident + ' ' + '.comment-edit-text-empty').length)
334                                                 $j('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($j(this).find('.wall-item-comment-wrapper'));
335                                         $j('#' + ident + ' ' + '.hide-comments-total').replaceWith($j(this).find('.hide-comments-total'));
336                                         $j('#' + ident + ' ' + '.wall-item-like').replaceWith($j(this).find('.wall-item-like'));
337                                         $j('#' + ident + ' ' + '.wall-item-dislike').replaceWith($j(this).find('.wall-item-dislike'));
338                                         $j('#' + ident + ' ' + '.my-comment-photo').each(function() {
339                                                 $j(this).attr('src',$j(this).attr('dst'));
340                                         });
341                                 }
342                                 prev = ident; 
343                         });*/
344                         
345                         $j('.like-rotator').hide();
346                         if(commentBusy) {
347                                 commentBusy = false;
348                                 $j('body').css('cursor', 'auto');
349                         }
350                         /* autocomplete @nicknames */
351                         $j(".comment-edit-form  textarea").contact_autocomplete(baseurl+"/acl");
352
353                         /*var bimgs = $j(".wall-item-body > img").not(function() { return this.complete; });
354                         var bimgcount = bimgs.length;
355
356                         if (bimgcount) {
357                                 bimgs.load(function() {
358                                         bimgcount--;
359                                         if (! bimgcount) {
360                                                 collapseHeight();
361
362                                         }
363                                 });
364                         } else {
365                                 collapseHeight();
366                         }*/
367
368                 });
369         }
370
371 /*      function collapseHeight() {
372                 $j(".wall-item-body").each(function() {
373                                 if($j(this).height() > 310) {
374                                 if(! $j(this).hasClass('divmore')) {
375                                         $j(this).divgrow({ initialHeight: 300, showBrackets: false, speed: 0 });
376                                         $j(this).addClass('divmore');
377                                 }
378                         }                                       
379                 });
380         }*/
381
382         function imgbright(node) {
383                 $j(node).removeClass("drophide").addClass("drop");
384         }
385
386         function imgdull(node) {
387                 $j(node).removeClass("drop").addClass("drophide");
388         }
389
390         // Since our ajax calls are asynchronous, we will give a few 
391         // seconds for the first ajax call (setting like/dislike), then 
392         // run the updater to pick up any changes and display on the page.
393         // The updater will turn any rotators off when it's done. 
394         // This function will have returned long before any of these
395         // events have completed and therefore there won't be any
396         // visible feedback that anything changed without all this
397         // trickery. This still could cause confusion if the "like" ajax call
398         // is delayed and NavUpdate runs before it completes.
399
400         function dolike(ident,verb) {
401                 unpause();
402                 $j('#like-rotator-' + ident.toString()).show();
403                 $j.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
404 //              if(timer) clearTimeout(timer);
405 //              timer = setTimeout(NavUpdate,3000);
406                 liking = 1;
407         }
408
409         function dostar(ident) {
410                 ident = ident.toString();
411                 //$j('#like-rotator-' + ident).show();
412                 $j.get('starred/' + ident, function(data) {
413                         if(data.match(/1/)) {
414                                 $j('#starred-' + ident).addClass('starred');
415                                 $j('#starred-' + ident).removeClass('unstarred');
416                                 $j('#star-' + ident).addClass('hidden');
417                                 $j('#unstar-' + ident).removeClass('hidden');
418                         }
419                         else {                  
420                                 $j('#starred-' + ident).addClass('unstarred');
421                                 $j('#starred-' + ident).removeClass('starred');
422                                 $j('#star-' + ident).removeClass('hidden');
423                                 $j('#unstar-' + ident).addClass('hidden');
424                         }
425                         //$j('#like-rotator-' + ident).hide();  
426                 });
427         }
428
429         function getPosition(e) {
430                 var cursor = {x:0, y:0};
431                 if ( e.touches[0].pageX || e.touches[0].pageY  ) {
432                         cursor.x = e.touches[0].pageX;
433                         cursor.y = e.touches[0].pageY;
434                 }
435                 else {
436                         if( e.touches[0].clientX || e.touches[0].clientY ) {
437                                 cursor.x = e.touches[0].clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
438                                 cursor.y = e.touches[0].clientY + (document.documentElement.scrollTop  || document.body.scrollTop)  - document.documentElement.clientTop;
439                         }
440                         else {
441                                 if( e.touches[0].x || e.touches[0].y ) {
442                                         cursor.touches[0].x = e.touches[0].x;
443                                         cursor.touches[0].y = e.touches[0].y;
444                                 }
445                         }
446                 }
447                 return cursor;
448         }
449
450         var lockvisible = false;
451
452         function lockview(event,id) {
453                 event = event || window.event;
454                 cursor = getPosition(event);
455                 if(lockvisible) {
456                         lockviewhide();
457                 }
458                 else {
459                         lockvisible = true;
460                         $j.get('lockview/' + id, function(data) {
461                                 $j('#panel').html(data);
462                                 $j('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
463                                 $j('#panel').show();
464                         });
465                 }
466         }
467
468         function lockviewhide() {
469                 lockvisible = false;
470                 $j('#panel').hide();
471         }
472
473         function post_comment(id) {
474                 unpause();
475                 commentBusy = true;
476                 $j('body').css('cursor', 'wait');
477                 $j("#comment-preview-inp-" + id).val("0");
478                 $j.post(  
479              "item",  
480              $j("#comment-edit-form-" + id).serialize(),
481                         function(data) {
482                                 if(data.success) {
483                                         $j("#comment-edit-wrapper-" + id).hide();
484                                         $j("#comment-edit-text-" + id).val('');
485                                 var tarea = document.getElementById("comment-edit-text-" + id);
486                                         if(tarea)
487                                                 commentClose(tarea,id);
488                                         if(timer) clearTimeout(timer);
489                                         timer = setTimeout(NavUpdate,10);
490                                 }
491                                 if(data.reload) {
492                                         window.location.href=data.reload;
493                                 }
494                         },
495                         "json"  
496          );  
497          return false;  
498         }
499
500
501         function preview_comment(id) {
502                 $j("#comment-preview-inp-" + id).val("1");
503                 $j("#comment-edit-preview-" + id).show();
504                 $j.post(  
505              "item",  
506              $j("#comment-edit-form-" + id).serialize(),
507                         function(data) {
508                                 if(data.preview) {
509                                                 
510                                         $j("#comment-edit-preview-" + id).html(data.preview);
511                                         $j("#comment-edit-preview-" + id + " a").click(function() { return false; });
512                                 }
513                         },
514                         "json"  
515          );  
516          return true;  
517         }
518
519
520
521         function preview_post() {
522                 $j("#jot-preview").val("1");
523                 $j("#jot-preview-content").show();
524                 tinyMCE.triggerSave();
525                 $j.post(  
526                         "item",  
527                         $j("#profile-jot-form").serialize(),
528                         function(data) {
529                                 if(data.preview) {                      
530                                         $j("#jot-preview-content").html(data.preview);
531                                         $j("#jot-preview-content" + " a").click(function() { return false; });
532                                 }
533                         },
534                         "json"  
535                 );  
536                 $j("#jot-preview").val("0");
537                 return true;  
538         }
539
540
541         function unpause() {
542                 // unpause auto reloads if they are currently stopped
543                 totStopped = false;
544                 stopped = false;
545             $j('#pause').html('');
546         }
547                 
548
549     function bin2hex(s){  
550         // Converts the binary representation of data to hex    
551         //   
552         // version: 812.316  
553         // discuss at: http://phpjs.org/functions/bin2hex  
554         // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
555         // +   bugfixed by: Onno Marsman  
556         // +   bugfixed by: Linuxworld  
557         // *     example 1: bin2hex('Kev');  
558         // *     returns 1: '4b6576'  
559         // *     example 2: bin2hex(String.fromCharCode(0x00));  
560         // *     returns 2: '00'  
561         var v,i, f = 0, a = [];  
562         s += '';  
563         f = s.length;  
564           
565         for (i = 0; i<f; i++) {  
566             a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");  
567         }  
568           
569         return a.join('');  
570     }  
571
572         function groupChangeMember(gid, cid, sec_token) {
573                 $j('body .fakelink').css('cursor', 'wait');
574                 $j.get('group/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
575                                 $j('#group-update-wrapper').html(data);
576                                 $j('body .fakelink').css('cursor', 'auto');                             
577                 });
578         }
579
580         function profChangeMember(gid,cid) {
581                 $j('body .fakelink').css('cursor', 'wait');
582                 $j.get('profperm/' + gid + '/' + cid, function(data) {
583                                 $j('#prof-update-wrapper').html(data);
584                                 $j('body .fakelink').css('cursor', 'auto');                             
585                 });
586         }
587
588         function contactgroupChangeMember(gid,cid) {
589                 $j('body').css('cursor', 'wait');
590                 $j.get('contactgroup/' + gid + '/' + cid, function(data) {
591                                 $j('body').css('cursor', 'auto');
592                 });
593         }
594
595
596 function checkboxhighlight(box) {
597   if($j(box).is(':checked')) {
598         $j(box).addClass('checkeditem');
599   }
600   else {
601         $j(box).removeClass('checkeditem');
602   }
603 }
604
605 function notifyMarkAll() {
606         $j.get('notify/mark/all', function(data) {
607                 if(timer) clearTimeout(timer);
608                 timer = setTimeout(NavUpdate,1000);
609         });
610 }
611
612
613 // code from http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser
614 function fcFileBrowser (field_name, url, type, win) {
615     /* TODO: If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
616        the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
617        These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */
618
619
620     var cmsURL = baseurl+"/fbrowser/"+type+"/";
621
622     tinyMCE.activeEditor.windowManager.open({
623         file : cmsURL,
624         title : 'File Browser',
625         width : 420,  // Your dimensions may differ - toy around with them!
626         height : 400,
627         resizable : "yes",
628         inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
629         close_previous : "no"
630     }, {
631         window : win,
632         input : field_name
633     });
634     return false;
635   }
636
637 function setupFieldRichtext(){
638         tinyMCE.init({
639                 theme : "advanced",
640                 mode : "specific_textareas",
641                 editor_selector: "fieldRichtext",
642                 plugins : "bbcode,paste, inlinepopups",
643                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
644                 theme_advanced_buttons2 : "",
645                 theme_advanced_buttons3 : "",
646                 theme_advanced_toolbar_location : "top",
647                 theme_advanced_toolbar_align : "center",
648                 theme_advanced_blockformats : "blockquote,code",
649                 paste_text_sticky : true,
650                 entity_encoding : "raw",
651                 add_unload_trigger : false,
652                 remove_linebreaks : false,
653                 force_p_newlines : false,
654                 force_br_newlines : true,
655                 forced_root_block : '',
656                 convert_urls: false,
657                 content_css: baseurl+"/view/custom_tinymce.css",
658                 theme_advanced_path : false,
659                 file_browser_callback : "fcFileBrowser",
660         });
661 }
662
663
664 /** 
665  * sprintf in javascript 
666  *      "{0} and {1}".format('zero','uno'); 
667  **/
668 String.prototype.format = function() {
669     var formatted = this;
670     for (var i = 0; i < arguments.length; i++) {
671         var regexp = new RegExp('\\{'+i+'\\}', 'gi');
672         formatted = formatted.replace(regexp, arguments[i]);
673     }
674     return formatted;
675 };
676 // Array Remove
677 Array.prototype.remove = function(item) {
678   to=undefined; from=this.indexOf(item);
679   var rest = this.slice((to || from) + 1 || this.length);
680   this.length = from < 0 ? this.length + from : from;
681   return this.push.apply(this, rest);
682 };
683
684 function previewTheme(elm) {
685         theme = $j(elm).val();
686         $j.getJSON('pretheme?f=&theme=' + theme,function(data) {
687                         $j('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
688         });
689
690 }