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