]> git.mxchange.org Git - friendica.git/blob - js/main.js
Don't replace data-src with src in acl-template
[friendica.git] / 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         $(function() {
37                 $.ajaxSetup({cache: false});
38
39                 msie = $.browser.msie ;
40                 
41                 /* setup tooltips *//*
42                 $("a,.tt").each(function(){
43                         var e = $(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                 $(".onoff input").each(function(){
56                         val = $(this).val();
57                         id = $(this).attr("id");
58                         $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
59                         
60                 });
61                 $(".onoff > a").click(function(event){
62                         event.preventDefault(); 
63                         var input = $(this).siblings("input");
64                         var val = 1-input.val();
65                         var id = input.attr("id");
66                         $("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
67                         $("#"+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() {
77                 if(last_popup_menu) {
78                 last_popup_menu.hide();
79                 last_popup_button.removeClass("selected");
80                 last_popup_menu = null;
81                 last_popup_button = null;
82                 }
83                 }
84                 $('a[rel^=#]').click(function(e){
85                         close_last_popup_menu();
86                         menu = $( $(this).attr('rel') );
87                         e.preventDefault();
88                         e.stopPropagation();
89                         if (menu.attr('popup')=="false") return false;
90                         $(this).parent().toggleClass("selected");
91                         menu.toggle();
92                         if (menu.css("display") == "none") {
93                                 last_popup_menu = null;
94                                 last_popup_button = null;
95                         } else {
96                                 last_popup_menu = menu;
97                                 last_popup_button = $(this).parent();
98                         }
99                         return false;
100                 });
101                 $('html').click(function() {
102                                                 close_last_popup_menu();
103                 });
104                 
105                 // fancyboxes
106                 $("a.popupbox").fancybox({
107                         'transitionIn' : 'elastic',
108                         'transitionOut' : 'elastic'
109                 });
110                 
111
112                 /* notifications template */
113                 var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
114                 var notifications_all = unescape($('<div>').append( $("#nav-notifications-see-all").clone() ).html()); //outerHtml hack
115                 var notifications_mark = unescape($('<div>').append( $("#nav-notifications-mark-all").clone() ).html()); //outerHtml hack
116                 var notifications_empty = unescape($("#nav-notifications-menu").html());
117                 
118                 /* nav update event  */
119                 $('nav').bind('nav-update', function(e,data){;
120                         var invalid = $(data).find('invalid').text();
121                         if(invalid == 1) { window.location.href=window.location.href }
122
123                         var net = $(data).find('net').text();
124                         if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
125                         $('#net-update').html(net);
126
127                         var home = $(data).find('home').text();
128                         if(home == 0) { home = '';  $('#home-update').removeClass('show') } else { $('#home-update').addClass('show') }
129                         $('#home-update').html(home);
130                         
131                         var intro = $(data).find('intro').text();
132                         if(intro == 0) { intro = '';  $('#intro-update').removeClass('show') } else { $('#intro-update').addClass('show') }
133                         $('#intro-update').html(intro);
134
135                         var mail = $(data).find('mail').text();
136                         if(mail == 0) { mail = '';  $('#mail-update').removeClass('show') } else { $('#mail-update').addClass('show') }
137                         $('#mail-update').html(mail);
138                         
139                         var intro = $(data).find('intro').text();
140                         if(intro == 0) { intro = '';  $('#intro-update-li').removeClass('show') } else { $('#intro-update-li').addClass('show') }
141                         $('#intro-update-li').html(intro);
142
143                         var mail = $(data).find('mail').text();
144                         if(mail == 0) { mail = '';  $('#mail-update-li').removeClass('show') } else { $('#mail-update-li').addClass('show') }
145                         $('#mail-update-li').html(mail);
146
147
148                         var allevents = $(data).find('all-events').text();
149                         if(allevents == 0) { allevents = ''; $('#allevents-update').removeClass('show') } else { $('#allevents-update').addClass('show') }
150                         $('#allevents-update').html(allevents);
151
152                         var alleventstoday = $(data).find('all-events-today').text();
153                         if(alleventstoday == 0) { $('#allevents-update').removeClass('notif-allevents-today') } else { $('#allevents-update').addClass('notif-allevents-today') }
154
155                         var events = $(data).find('events').text();
156                         if(events == 0) { events = ''; $('#events-update').removeClass('show') } else { $('#events-update').addClass('show') }
157                         $('#events-update').html(events);
158
159                         var eventstoday = $(data).find('events-today').text();
160                         if(eventstoday == 0) { $('#events-update').removeClass('notif-events-today') } else { $('#events-update').addClass('notif-events-today') }
161
162                         var birthdays = $(data).find('birthdays').text();
163                         if(birthdays == 0) {birthdays = ''; $('#birthdays-update').removeClass('show') } else { $('#birthdays-update').addClass('show') }
164                         $('#birthdays-update').html(birthdays);
165
166                         var birthdaystoday = $(data).find('birthdays-today').text();
167                         if(birthdaystoday == 0) { $('#birthdays-update').removeClass('notif-birthdays-today') } else { $('#birthdays-update').addClass('notif-birthdays-today') }
168
169
170                         var eNotif = $(data).find('notif')
171                         
172                         if (eNotif.children("note").length==0){
173                                 $("#nav-notifications-menu").html(notifications_empty);
174                         } else {
175                                 nnm = $("#nav-notifications-menu");
176                                 nnm.html(notifications_all + notifications_mark);
177                                 //nnm.attr('popup','true');
178                                 eNotif.children("note").each(function(){
179                                         e = $(this);
180                                         text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
181                                         html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen'));
182                                         nnm.append(html);
183                                 });
184
185                                 $("img[data-src]", nnm).each(function(i, el){
186                                         // Replace data-src attribute with src attribute for every image
187                                         $(el).attr('src', $(el).data("src"));
188                                         $(el).removeAttr("data-src");
189                                 });
190                         }
191
192                         notif = eNotif.attr('count');
193                         if (notif>0){
194                                 $("#nav-notifications-linkmenu").addClass("on");
195                         } else {
196                                 $("#nav-notifications-linkmenu").removeClass("on");
197                         }
198                         if(notif == 0) { notif = ''; $('#notify-update').removeClass('show') } else { $('#notify-update').addClass('show') }
199                         $('#notify-update').html(notif);
200                         
201                         var eSysmsg = $(data).find('sysmsgs');
202                         eSysmsg.children("notice").each(function(){
203                                 text = $(this).text();
204                                 $.jGrowl(text, { sticky: true, theme: 'notice' });
205                         });
206                         eSysmsg.children("info").each(function(){
207                                 text = $(this).text();
208                                 $.jGrowl(text, { sticky: false, theme: 'info', life: 10000 });
209                         });
210                         
211                 });
212
213                 NavUpdate(); 
214                 // Allow folks to stop the ajax page updates with the pause/break key
215                 $(document).keydown(function(event) {
216                         if(event.keyCode == '8') {
217                                 var target = event.target || event.srcElement;
218                                 if (!/input|textarea/i.test(target.nodeName)) {
219                                         return false;
220                                 }
221                         }
222                         if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
223                                 event.preventDefault();
224                                 if(stopped == false) {
225                                         stopped = true;
226                                         if (event.ctrlKey) {
227                                                 totStopped = true;
228                                         }
229                                         $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
230                                 } else {
231                                         unpause();
232                                 }
233                         } else {
234                                 if (!totStopped) {
235                                         unpause();
236                                 }
237                         }
238                 });
239                 
240                 
241         });
242
243         function NavUpdate() {
244
245                 if(! stopped) {
246                         var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
247                         $.get(pingCmd,function(data) {
248                                 $(data).find('result').each(function() {
249                                         // send nav-update event
250                                         $('nav').trigger('nav-update', this);
251                                         
252                                         
253                                         // start live update
254
255                                         if($('#live-network').length)   { src = 'network'; liveUpdate(); }
256                                         if($('#live-profile').length)   { src = 'profile'; liveUpdate(); }
257                                         if($('#live-community').length) { src = 'community'; liveUpdate(); }
258                                         if($('#live-notes').length)     { src = 'notes'; liveUpdate(); }
259                                         if($('#live-display').length)     { src = 'display'; liveUpdate(); }
260 /*                                      if($('#live-display').length) {
261                                                 if(liking) {
262                                                         liking = 0;
263                                                         window.location.href=window.location.href 
264                                                 }
265                                         }*/
266                                         if($('#live-photos').length) { 
267                                                 if(liking) {
268                                                         liking = 0;
269                                                         window.location.href=window.location.href 
270                                                 }
271                                         }
272
273                                         
274                                         
275                                         
276                                 });
277                         }) ;
278                 }
279                 timer = setTimeout(NavUpdate,updateInterval);
280         }
281
282         function liveUpdate() {
283                 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
284                 if(($('.comment-edit-text-full').length) || (in_progress)) {
285                         if(livetime) {
286                                 clearTimeout(livetime);
287                         }
288                         livetime = setTimeout(liveUpdate, 10000);
289                         return;
290                 }
291                 if(livetime != null)
292                         livetime = null;
293
294                 prev = 'live-' + src;
295
296                 in_progress = true;
297                 var udargs = ((netargs.length) ? '/' + netargs : '');
298                 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
299
300                 $.get(update_url,function(data) {
301                         in_progress = false;
302                         //                      $('.collapsed-comments',data).each(function() {
303                         //      var ident = $(this).attr('id');
304                         //      var is_hidden = $('#' + ident).is(':hidden');
305                         //      if($('#' + ident).length) {
306                         //              $('#' + ident).replaceWith($(this));
307                         //              if(is_hidden)
308                         //                      $('#' + ident).hide();
309                         //      }
310                         //});
311
312                         // add a new thread
313                         $('.toplevel_item',data).each(function() {
314                                 var ident = $(this).attr('id');
315
316                                 if($('#' + ident).length == 0 && profile_page == 1) {
317                                         $('img',this).each(function() {
318                                                 $(this).attr('src',$(this).attr('dst'));
319                                         });
320                                         $('#' + prev).after($(this));
321                                 }
322                                 else {
323                                         // Find out if the hidden comments are open, so we can keep it that way
324                                         // if a new comment has been posted
325                                         var id = $('.hide-comments-total', this).attr('id');
326                                         if(typeof id != 'undefined') {
327                                                 id = id.split('-')[3];
328                                                 var commentsOpen = $("#collapsed-comments-" + id).is(":visible");
329                                         }
330
331                                         $('img',this).each(function() {
332                                                 $(this).attr('src',$(this).attr('dst'));
333                                         });
334                                         //vScroll = $(document).scrollTop();
335                                         $('html').height($('html').height());
336                                         $('#' + ident).replaceWith($(this));
337
338                                         if(typeof id != 'undefined') {
339                                                 if(commentsOpen) showHideComments(id);
340                                         }
341                                         $('html').height('auto');
342                                         //$(document).scrollTop(vScroll);
343                                 }
344                                 prev = ident;
345                         });
346
347                         // reset vars for inserting individual items
348
349                         /*                      prev = 'live-' + src;
350
351                         $('.wall-item-outside-wrapper',data).each(function() {
352                                 var ident = $(this).attr('id');
353
354                                 if($('#' + ident).length == 0 && prev != 'live-' + src) {
355                                                 $('img',this).each(function() {
356                                                         $(this).attr('src',$(this).attr('dst'));
357                                                 });
358                                                 $('#' + prev).after($(this));
359                                 }
360                                 else { 
361                                         $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago')); 
362                                         if($('#' + ident + ' ' + '.comment-edit-text-empty').length)
363                                                 $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
364                                         $('#' + ident + ' ' + '.hide-comments-total').replaceWith($(this).find('.hide-comments-total'));
365                                         $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
366                                         $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
367                                         $('#' + ident + ' ' + '.my-comment-photo').each(function() {
368                                                 $(this).attr('src',$(this).attr('dst'));
369                                         });
370                                 }
371                                 prev = ident; 
372                         });
373                         */
374                         $('.like-rotator').hide();
375                         if(commentBusy) {
376                                 commentBusy = false;
377                                 $('body').css('cursor', 'auto');
378                         }
379                         /* autocomplete @nicknames */
380                         $(".comment-edit-form  textarea").contact_autocomplete(baseurl+"/acl");
381                 });
382         }
383
384         function imgbright(node) {
385                 $(node).removeClass("drophide").addClass("drop");
386         }
387
388         function imgdull(node) {
389                 $(node).removeClass("drop").addClass("drophide");
390         }
391
392         // Since our ajax calls are asynchronous, we will give a few 
393         // seconds for the first ajax call (setting like/dislike), then 
394         // run the updater to pick up any changes and display on the page.
395         // The updater will turn any rotators off when it's done. 
396         // This function will have returned long before any of these
397         // events have completed and therefore there won't be any
398         // visible feedback that anything changed without all this
399         // trickery. This still could cause confusion if the "like" ajax call
400         // is delayed and NavUpdate runs before it completes.
401
402         function dolike(ident,verb) {
403                 unpause();
404                 $('#like-rotator-' + ident.toString()).show();
405                 $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
406                 liking = 1;
407         }
408
409         function dosubthread(ident) {
410                 unpause();
411                 $('#like-rotator-' + ident.toString()).show();
412                 $.get('subthread/' + ident.toString(), NavUpdate );
413                 liking = 1;
414         }
415
416
417         function dostar(ident) {
418                 ident = ident.toString();
419                 $('#like-rotator-' + ident).show();
420                 $.get('starred/' + ident, function(data) {
421                         if(data.match(/1/)) {
422                                 $('#starred-' + ident).addClass('starred');
423                                 $('#starred-' + ident).removeClass('unstarred');
424                                 $('#star-' + ident).addClass('hidden');
425                                 $('#unstar-' + ident).removeClass('hidden');
426                         }
427                         else {                  
428                                 $('#starred-' + ident).addClass('unstarred');
429                                 $('#starred-' + ident).removeClass('starred');
430                                 $('#star-' + ident).removeClass('hidden');
431                                 $('#unstar-' + ident).addClass('hidden');
432                         }
433                         $('#like-rotator-' + ident).hide();     
434                 });
435         }
436
437         function getPosition(e) {
438                 var cursor = {x:0, y:0};
439                 if ( e.pageX || e.pageY  ) {
440                         cursor.x = e.pageX;
441                         cursor.y = e.pageY;
442                 }
443                 else {
444                         if( e.clientX || e.clientY ) {
445                                 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
446                                 cursor.y = e.clientY + (document.documentElement.scrollTop  || document.body.scrollTop)  - document.documentElement.clientTop;
447                         }
448                         else {
449                                 if( e.x || e.y ) {
450                                         cursor.x = e.x;
451                                         cursor.y = e.y;
452                                 }
453                         }
454                 }
455                 return cursor;
456         }
457
458         var lockvisible = false;
459
460         function lockview(event,id) {
461                 event = event || window.event;
462                 cursor = getPosition(event);
463                 if(lockvisible) {
464                         lockviewhide();
465                 }
466                 else {
467                         lockvisible = true;
468                         $.get('lockview/' + id, function(data) {
469                                 $('#panel').html(data);
470                                 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
471                                 $('#panel').show();
472                         });
473                 }
474         }
475
476         function lockviewhide() {
477                 lockvisible = false;
478                 $('#panel').hide();
479         }
480
481         function post_comment(id) {
482                 unpause();
483                 commentBusy = true;
484                 $('body').css('cursor', 'wait');
485                 $("#comment-preview-inp-" + id).val("0");
486                 $.post(  
487              "item",  
488              $("#comment-edit-form-" + id).serialize(),
489                         function(data) {
490                                 if(data.success) {
491                                         $("#comment-edit-wrapper-" + id).hide();
492                                         $("#comment-edit-text-" + id).val('');
493                                 var tarea = document.getElementById("comment-edit-text-" + id);
494                                         if(tarea)
495                                                 commentClose(tarea,id);
496                                         if(timer) clearTimeout(timer);
497                                         timer = setTimeout(NavUpdate,10);
498                                 }
499                                 if(data.reload) {
500                                         window.location.href=data.reload;
501                                 }
502                         },
503                         "json"  
504          );  
505          return false;  
506         }
507
508
509         function preview_comment(id) {
510                 $("#comment-preview-inp-" + id).val("1");
511                 $("#comment-edit-preview-" + id).show();
512                 $.post(  
513              "item",  
514              $("#comment-edit-form-" + id).serialize(),
515                         function(data) {
516                                 if(data.preview) {
517                                                 
518                                         $("#comment-edit-preview-" + id).html(data.preview);
519                                         $("#comment-edit-preview-" + id + " a").click(function() { return false; });
520                                 }
521                         },
522                         "json"  
523          );  
524          return true;  
525         }
526
527
528
529         function showHideComments(id) {
530                 if( $("#collapsed-comments-" + id).is(":visible")) {
531                         $("#collapsed-comments-" + id).hide();
532                         $("#hide-comments-" + id).html(window.showMore);
533                 }
534                 else {
535                         $("#collapsed-comments-" + id).show();
536                         $("#hide-comments-" + id).html(window.showFewer);
537                 }
538         }
539
540
541
542         function preview_post() {
543                 $("#jot-preview").val("1");
544                 $("#jot-preview-content").show();
545                 tinyMCE.triggerSave();
546                 $.post(  
547                         "item",  
548                         $("#profile-jot-form").serialize(),
549                         function(data) {
550                                 if(data.preview) {                      
551                                         $("#jot-preview-content").html(data.preview);
552                                         $("#jot-preview-content" + " a").click(function() { return false; });
553                                 }
554                         },
555                         "json"  
556                 );  
557                 $("#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             $('#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                 $('body .fakelink').css('cursor', 'wait');
595                 $.get('group/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
596                                 $('#group-update-wrapper').html(data);
597                                 $('body .fakelink').css('cursor', 'auto');                              
598                 });
599         }
600
601         function profChangeMember(gid,cid) {
602                 $('body .fakelink').css('cursor', 'wait');
603                 $.get('profperm/' + gid + '/' + cid, function(data) {
604                                 $('#prof-update-wrapper').html(data);
605                                 $('body .fakelink').css('cursor', 'auto');                              
606                 });
607         }
608
609         function contactgroupChangeMember(gid,cid) {
610                 $('body').css('cursor', 'wait');
611                 $.get('contactgroup/' + gid + '/' + cid, function(data) {
612                                 $('body').css('cursor', 'auto');
613                 });
614         }
615
616
617 function checkboxhighlight(box) {
618   if($(box).is(':checked')) {
619         $(box).addClass('checkeditem');
620   }
621   else {
622         $(box).removeClass('checkeditem');
623   }
624 }
625
626 function notifyMarkAll() {
627         $.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 = $(elm).val();
707         $.getJSON('pretheme?f=&theme=' + theme,function(data) {
708                         $('#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 }