1 $(document).ready(function() {
3 window.navMenuTimeout = {
4 '#network-menu-list-timeout': null,
5 '#contacts-menu-list-timeout': null,
6 '#system-menu-list-timeout': null,
7 '#network-menu-list-opening': false,
8 '#contacts-menu-list-opening': false,
9 '#system-menu-list-opening': false,
10 '#network-menu-list-closing': false,
11 '#contacts-menu-list-closing': false,
12 '#system-menu-list-closing': false
20 /* enable tinymce on focus and click */
21 $("#profile-jot-text").focus(enableOnUser);
22 $("#profile-jot-text").click(enableOnUser);
24 $('.nav-menu-list, .nav-menu-icon').hover(function() {
25 showNavMenu($(this).attr('point'));
27 hideNavMenu($(this).attr('point'));
30 /* $('html').click(function() { $("#nav-notifications-menu" ).hide(); });*/
32 $('.group-edit-icon').hover(
34 $(this).addClass('icon'); $(this).removeClass('iconspacer');},
36 $(this).removeClass('icon'); $(this).addClass('iconspacer');}
39 $('.sidebar-group-element').hover(
41 id = $(this).attr('id');
42 $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
45 id = $(this).attr('id');
46 $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
50 $('.savedsearchdrop').hover(
52 $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
54 $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
57 $('.savedsearchterm').hover(
59 id = $(this).attr('id');
60 $('#drop-' + id).addClass('icon'); $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
63 id = $(this).attr('id');
64 $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
67 /* $('.nav-load-page-link').click(function() {
68 getPageContent( $(this).attr('href') );
69 hideNavMenu( '#' + $(this).closest('ul').attr('id') );
73 $('#event-share-checkbox').change(function() {
75 if ($('#event-share-checkbox').is(':checked')) {
76 $('#acl-wrapper').show();
79 $('#acl-wrapper').hide();
84 /* $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
86 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
87 selstr = $(this).text();
88 $('#jot-public').hide();
91 $('#jot-public').show();
94 }).trigger('change');*/
97 if(typeof window.AjaxUpload != "undefined") {
98 var uploader = new window.AjaxUpload(
99 window.imageUploadButton,
100 { action: 'wall_upload/'+window.nickname,
102 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
103 onComplete: function(file,response) {
104 addeditortext(window.jotId, response);
105 $('#profile-rotator').hide();
110 if($('#wall-file-upload').length) {
111 var file_uploader = new window.AjaxUpload(
113 { action: 'wall_attach/'+window.nickname,
115 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
116 onComplete: function(file,response) {
117 addeditortext(window.jotId, response);
118 $('#profile-rotator').hide();
126 if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
129 [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
134 if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
135 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
137 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
138 selstr = $(this).text();
139 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
140 $('#jot-public').hide();
143 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
144 $('#jot-public').show();
147 }).trigger('change');
150 if(window.aclType == "event_head") {
151 $('#events-calendar').fullCalendar({
152 events: baseurl + '/events/json/',
154 left: 'prev,next today',
156 right: 'month,agendaWeek,agendaDay'
158 timeFormat: 'H(:mm)',
159 eventClick: function(calEvent, jsEvent, view) {
160 showEvent(calEvent.id);
162 loading: function(isLoading, view) {
164 $('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); });
168 eventRender: function(event, element, view) {
169 //console.log(view.name);
170 if (event.item['author-name']==null) return;
173 element.find(".fc-event-title").html(
174 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
175 event.item['author-avatar'],
176 event.item['author-name'],
181 element.find(".fc-event-title").html(
182 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
183 event.item['author-avatar'],
184 event.item['author-name'],
190 element.find(".fc-event-title").html(
191 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
192 event.item['author-avatar'],
193 event.item['author-name'],
204 var args=location.href.replace(baseurl,"").split("/");
205 if (args.length>=4) {
206 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
210 var hash = location.hash.split("-")
211 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
215 switch(window.autocompleteType) {
217 $("#recip").name_autocomplete(baseurl + '/acl', '', false, function(data) {
218 $("#recip-complete").val(data.id);
221 case 'contacts-head':
222 $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
225 $("#contacts-search").keyup(function(event){
226 if(event.keyCode == 13){
227 $("#contacts-search").click();
230 $(".autocomplete-w1 .selected").keyup(function(event){
231 if(event.keyCode == 13){
232 $("#contacts-search").click();
237 $(".comment-wwedit-wrapper textarea").editor_autocomplete(baseurl+"/acl");
243 /* if(window.autoCompleteType == "display-head") {
244 //$(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
245 // make auto-complete work in more places
246 //$(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
247 $(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
250 // Add Colorbox for viewing Network page images
251 //var cBoxClasses = new Array();
252 $(".wall-item-body a img").each(function(){
253 var aElem = $(this).parent();
254 var imgHref = aElem.attr("href");
256 // We need to make sure we only put a Colorbox on links to Friendica images
257 // We'll try to do this by looking for links of the form
258 // .../photo/ab803d8eg08daf85023adfec08 (with nothing more following), in hopes
259 // that that will be unique enough
260 if(imgHref.match(/\/photo\/[a-fA-F0-9]+(-[0-9]\.[\w]+?)?$/)) {
262 // Add a unique class to all the images of a certain post, to allow scrolling through
263 var cBoxClass = $(this).closest(".wall-item-body").attr("id") + "-lightbox";
264 $(this).addClass(cBoxClass);
266 // if( $.inArray(cBoxClass, cBoxClasses) < 0 ) {
267 // cBoxClasses.push(cBoxClass);
272 photo: true, // Colorbox doesn't recognize a URL that don't end in .jpg, etc. as a photo
273 rel: cBoxClass //$(this).attr("class").match(/wall-item-body-[\d]+-lightbox/)[0]
277 /*$.each(cBoxClasses, function(){
278 $('.'+this).colorbox({
288 // update pending count //
291 $("nav").bind('nav-update', function(e,data){
292 var elm = $('#pending-update');
293 var register = $(data).find('register').text();
294 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
302 $("#cnftheme").click(function(){
306 href: baseurl + "/admin/themes/" + $("#id_theme :selected").val(),
307 onComplete: function(){
308 $("div#fancybox-content form").submit(function(e){
309 var url = $(this).attr('action');
310 // can't get .serialize() to work...
312 $(this).find("input").each(function(){
313 data[$(this).attr('name')] = $(this).val();
315 $(this).find("select").each(function(){
316 data[$(this).attr('name')] = $(this).children(":selected").val();
318 console.log(":)", url, data);
320 $.post(url, data, function(data) {
321 if(timer) clearTimeout(timer);
336 function homeRedirect() {
337 $('html').fadeOut('slow', function(){
338 window.location = baseurl + "/login";
343 if(typeof window.photoEdit != 'undefined') {
345 $(document).keydown(function(event) {
347 if(window.prevLink != '') { if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = window.prevLink; }}
348 if(window.nextLink != '') { if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = window.nextLink; }}
353 function showEvent(eventid) {
355 baseurl + '/events/?id='+eventid,
357 $.colorbox({html:data});
363 function doEventPreview() {
364 $('#event-edit-preview').val(1);
365 $.post('events',$('#event-edit-form').serialize(), function(data) {
366 $.colorbox({ html: data });
368 $('#event-edit-preview').val(0);
371 function initCrop() {
372 function onEndCrop( coords, dimensions ) {
373 $PR( 'x1' ).value = coords.x1;
374 $PR( 'y1' ).value = coords.y1;
375 $PR( 'x2' ).value = coords.x2;
376 $PR( 'y2' ).value = coords.y2;
377 $PR( 'width' ).value = dimensions.width;
378 $PR( 'height' ).value = dimensions.height;
381 Event.observe( window, 'load', function() {
382 new Cropper.ImgWithPreview(
385 previewWrap: 'previewWrap',
390 ratioDim: { x: 100, y:100 },
399 $(document).mouseup(function (clickPos) {
401 var sysMenu = $("#system-menu-list");
402 var sysMenuLink = $(".system-menu-link");
403 var contactsMenu = $("#contacts-menu-list");
404 var contactsMenuLink = $(".contacts-menu-link");
405 var networkMenu = $("#network-menu-list");
406 var networkMenuLink = $(".network-menu-link");
408 if( !sysMenu.is(clickPos.target) && !sysMenuLink.is(clickPos.target) && sysMenu.has(clickPos.target).length === 0) {
409 hideNavMenu("#system-menu-list");
411 if( !contactsMenu.is(clickPos.target) && !contactsMenuLink.is(clickPos.target) && contactsMenu.has(clickPos.target).length === 0) {
412 hideNavMenu("#contacts-menu-list");
414 if( !networkMenu.is(clickPos.target) && !networkMenuLink.is(clickPos.target) && networkMenu.has(clickPos.target).length === 0) {
415 hideNavMenu("#network-menu-list");
420 function getPageContent(url) {
422 var pos = $('.main-container').position();
424 $('.main-container').css('margin-left', pos.left);
425 $('.main-content-container').hide(0, function () {
426 $('.main-content-loading').show(0);
429 $.get(url, function(html) {
430 console.log($('.main-content-container').html());
431 $('.main-content-container').html( $('.main-content-container', html).html() );
432 console.log($('.main-content-container').html());
433 $('.main-content-loading').hide(function() {
434 $('.main-content-container').fadeIn(800,function() {
435 $('.main-container').css('margin-left', 'auto'); // This sucks -- if the CSS specification changes, this will be wrong
442 function showNavMenu(menuID) {
444 if(window.navMenuTimeout[menuID + '-closing']) {
445 window.navMenuTimeout[menuID + '-closing'] = false;
446 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
449 window.navMenuTimeout[menuID + '-opening'] = true;
451 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
452 $(menuID).slideDown('fast').show();
453 window.navMenuTimeout[menuID + '-opening'] = false;
458 function hideNavMenu(menuID) {
460 if(window.navMenuTimeout[menuID + '-opening']) {
461 window.navMenuTimeout[menuID + '-opening'] = false;
462 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
465 window.navMenuTimeout[menuID + '-closing'] = true;
467 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
468 $(menuID).slideUp('fast');
469 window.navMenuTimeout[menuID + '-closing'] = false;
480 function InitMCEEditor(editorData) {
481 var tinyMCEInitConfig = {
484 //editor_selector: // SPECIFIC
485 //elements: // SPECIFIC
486 plugins : "bbcode,paste,autoresize,inlinepopups",
487 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
488 theme_advanced_buttons2 : "",
489 theme_advanced_buttons3 : "",
490 theme_advanced_toolbar_location : "top",
491 theme_advanced_toolbar_align : "center",
492 theme_advanced_blockformats : "blockquote,code",
493 gecko_spellcheck : true,
494 paste_text_sticky : true, // COUPLED WITH paste PLUGIN
495 entity_encoding : "raw",
496 add_unload_trigger : false,
497 remove_linebreaks : false,
498 //force_p_newlines : false,
499 //force_br_newlines : true,
500 forced_root_block : 'div',
501 //convert_urls: false, //SPECIFIC?
502 content_css: baseurl + "/view/custom_tinymce.css",
503 theme_advanced_path : false,
504 file_browser_callback : "fcFileBrowser",
505 //setup : // SPECIFIC
508 if(window.editSelect != 'none') {
509 $.extend(tinyMCEInitConfig, editorData);
510 tinyMCE.init(tinyMCEInitConfig);
512 else if(typeof editorData.plaintextFn == 'function') {
513 (editorData.plaintextFn)();
520 function initEditor(cb){
523 $("#profile-jot-text-loading").show();
526 mode : "specific_textareas",
527 editor_selector : "profile-jot-text",
528 auto_focus : "profile-jot-text",
529 //plugins : "bbcode,paste,autoresize,inlinepopups",
530 //paste_text_sticky : true,
531 convert_urls : false,
532 setup : function(ed) {
534 ed.onKeyDown.add(function(ed,e) {
539 ed.onKeyUp.add(function(ed, e) {
540 var txt = tinyMCE.activeEditor.getContent();
541 match = txt.match(/@([^ \n]+)$/);
543 if(cPopup === null) {
544 cPopup = new ACPopup(this,baseurl+"/acl");
546 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
547 if(! cPopup.ready) cPopup = null;
550 if(cPopup !== null) { cPopup.close(); cPopup = null; }
553 textlen = txt.length;
554 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
555 $('#profile-jot-desc').html(window.isPublic);
558 $('#profile-jot-desc').html(' ');
564 $('#character-counter').removeClass('red');
565 $('#character-counter').removeClass('orange');
566 $('#character-counter').addClass('grey');
568 if((textlen > 140) && (textlen <= 420)) {
569 $('#character-counter').removeClass('grey');
570 $('#character-counter').removeClass('red');
571 $('#character-counter').addClass('orange');
574 $('#character-counter').removeClass('grey');
575 $('#character-counter').removeClass('orange');
576 $('#character-counter').addClass('red');
578 $('#character-counter').text(textlen);
581 ed.onInit.add(function(ed) {
582 ed.pasteAsPlainText = true;
583 $("#profile-jot-text-loading").hide();
584 $(".jothidden").show();
585 if (typeof cb!="undefined") cb();
589 plaintextFn : function() {
590 $("#profile-jot-text-loading").hide();
591 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
592 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
593 $(".jothidden").show();
594 if (typeof cb!="undefined") cb();
597 InitMCEEditor(editorData);
600 $("a#jot-perms-icon").colorbox({
602 'transition' : 'elastic'
605 if (typeof cb!="undefined") cb();
609 function enableOnUser(){
616 function msgInitEditor() {
618 mode : "specific_textareas",
619 editor_selector : "prvmail-text",
620 //plugins : "bbcode,paste",
621 //paste_text_sticky : true,
622 convert_urls : false,
623 //theme_advanced_path : false,
624 setup : function(ed) {
626 ed.onKeyDown.add(function(ed,e) {
631 ed.onKeyUp.add(function(ed, e) {
632 var txt = tinyMCE.activeEditor.getContent();
633 match = txt.match(/@([^ \n]+)$/);
635 if(cPopup === null) {
636 cPopup = new ACPopup(this,baseurl+"/acl");
638 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
639 if(! cPopup.ready) cPopup = null;
642 if(cPopup !== null) { cPopup.close(); cPopup = null; }
645 textlen = txt.length;
646 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
647 $('#profile-jot-desc').html(window.isPublic);
650 $('#profile-jot-desc').html(' ');
654 ed.onInit.add(function(ed) {
655 ed.pasteAsPlainText = true;
656 var editorId = ed.editorId;
657 var textarea = $('#'+editorId);
658 if (typeof(textarea.attr('tabindex')) != "undefined") {
659 $('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
660 textarea.attr('tabindex', null);
664 plaintextFn : function() {
665 $("#prvmail-text").editor_autocomplete(baseurl+"/acl");
668 InitMCEEditor(editorData);
672 function contactInitEditor() {
675 elements : "contact-edit-info",
678 InitMCEEditor(editorData);
682 function eventInitEditor() {
685 //plugins : "bbcode,paste",
686 //paste_text_sticky : true,
687 //theme_advanced_path : false,
688 setup : function(ed) {
689 ed.onInit.add(function(ed) {
690 ed.pasteAsPlainText = true;
694 InitMCEEditor(editorData);
698 function profInitEditor() {
701 //plugins : "bbcode,paste",
702 //paste_text_sticky : true,
703 //theme_advanced_path : false,
704 setup : function(ed) {
705 ed.onInit.add(function(ed) {
706 ed.pasteAsPlainText = true;
710 InitMCEEditor(editorData);
718 function addeditortext(textElem, data) {
719 if(window.editSelect == 'none') {
720 var currentText = $(textElem).val();
721 $(textElem).val(currentText + data);
724 tinyMCE.execCommand('mceInsertRawHTML',false,data);
727 function jotVideoURL() {
728 reply = prompt(window.vidURL);
729 if(reply && reply.length) {
730 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
734 function jotAudioURL() {
735 reply = prompt(window.audURL);
736 if(reply && reply.length) {
737 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
742 function jotGetLocation() {
744 /* if(navigator.geolocation) {
746 navigator.geolocation.getCurrentPosition(function(position) {
747 var lat = position.coords.latitude;
748 var lng = position.coords.longitude;
752 url: 'http://nominatim.openstreetmap.org/reverse?format=json&lat='+lat+'&lon='+lng,
753 jsonp: 'json_callback',
754 contentType: 'application/json',
756 success: function(json) {
758 var locationDisplay = json.address.building+', '+json.address.city+', '+json.address.state;
759 $('#jot-location').val(locationDisplay);
760 $('#jot-display-location').html('Location: '+locationDisplay);
761 $('#jot-display-location').show();
768 reply = prompt(window.whereAreU, $('#jot-location').val());
769 if(reply && reply.length) {
770 $('#jot-location').val(reply);
774 reply = prompt(window.whereAreU, $('#jot-location').val());
775 if(reply && reply.length) {
776 $('#jot-location').val(reply);
780 function jotShare(id) {
781 if ($('#jot-popup').length != 0) $('#jot-popup').show();
783 $('#like-rotator-' + id).show();
784 $.get('share/' + id, function(data) {
785 if (!editor) $("#profile-jot-text").val("");
786 initEditor(function(){
787 addeditortext("#profile-jot-text", data);
788 $('#like-rotator-' + id).hide();
789 $(window).scrollTop(0);
795 function jotClearLocation() {
796 $('#jot-coord').val('');
797 $('#profile-nolocation-wrapper').hide();
801 function jotGetLink() {
802 reply = prompt(window.linkURL);
803 if(reply && reply.length) {
804 reply = bin2hex(reply);
805 $('#profile-rotator').show();
806 $.get('parse_url?binurl=' + reply, function(data) {
807 addeditortext(window.jotId, data);
808 $('#profile-rotator').hide();
814 function linkdropper(event) {
815 var linkFound = event.dataTransfer.types.contains("text/uri-list");
817 event.preventDefault();
821 function linkdrop(event) {
822 var reply = event.dataTransfer.getData("text/uri-list");
823 //event.target.textContent = reply;
824 event.preventDefault();
825 if(reply && reply.length) {
826 reply = bin2hex(reply);
827 $('#profile-rotator').show();
828 $.get('parse_url?binurl=' + reply, function(data) {
829 /* if(window.jotId == "#profile-jot-text") {
830 if (!editor) $("#profile-jot-text").val("");
831 initEditor(function(){
832 addeditortext(window.jotId, data);
833 $('#profile-rotator').hide();
837 addeditortext(window.jotId, data);
838 $('#profile-rotator').hide();
845 if(typeof window.geoTag === 'function') window.geoTag();
852 function confirmDelete() { return confirm(window.delItem); }
854 function deleteCheckedItems(delID) {
855 if(confirm(window.delItems)) {
859 $(delID + '-rotator').show();
860 $('.item-select').each( function() {
861 if($(this).is(':checked')) {
862 if(checkedstr.length != 0) {
863 checkedstr = checkedstr + ',' + $(this).val();
866 checkedstr = $(this).val();
870 $.post('item', { dropitems: checkedstr }, function(data) {
871 window.location.reload();
876 function itemTag(id) {
877 reply = prompt(window.term);
878 if(reply && reply.length) {
879 reply = reply.replace('#','');
883 $('body').css('cursor', 'wait');
885 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
886 /*if(timer) clearTimeout(timer);
887 timer = setTimeout(NavUpdate,3000);*/
893 function itemFiler(id) {
895 var bordercolor = $("input").css("border-color");
897 $.get('filer/', function(data){
898 $.colorbox({html:data});
900 $("#id_term").keypress(function(){
901 $(this).css("border-color",bordercolor);
903 $("#select_term").change(function(){
904 $("#id_term").css("border-color",bordercolor);
907 $("#filer_save").click(function(e){
909 reply = $("#id_term").val();
910 if(reply && reply.length) {
912 $('body').css('cursor', 'wait');
913 $.get('filer/' + id + '?term=' + reply, NavUpdate);
914 /* if(timer) clearTimeout(timer);
915 timer = setTimeout(NavUpdate,3000);*/
919 $("#id_term").css("border-color","#FF0000");
932 function insertFormatting(comment,BBcode,id) {
934 var tmpStr = $("#comment-edit-text-" + id).val();
935 if(tmpStr == comment) {
937 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
938 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
939 openMenu("comment-edit-submit-wrapper-" + id);
940 $("#comment-edit-text-" + id).val(tmpStr);
943 textarea = document.getElementById("comment-edit-text-" +id);
944 if (document.selection) {
946 selected = document.selection.createRange();
947 if (BBcode == "url"){
948 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
950 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
951 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
952 var start = textarea.selectionStart;
953 var end = textarea.selectionEnd;
954 if (BBcode == "url"){
955 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
957 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
962 function cmtBbOpen(id) {
963 $("#comment-edit-bb-" + id).show();
965 function cmtBbClose(id) {
966 $("#comment-edit-bb-" + id).hide();
969 function commentOpen(obj,id) {
970 if(obj.value == window.commentEmptyText) {
972 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
973 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
974 $("#mod-cmnt-wrap-" + id).show();
975 openMenu("comment-edit-submit-wrapper-" + id);
978 function commentClose(obj,id) {
979 if(obj.value == "") {
980 obj.value = window.commentEmptyText;
981 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
982 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
983 $("#mod-cmnt-wrap-" + id).hide();
984 closeMenu("comment-edit-submit-wrapper-" + id);
989 function commentInsert(obj,id) {
990 var tmpStr = $("#comment-edit-text-" + id).val();
991 if(tmpStr == window.commentEmptyText) {
993 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
994 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
995 openMenu("comment-edit-submit-wrapper-" + id);
997 var ins = $(obj).html();
998 ins = ins.replace("<","<");
999 ins = ins.replace(">",">");
1000 ins = ins.replace("&","&");
1001 ins = ins.replace(""",'"');
1002 $("#comment-edit-text-" + id).val(tmpStr + ins);
1005 function qCommentInsert(obj,id) {
1006 var tmpStr = $("#comment-edit-text-" + id).val();
1007 if(tmpStr == window.commentEmptyText) {
1009 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
1010 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
1011 openMenu("comment-edit-submit-wrapper-" + id);
1013 var ins = $(obj).val();
1014 ins = ins.replace("<","<");
1015 ins = ins.replace(">",">");
1016 ins = ins.replace("&","&");
1017 ins = ins.replace(""",'"');
1018 $("#comment-edit-text-" + id).val(tmpStr + ins);
1022 /*function showHideCommentBox(id) {
1023 if( $('#comment-edit-form-' + id).is(':visible')) {
1024 $('#comment-edit-form-' + id).hide();
1027 $('#comment-edit-form-' + id).show();