var almsamim = {}; var comm, bbcode; var isIE, isOpera,isGecko, isWebKit,ua,Editor; ua = navigator.userAgent; almsamim.isOpera = isOpera = window['opera'] && opera.buildNumber; almsamim.isWebKit = isWebKit = /WebKit/.test(ua); almsamim.isGecko = isGecko = !isWebKit && /Gecko/.test(ua); almsamim.isIE = isIE = !isWebKit && !isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName); almsamim.plugins = {}; // dropdown divs of the toolbar var lang_s = new Array(); var ids = new Array; ids[5] = 'Colorpalettef'; var smiley_wysiwyg = true; var smiley_code = new Array(); for (i = 0; i < 700; i++){ smiley_code[i] = '[e' + (i < 10 ? '0' + i : i) + ']'; } var smiley_img = new Array(); for (i = 0; i < 700; i++){ smiley_img[i] = (i < 10 ? '0' + i : i ) + '.gif'; } var smiley_path = "images/smile/"; var smiley_total = 700; var doc = null; var tra = new Array(); var abc2 = new Array(); var translit = false; var translit_language = true; tra[String.fromCharCode(97)] = new Array ('ы+','Й+','Ы+','й+','Ы','й','ы','Й','',''); abc2[String.fromCharCode(97)] = new Array ('ыа','Йа','Ыа','йа','Я','я','я','Я','а','a'); tra[String.fromCharCode(98)] = new Array ('',''); abc2[String.fromCharCode(98)] = new Array ('б','b'); tra[String.fromCharCode(118)] = new Array ('',''); abc2[String.fromCharCode(118)] = new Array ('в','v'); tra[String.fromCharCode(103)] = new Array ('',''); abc2[String.fromCharCode(103)] = new Array ('г','g'); tra[String.fromCharCode(100)] = new Array ('',''); abc2[String.fromCharCode(100)] = new Array ('д','d'); tra[String.fromCharCode(101)] = new Array ('Й+','й+','Й','й','',''); abc2[String.fromCharCode(101)] = new Array ('Йе','йе','Э','э','е','e'); tra[String.fromCharCode(111)] = new Array ('ы+','Й+','Ы+','й+','Ы','ы','Й','й','',''); abc2[String.fromCharCode(111)] = new Array ('ыо','Йо','Ыо','йо','Ё','ё','Ё','ё','о','o'); tra[String.fromCharCode(246)] = new Array ('',''); abc2[String.fromCharCode(246)] = new Array ('ё','ц'); tra[String.fromCharCode(104)] = new Array ('сх+','Сх+','з+','Сх','с+','ш+','Ц+','Ш+','С+','сх','ц+','З+','Ш','с','ц','ш','З','С','Ц','з','',''); abc2[String.fromCharCode(104)] = new Array ('схх','Схх','зх','Щ','сх','шх','Цх','Шх','Сх','щ','цх','Зх','Щ','ш','ч','щ','Ж','Ш','Ч','ж','х','h'); tra[String.fromCharCode(122)] = new Array ('',''); abc2[String.fromCharCode(122)] = new Array ('з','z'); tra[String.fromCharCode(105)] = new Array ('',''); abc2[String.fromCharCode(105)] = new Array ('и','i'); tra[String.fromCharCode(106)] = new Array ('',''); abc2[String.fromCharCode(106)] = new Array ('й','j'); tra[String.fromCharCode(107)] = new Array ('',''); abc2[String.fromCharCode(107)] = new Array ('к','k'); tra[String.fromCharCode(108)] = new Array ('',''); abc2[String.fromCharCode(108)] = new Array ('л','l'); tra[String.fromCharCode(109)] = new Array ('',''); abc2[String.fromCharCode(109)] = new Array ('м','m'); tra[String.fromCharCode(110)] = new Array ('',''); abc2[String.fromCharCode(110)] = new Array ('н','n'); tra[String.fromCharCode(112)] = new Array ('',''); abc2[String.fromCharCode(112)] = new Array ('п','p'); tra[String.fromCharCode(114)] = new Array ('',''); abc2[String.fromCharCode(114)] = new Array ('р','r'); tra[String.fromCharCode(115)] = new Array ('',''); abc2[String.fromCharCode(115)] = new Array ('с','s'); tra[String.fromCharCode(116)] = new Array ('',''); abc2[String.fromCharCode(116)] = new Array ('т','t'); tra[String.fromCharCode(117)] = new Array ('ы+','Й+','Ы+','й+','Ы','й','ы','Й','',''); abc2[String.fromCharCode(117)] = new Array ('ыу','Йу','Ыу','йу','Ю','ю','ю','Ю','у','u'); tra[String.fromCharCode(102)] = new Array ('',''); abc2[String.fromCharCode(102)] = new Array ('ф','f'); tra[String.fromCharCode(120)] = new Array ('',''); abc2[String.fromCharCode(120)] = new Array ('х','x'); tra[String.fromCharCode(99)] = new Array ('',''); abc2[String.fromCharCode(99)] = new Array ('ц','c'); tra[String.fromCharCode(119)] = new Array ('',''); abc2[String.fromCharCode(119)] = new Array ('щ','w'); tra[String.fromCharCode(35)] = new Array ('ъ+','ъ','',''); abc2[String.fromCharCode(35)] = new Array ('ъъ','Ъ','ъ','#'); tra[String.fromCharCode(121)] = new Array ('',''); abc2[String.fromCharCode(121)] = new Array ('ы','y'); tra[String.fromCharCode(39)] = new Array ('ь+','ь','',''); abc2[String.fromCharCode(39)] = new Array ('ьь','Ь','ь','\''); tra[String.fromCharCode(228)] = new Array ('',''); abc2[String.fromCharCode(228)] = new Array ('э','д'); tra[String.fromCharCode(252)] = new Array ('',''); abc2[String.fromCharCode(252)] = new Array ('ю','ь'); tra[String.fromCharCode(65)] = new Array ('Ы+','Й+','Ы','Й','',''); abc2[String.fromCharCode(65)] = new Array ('ЫА','ЙА','Я','Я','А','A'); tra[String.fromCharCode(66)] = new Array ('',''); abc2[String.fromCharCode(66)] = new Array ('Б','B'); tra[String.fromCharCode(86)] = new Array ('',''); abc2[String.fromCharCode(86)] = new Array ('В','V'); tra[String.fromCharCode(71)] = new Array ('',''); abc2[String.fromCharCode(71)] = new Array ('Г','G'); tra[String.fromCharCode(68)] = new Array ('',''); abc2[String.fromCharCode(68)] = new Array ('Д','D'); tra[String.fromCharCode(69)] = new Array ('Й+','Й','',''); abc2[String.fromCharCode(69)] = new Array ('ЙЕ','Э','Е','E'); tra[String.fromCharCode(79)] = new Array ('Ы+','Й+','Ы','Й','',''); abc2[String.fromCharCode(79)] = new Array ('ЫО','ЙО','Ё','Ё','О','O'); tra[String.fromCharCode(214)] = new Array ('',''); abc2[String.fromCharCode(214)] = new Array ('Ё','Ц'); tra[String.fromCharCode(72)] = new Array ('СХ+','Ц+','СХ','С+','З+','Ш+','Ш','Ц','С','З','',''); abc2[String.fromCharCode(72)] = new Array ('СХХ','ЦХ','Щ','СХ','ЗХ','ШХ','Щ','Ч','Ш','Ж','Х','H'); tra[String.fromCharCode(90)] = new Array ('',''); abc2[String.fromCharCode(90)] = new Array ('З','Z'); tra[String.fromCharCode(73)] = new Array ('',''); abc2[String.fromCharCode(73)] = new Array ('И','I'); tra[String.fromCharCode(74)] = new Array ('',''); abc2[String.fromCharCode(74)] = new Array ('Й','J'); tra[String.fromCharCode(75)] = new Array ('',''); abc2[String.fromCharCode(75)] = new Array ('К','K'); tra[String.fromCharCode(76)] = new Array ('',''); abc2[String.fromCharCode(76)] = new Array ('Л','L'); tra[String.fromCharCode(77)] = new Array ('',''); abc2[String.fromCharCode(77)] = new Array ('М','M'); tra[String.fromCharCode(78)] = new Array ('',''); abc2[String.fromCharCode(78)] = new Array ('Н','N'); tra[String.fromCharCode(80)] = new Array ('',''); abc2[String.fromCharCode(80)] = new Array ('П','P'); tra[String.fromCharCode(82)] = new Array ('',''); abc2[String.fromCharCode(82)] = new Array ('Р','R'); tra[String.fromCharCode(83)] = new Array ('',''); abc2[String.fromCharCode(83)] = new Array ('С','S'); tra[String.fromCharCode(84)] = new Array ('',''); abc2[String.fromCharCode(84)] = new Array ('Т','T'); tra[String.fromCharCode(85)] = new Array ('Ы+','Й+','Ы','Й','',''); abc2[String.fromCharCode(85)] = new Array ('ЫУ','ЙУ','Ю','Ю','У','U'); tra[String.fromCharCode(70)] = new Array ('',''); abc2[String.fromCharCode(70)] = new Array ('Ф','F'); tra[String.fromCharCode(88)] = new Array ('',''); abc2[String.fromCharCode(88)] = new Array ('Х','X'); tra[String.fromCharCode(67)] = new Array ('',''); abc2[String.fromCharCode(67)] = new Array ('Ц','C'); tra[String.fromCharCode(87)] = new Array ('',''); abc2[String.fromCharCode(87)] = new Array ('Щ','W'); tra[String.fromCharCode(89)] = new Array ('',''); abc2[String.fromCharCode(89)] = new Array ('Ы','Y'); tra[String.fromCharCode(196)] = new Array ('',''); abc2[String.fromCharCode(196)] = new Array ('Э','Д'); tra[String.fromCharCode(220)] = new Array ('',''); abc2[String.fromCharCode(220)] = new Array ('Ю','Ь'); var smiles = new Array(); smiles[':D'] = ':D'; smiles[';)'] = ';)'; smiles[':)'] = ':)'; smiles[':P'] = ':P'; smiles[':]'] = ':]'; smiles['=)'] = '=)'; smiles[':|'] = ':|'; smiles[':('] = ':('; smiles[':\\'] = ':\\'; smiles['=0'] = '=0'; smiles[':X'] = [':X']; /* * отослать сообщение */ function send_message(button_object){ Editor = document.getElementById('box').contentWindow.document; var ceditor = bbcode._HTMLtoBBcode(bbcode._erase(Editor.body.innerHTML)); ceditor = ceditor.replace(/(^\s+)|(\s+$)/g, ""); /* если данных нет */ if (!$.fn.editor_options.empty_msg && ceditor == ''){ alert(locale.empty_message[lang]); $('#box').get(0).contentWindow.focus(); return; } if ($.fn.editor_options.unbind_btn){ button_object.onclick = ''; } /* выполнить callback или сделать пост по умолчанию */ if (typeof $.fn.editor_options.callback == 'function'){ $.fn.editor_options.callback(ceditor); }else{ var valid = true; /* если есть дополнительные поля для post */ if ($.fn.editor_options.onpost != null && (post_vars = $.fn.editor_options.onpost()) != false){ /* совместить все в один массив */ post_vars = $.extend({ editor_msg: ceditor }, post_vars); }else if($.fn.editor_options.onpost != null && (post_vars = $.fn.editor_options.onpost()) == false){ /* валидация не прошла */ valid = false; }else{ var post_vars = { editor_msg: ceditor }; } /* выполнить запрос на сервер и выполнить onresult */ if (valid == true){ $.post($.fn.editor_options.post_url, post_vars, $.fn.editor_options.onresult); } } return; } //----------------------------------------------------------------------- function cookie_create(name, value, days){ if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); }else{ var expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; } //----------------------------------------------------------------------- function cookie_read(name){ var ca = document.cookie.split(';'); var nameEQ = name + "="; for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } //----------------------------------------------------------------------- function cookie_delete(name){ cookie_create(name, "", -1); } //----------------------------------------------------------------------- function hideFgColors(obj){ $('#colors_fg').hide(); } //----------------------------------------------------------------------- function skip_smile(txt){ if (txt.length > 2){ txt = txt.substr(txt.length - 2); } if (!smiles[txt]){ return false; }else{ return true; } } //----------------------------------------------------------------------- function translate_letter(keyCode, e) { var txt = String.fromCharCode(keyCode); if (txt== '<' || txt == '[') { translit_language = false; } if (txt == '>' || txt == ']') { translit_language = true; } if (!tra[txt]){ return true; } doc = document.getElementById('box').contentWindow.document; if (navigator.family == 'ie4'){ keyCode = 0; with(doc.selection.createRange()){ if (text != ''){ doc.selection.clear(); } text = ''; collapse(); select(); } cursor_pos_selection = doc.selection.createRange(); cursor_pos_selection.select(); cursor_pos_selection.text = '%'; cursor_pos_selection.moveStart("character", -2); pretxt = cursor_pos_selection.text.substring(0, cursor_pos_selection.text.length-1); cursor_pos_selection.text = ''; cursor_pos_selection.collapse(); result =""; if (translit_language && !skip_smile(pretxt+txt)){ result = translatesymboltocyrillic(pretxt+txt); }else{ result = pretxt+txt; } with(doc.selection.createRange()) { select(); text = result; collapse(); } }else{ if (keyCode && keyCode > 33 && (!(e.ctrlKey || e.altKey))) { if (e.preventDefault){ e.preventDefault(); } var sel = document.getElementById('box').contentWindow.getSelection(); var range = sel.getRangeAt(0); if (navigator.family != 'opera'){ sel.removeAllRanges(); range.deleteContents(); var container = range.startContainer; var pos = range.startOffset; range=document.createRange(); }else{ var container = range.startContainer; var pos = range.startOffset; } var afterNode; if (container.nodeType==3) { var textNode = container; container = textNode.parentNode; var text = textNode.nodeValue; var textBefore = text.substr(0,pos); var textAfter = text.substr(pos); if (translit_language && !skip_smile(textBefore + txt)){ textBefore = translatesymboltocyrillic(textBefore + txt); // to cyrillic }else{ textBefore = textBefore + txt; } pos = textBefore.length; textNode.nodeValue = textBefore+textAfter; range.setEnd(textNode, pos); range.setStart(textNode, pos); }else { textNode = container.childNodes[pos]; if (translit_language && !skip_smile(txt)){ txt = translatesymboltocyrillic(txt); // to cyrillic } afterNode = document.createTextNode(txt); pos = txt.length; container.insertBefore(afterNode, textNode); range.setEnd(afterNode, pos); range.setStart(afterNode, pos); } sel.addRange(range); } } $('#box').get(0).contentWindow.focus(); return false; } //----------------------------------------------------------------------- function translatesymboltocyrillic(txt) { var pretxt = txt.substr(0,txt.length-1); var last = txt.substr(txt.length-1,1); var lat = tra[last]; var rus = abc2[last]; if (lat){ for (var ii=0; iilat[ii].length?(pretxt.length-lat[ii].length):0; if (lat[ii]==pretxt.substr(pos,pretxt.length-pos)){ return pretxt.substr(0,pretxt.length-lat[ii].length)+rus[ii]; } } } return txt; } //----------------------------------------------------------------------- function shortkey_pressed(e){ var keynum; var keychar; var ctrl; if (navigator.appName.indexOf("Netscape") == -1){ // IE keynum = e.keyCode; }else if(e.which){ // Netscape/Firefox/Opera keynum = e.which; } keychar = String.fromCharCode(keynum); if ((keynum == 13 && e.ctrlKey) || (keynum == 10 && e.ctrlKey)){ if (document.getElementById("chat") != null) { setTimeout('send_message1();', 10); } else { setTimeout('send_message("");', 10); } return false; } if (translit){ res = translate_letter(keynum, e); }else{ res = true; } return res; } //----------------------------------------------------------------------- function saveCurrentPos(){ if (navigator.family == 'ie4' ){ current_pos = document.getElementById('box').contentWindow.document.selection.createRange(); } } //----------------------------------------------------------------------- if (smiley_wysiwyg) { var smiley_code_bbcode = new Array(); var smiley_img_bbcode = new Array(); for(var i = 0; i < smiley_total; i++) { smiley_code_bbcode[i] = smiley_code[i]; smiley_img_bbcode[i] = "[IMG]/" + smiley_path + smiley_img[i] + "[/IMG]"; } function Smiley_HTMLtoBBcode(str) { /* FF smile troubles */ while (str.indexOf('.../images/smile') > -1) { str = str.replace('.../images/smile','/images/smile'); } while (str.indexOf('/..') > -1) { str = str.replace('/..',''); } for(var i = 0; i < smiley_total; i++) { while (str.indexOf(smiley_img_bbcode[i]) > -1) { str = str.replace(smiley_img_bbcode[i], smiley_code_bbcode[i]); } } /* удалить все картинки, которые не смайлы */ return str.replace(/\[img\](.*?)\[\/img\]/gi,''); }; function Smiley_BBcodetoHTML(str) { for(var i = 0; i < smiley_total; i++) { while (str.indexOf(smiley_code_bbcode[i]) > -1) { str = str.replace(smiley_code_bbcode[i], smiley_img_bbcode[i]); } } return str; }; } almsamim.bbcode = bbcode = { // turning the editor on Start : function (){ Editor = document.getElementById('box').contentWindow.document; var iframeContent; iframeContent = '\n'; iframeContent += ''; //iframeContent += ''; var msg_editor_h = document.getElementById("msg_editor_h"); if (msg_editor_h.value !== ""){ iframeContent += this._BBcodetoHTML(msg_editor_h.value) ; } iframeContent += ''; iframeContent += ''; Editor.open(); Editor.write(iframeContent); Editor.close(); if(isIE){ Editor.body.contentEditable = true; }else { Editor.designMode = "on"; } /* события */ if (typeof Editor.addEventListener != 'undefined') { Editor.addEventListener("keypress", shortkey_pressed, true); Editor.addEventListener("onclick", saveCurrentPos, true); }else if (typeof Editor.attachEvent != 'undefined') { Editor.attachEvent('onkeypress', shortkey_pressed); Editor.attachEvent('onclick', saveCurrentPos); } if(isIE){ Editor.attachEvent('onmousedown', hideall); }else{ Editor.addEventListener('mousedown', hideall, true); } /* if(isIE){ Editor.attachEvent('onkeypress', editorEvents); Editor.attachEvent('onmousedown', editorEvents); Editor.attachEvent('onmousedown', hideall); Editor.body.contentEditable = true; }else{ Editor.addEventListener('keypress', editorEvents, true); Editor.addEventListener('mousedown', editorEvents, true); Editor.addEventListener('mousedown', hideall, true); Editor.designMode = "on"; } */ // activate_divs(); if(!isWebKit){ // disable CSS in Geko ,IE and opera try { // Try new Gecko method Editor.execCommand("styleWithCSS", 0, false); } catch (e) { // Use old method try {Editor.execCommand("useCSS", 0, true);} catch (e) {}; } } $('#more_smiles').click(function(e){ if (!$('#smile_popup_width').is(":hidden")) { $('#smile_popup_width').hide(); $('#box').get(0).contentWindow.focus(); } else { x=e.pageX - 520; //y=e.pageY - 390; y = e.pageY - $('#smile_popup_width').height() - 30; if (x < 0) { x = 3; } if (y < 0) { y = 0; } x = x + 'px'; y = y + 'px'; $('#smile_popup_width').css({left:x,top:y,display:''}); } return false; }); //----------------------------------------------------------------------- $('.customize_smiles').click(function(e){ window_open('/window/profile/custom_smiles.html', 700, 500, 'smiles', true); }); //----------------------------------------------------------------------- $('#bclose_smiles').click(function(e){ $('#smile_popup_width').hide(); $('#box').get(0).contentWindow.focus(); }); //----------------------------------------------------------------------- $('#colors_btn').click(function(e){ if (!$('#colors_fg').is(":hidden")) { $('#colors_fg').hide(); $('#box').get(0).contentWindow.focus(); } else { x = e.pageX; y = e.pageY; if (x < 0){ x = 3; } if (y < 0){ y = 0; } x = x + 'px'; y = y + 'px'; $('#colors_fg').css({left:x,top:y,display:''}).show(); } }); //----------------------------------------------------------------------- $('#col_close').click(function(e){ $('#colors_fg').hide(); $('#box').get(0).contentWindow.focus(); }); //----------------------------------------------------------------------- $('#toggle_translit_id').mouseover(function(e){ x = e.pageX + 5; y = e.pageY; if (x < 0){ x = 3; } if (y < 0){ y = 0; } if (x + 370 > $(document).width()) { x = $(document).width() - 370; } if (y + 176 > $(document).height()) { y = $(document).height() - 176; } x = x + 'px'; y = y + 'px'; $('#translit_hint').css({left:x,top:y,display:'',cursor:'pointer'}); return false; }); //----------------------------------------------------------------------- $('#translit_hint').mouseout(function(e){ $('#translit_hint').hide(); }); }, // convert BBcode to HTML code _BBcodetoHTML : function (a) { function r(re, str) { a = a.replace(re, str); }; if (smiley_wysiwyg) { a=Smiley_BBcodetoHTML(a); } a = a.replace(/\[fg=/gi, "[color="); a = a.replace(/\[\/fg\]/gi, "[/color]"); a = a.replace(/\[a=/gi, "[url="); a = a.replace(/\[\/a\]/gi, "[/url]"); a = a.replace(/\[wbr\]/gi, ""); r(/\n+(\[\/list\])/gi,'[/list]'); r(/\[list\]\n+/gi,'[list]'); r(/\[list=1\]\n+/gi,'[list=1]'); r(/\[list=a\]\n+/gi,'[list=a]'); r(/\n+\[\/tr\]/gi,'[/tr]'); r(/\n+\[tr\]/gi,'[tr]'); r(/\n+\[td\]/gi,'[td]'); r(/\n+\[\/td\]/gi,'[/td]'); r(/\n+\[\/table\]/gi,'[/table]'); r(/\[\/table\]$/gi,"[/table]\n"); r(/&/g,'&'); r(//gi,''); r(/]*>/gi, ""); //mojo r(//g,'>'); r(/ /g,'  '); r(/\t/g,'     '); r(/\n/g,'
'); r(/\[hr\]/gi,'
'); r(/\[\/hr]/gi,''); r(/\[table\]/gi,''); r(/\[\/table\]/gi,'
'); r(/\[(\/|)tr\]/gi,'<$1tr>'); r(/\[(\/|)td\]/gi,'<$1td style="font-size: 20px; display:table-cell;padding:1px;vertical-align:inherit;border:1px dotted #CCCCCC;">'); r(/\[(\/|)indent\]/gi,'<$1blockquote>'); r(/\[(sub|sup|strike|s|b|i|u|blockquote)\]/gi,'<$1>'); r(/\[\/(sub|sup|strike|s|b|i|u|blockquote)\]/gi,''); r(/\[font=(.*?)\]/gi,''); r(/\[color=(.*?)\]/gi,''); r(/\[highlight=(.*?)\]/gi,''); r(/\[\/highlight\]/gi,''); r(/\[size=(.*?)\]/gi,''); r(/\[\/(font|color|size)\]/gi,''); r(/\[(center|left|right|justify)\]/gi,'
'); r(/\[\/(center|left|right|justify)\]/gi,'
'); r(/\[url=(.*?)\]/gi,''); r(/\[url\](.*?)\[\/url\]/gi,'$1[/url]'); r(/\[\/url\]/gi,''); r(/\[img\](.*?)\[\/img\]/gi,''); var b=a.match(/\[(list|list=1|list=a)\]/gi); r(/\[list=1\]/gi,'
    '); r(/\[list=a\]/gi,'
      '); r(/\[list\]/gi,'
        '); r(/\[\*\]/gi,'
      • '); r(/]*>
      • /gi,'
      • '); r(/]*>
      • /gi,'
      • '); r(/]*><\/li>/gi,'
      • '); r(/\[h([1-6])?\]/gi,""); r(/\[\/h([1-6])?\]/gi,""); if(b){for(var i=0;i');}else if(b[i].toLowerCase()=="[list=1]"||b[i].toLowerCase()=="[list=a]"){r(/\[\/list\]/i,'
    ');}}} if(isOpera){r(/<\/table>/gi,'');r(/<\/tr>/gi,'');} if(isOpera||isIE){r(/
  1. /gi,'
  2. ');r(/<\/(ol|ul)>/gi,'
  3. ');} return a; }, // erase white spaces from the text inside the editor _erase : function (a) { if(typeof a!="string")return a; var b=a; var c=b.substring(0,1); while(c==" ") { b=b.substring(1,b.length); c=b.substring(0,1) } c=b.substring(b.length-1,b.length); while(c==" ") { b=b.substring(0,b.length-1); c=b.substring(b.length-1,b.length) } while(b.indexOf(" ")!=-1) { b=b.substring(0,b.indexOf(" "))+b.substring(b.indexOf(" ")+1,b.length) } return b ; }, // convert HTML to bb when submit bbcode _HTMLtoBBcode : function (a) { function r(re, str) { a = a.replace(re, str); }; if (isIE) { r(/<\/li>/gi, ""); r(/
  4. /gi, "[*]"); } r(/
    <\/div>/gi, ""); r(/]*>/gi, "
    "); r(/[\n\r]/gi, " "); r(/