باش بېتى | MP3 | MTV | تىما بېزەش رەسىمى | يۇمشاق دىتال | كىنو | تور ئويۇنلىرى | ناخشا ئىزدەش| يانفۇن مۇزىكىسى

ئالدىنقى تېماكىيىنكى تېما
مەزكۇر يازما 724 قېتىم كۆرۈلدى
تېما: editor.js دىن ياردەم سورايمەن
دەرىجە: يېڭى ئەزا
ئەزا ئۇچۇرى ئەزا نومۇرى: 1595
جىنسى : يوشۇرۇن
نادىر تېمىسى: 0
ئومۇمىي يازما: 1
ئۇنۋان:يېڭى ھازىرغىچە1دانە
ئۆسۈش: 30 %
مۇنبەر پۇلى: 30 سوم
تۆھپىسى: 0 كىشى
ياخشى باھا: 0 نۇمۇر
تىزىملاش: 2010-09-06
ئاخىرقى: 2010-09-06
0-قەۋەت   يوللانغان ۋاقت: 2010-09-06 22:35

editor.js دىن ياردەم سورايمەن

';
 });
 str = str.replace(/\[\/td\]\s*\[\/tr\]/ig, '
');
 return '
editor.js گە ئۇيغۇرچە ھەرىپ يازىدىغان قىلىپ تەڭشەپ بەرسەڭلەر
كودى:
كودنى نۇسخىلاش
  1. var tempdata='';   //临时保存数据
  2. var postSubmited = false;
  3. var smdiv = new Array();
  4. var codecount = '-1';
  5. var codehtml = new Array();var Editorwin = 0;
  6. var editbox = editwin = editdoc = editcss = null;
  7. var cursor = -1;
  8. var stack = new Array();
  9. var initialized = false;function newEditor(mode, initialtext) {
  10.  wysiwyg = parseInt(mode);
  11.  if(!(is_ie || is_moz || (is_opera >= 9))) {
  12.   allowswitcheditor = wysiwyg = 0;
  13.  }
  14.  if(!allowswitcheditor) {
  15.   $(editorid + '_switcher').style.display = 'none';
  16.  } $(editorid + '_cmd_table').style.display = wysiwyg ? '' : 'none'; if(wysiwyg) {
  17.   if($(editorid + '_iframe')) {
  18.    editbox = $(editorid + '_iframe');
  19.   } else {
  20.    var iframe = document.createElement('iframe');
  21.    editbox = textobj.parentNode.appendChild(iframe);
  22.    editbox.id = editorid + '_iframe';
  23.   }  editwin = editbox.contentWindow;
  24.   editdoc = editwin.document;
  25.   writeEditorContents(isUndefined(initialtext) ?  textobj.value : initialtext);
  26.  } else {
  27.   editbox = editwin = editdoc = textobj;
  28.   if(!isUndefined(initialtext)) {
  29.    writeEditorContents(initialtext);
  30.   }
  31.   addSnapshot(textobj.value);
  32.  }
  33.  setEditorEvents();
  34.  initEditor();
  35. }function initEditor() {
  36.  var buttons = $(editorid + '_controls').getElementsByTagName('a');
  37.  for(var i = 0; i < buttons.length; i++) {
  38.   if(buttons[i].id.indexOf(editorid + '_cmd_') != -1) {
  39.    buttons[i].href="#";
  40.    buttons[i].onclick = function(e) {ubbcode(this.id.substr(this.id.lastIndexOf('_cmd_') + 5))};
  41.   } else if(buttons[i].id.indexOf(editorid + '_popup_') != -1) {
  42.    buttons[i].href="#";
  43.    if(!$(buttons[i].id + '_menu') || !$(buttons[i].id + '_menu').getAttribute('clickshow')) {
  44.     buttons[i].onmouseover = function(e) {InFloat = InFloat_Editor;showMenu(this.id, true, 0, 2)};
  45.    } else {
  46.     buttons[i].onclick = function(e) {InFloat = InFloat_Editor;showMenu(this.id, true, 0, 2)};
  47.    }
  48.   }
  49.  }
  50.  setUnselectable($(editorid + '_controls'));
  51.  textobj.onkeydown = function(e) {ctlent(e ? e : event)};
  52. }
  53. function AddText(txt) {
  54.  obj = $('postform').message;
  55.  selection = document.selection;
  56.  checkFocus();
  57.  if(!isUndefined(obj.selectionStart)) {
  58.   var opn = obj.selectionStart + 0;
  59.   obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
  60.  } else if(selection && selection.createRange) {
  61.   var sel = selection.createRange();
  62.   sel.text = txt;
  63.   sel.moveStart('character', -strlen(txt));
  64.  } else {
  65.   obj.value += txt;
  66.  }
  67. }function checkFocus() {
  68.  var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('postform').message : editwin;
  69.  if(!obj.hasfocus) {
  70.   obj.focus();
  71.  }
  72. }function validate(theform) {
  73.  var message = wysiwyg ? html2bbcode(getEditorContents()) : parseurl(theform.message.value);
  74.  theform.message.value = message;
  75.  return true;
  76. }//ctrl+enter 提交
  77. function ctlent(event) {
  78.  if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83) ) {
  79.   //postSubmited = true;
  80.   //$('postsubmit').disabled = true;
  81.   parent.checkform();
  82.   //parent.document.getElementsByTagName("form")[0].submit();
  83.  }
  84. }// 解析URL
  85. function parseurl(str, mode, parsecode) {
  86.  if(!parsecode) str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return codetag($2);});
  87.  str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, mode == 'html' ? '$1' : '$1[img]$2[/img]');
  88.  str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast):\/\/))([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1$2' : '$1[url]$2[/url]');
  89.  str = str.replace(/([^\w>=\]"'\/@]|^)((www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1$2' : '$1[url]$2[/url]');
  90.  //str = str.replace(/([^\w->=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1mailto:$2">$2' : '$1[email]$2[/email]');
  91.  if(!parsecode) {
  92.   for(var i = 0; i <= codecount; i++) {
  93.    str = str.replace("[\tUBB_CODE_" + i + "\t]", codehtml[i]);
  94.   }
  95.  }
  96.  return str;
  97. }// 处理[CODE] 将[code]
间的数据填入 codehtml 返回 codecount
function codetag(text) {
 codecount++;
 if(typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/]*>/ig, '\n');
 //if(typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/]*>/ig, '\n').replace(/<(\/|)[A-Za-z].*?>/ig, '');
 codehtml[codecount] = '
كودنى نۇسخىلاش
  1. ' + text + '
';
 return '[\tUBB_CODE_' + codecount + '\t]';
}
// 验证内容长度
function checklength(theform) {
 var message = wysiwyg ? html2bbcode(getEditorContents()) : (!theform.parseurloff.checked ? parseurl(theform.message.value) : theform.message.value);
 //var showmessage = postmaxchars != 0 ? '限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节' : '';
 var showmessage = '';
 alert('\n当前长度: ' + mb_strlen(message) + ' 字节\n\n' + showmessage);
}
// 恢复保存数据
function loadData(quiet) {
 if(tempdata==''){
   alert('没有可恢复的数据!');
   return;
 }else if(confirm('此操作将覆盖当前帖子内容,确定要恢复数据吗?')) {
  if (wysiwyg){
   editdoc.body.innerHTML=tempdata;
  }else{
   textobj.value=tempdata;
  }
 }
}
// 自动保数据
var autosaveDatai, autosaveDatatime;
function autosaveData(op) {
 var autosaveInterval = 60;
 obj = $(editorid + '_cmd_autosave');
 if(op) {
  if(op == 2) {
   saveData(wysiwyg ? editdoc.body.innerHTML : textobj.value);
  } else {
   setcookie('disableautosave', '', -2592000);
  }
  autosaveDatatime = autosaveInterval;
  autosaveDatai = setInterval(function() {
   autosaveDatatime--;
   if(autosaveDatatime == 0) {
    saveData(wysiwyg ? editdoc.body.innerHTML : textobj.value);
    autosaveDatatime = autosaveInterval;
   }
   if($('autsavet')) {
    $('autsavet').innerHTML = '(' + autosaveDatatime + '秒' + ')';
   }
  }, 1000);
  obj.onclick = function() { autosaveData(0); }
 } else {
  setcookie('disableautosave', 1, 2592000);
  clearInterval(autosaveDatai);
  $('autsavet').innerHTML = '(已停止)';
  obj.onclick = function() { autosaveData(1); }
 }
}

// 保存编辑器数据
function saveData(data, del) {
 if (wysiwyg){
  tempdata=editdoc.body.innerHTML;
 }else{
  tempdata=textobj.value;
 }
}

function setCaretAtEnd() {
 if(typeof wysiwyg != 'undefined' && wysiwyg) {
  editdoc.body.innerHTML += '';
 } else {
  editdoc.value += '';
 }
}


function setUnselectable(obj) {
 if(is_ie && is_ie > 4 && typeof obj.tagName != 'undefined') {
  if(obj.hasChildNodes()) {
   for(var i = 0; i < obj.childNodes.length; i++) {
    setUnselectable(obj.childNodes);
   }
  }
  obj.unselectable = 'on';
 }
}
function writeEditorContents(text) {
 if(wysiwyg) {
  if(text == '' && is_moz) {
   text = '
';
  }
  if(initialized && !(is_moz && is_moz >= 3)) {
   editdoc.body.innerHTML = text;
  } else {
   editdoc.designMode = 'on';
   editdoc = editwin.document;
   editdoc.open('text/html', 'replace');
   editdoc.write(text);
   editdoc.close();
   editdoc.body.contentEditable = true;
   initialized = true;
  }
 } else {
  textobj.value = text;
 }
 setEditorStyle();
}
function getEditorContents() {
 return wysiwyg ? editdoc.body.innerHTML : editdoc.value;
}
//始终返回ubb代码格式的内容
function getEditorContentByUbb(){
 return wysiwyg ? html2bbcode(editdoc.body.innerHTML) : editdoc.value;
}
function setEditorStyle() {
 if(wysiwyg) {
  textobj.style.display = 'none';
  editbox.style.display = '';
  editbox.className = textobj.className;
  if(editcss == null) {
   var cssarray = [editorcss, editorcss_editor];
   for(var i = 0; i < 2; i++) {
    editcss = editdoc.createElement('link');
    editcss.type = 'text/css';
    editcss.rel = 'stylesheet';
    editcss.href = cssarray;
    var headNode = editdoc.getElementsByTagName("head")[0];
    headNode.appendChild(editcss);
   }
  }
  if(is_moz || is_opera) {
   editbox.style.border = '0px';
  } else if(is_ie) {
   editdoc.body.style.border = '0px';
   editdoc.body.addBehavior('#default#userData');
  }
  editbox.style.width = textobj.style.width;
  editbox.style.height = textobj.style.height;
  editdoc.body.style.backgroundColor = TABLEBG;
  editdoc.body.style.textAlign = 'left';
  editdoc.body.id = 'wysiwyg';
 } else {
  var iframe = textobj.parentNode.getElementsByTagName('iframe')[0];
  if(iframe) {
   textobj.style.display = '';
   textobj.style.width = iframe.style.width;
   textobj.style.height = iframe.style.height;
   iframe.style.display = 'none';
  }
 }
}
function setEditorEvents() {
 if(wysiwyg) {
  if(is_moz || is_opera) {
   editwin.addEventListener('focus', function(e) {this.hasfocus = true;}, true);
   editwin.addEventListener('blur', function(e) {this.hasfocus = false;}, true);
   editwin.addEventListener('keydown', function(e) {ctlent(e);}, true);
  } else {
   if(editdoc.attachEvent) {
    editdoc.body.attachEvent("onkeydown", ctlent);
   }
  }
 }
 editwin.onfocus = function(e) {this.hasfocus = true;};
 editwin.onblur = function(e) {this.hasfocus = false;};
}
function insertTags(tagname, useoption, selection) {
 if(isUndefined(selection)) {
  var selection = getSel();
  if(selection === false) {
   selection = '';
  } else {
   selection += '';
  }
 }
 if(useoption !== false) {
  var opentag = '[' + tagname + '=' + useoption + ']';
 } else {
  var opentag = '[' + tagname + ']';
 }
 var closetag = '[/' + tagname + ']';
 var text = opentag + selection + closetag;
 insertText(text, strlen(opentag), strlen(closetag), in_array(tagname, ['code', 'quote',  'replyview']) ? true : false);
}
function applyFormat(cmd, dialog, argument) {
 if(wysiwyg) {
  editdoc.execCommand(cmd, (isUndefined(dialog) ? false : dialog), (isUndefined(argument) ? true : argument));
  return;
 }
 switch(cmd) {
  case 'superscript':
   insertTags('sup', false);
   break;
  case 'subscript':
   insertTags('sub', false);
   break;
  case 'backcolor':
   insertTags('backcolor', argument);
   break;
  case 'strikethrough':
   insertTags('strike', false);
   break;
  case 'inserthorizontalrule':
     insertText('
', 4, 0, false);
   break;
  case 'bold':
  case 'italic':
  case 'underline':
   insertTags(cmd.substr(0, 1), false);
   break;
  case 'justifyleft':
  case 'justifycenter':
  case 'justifyright':
   insertTags('align', cmd.substr(7));
   break;
  case 'indent':
   insertTags(cmd, false);
   break;
  case 'fontname':
   insertTags('font', argument);
   break;
  case 'fontsize':
   insertTags('size', argument);
   break;
  case 'forecolor':
   insertTags('color', argument);
   break;
  case 'createlink':
   var sel = getSel();
   if(sel) {
    insertTags('url', argument);
   } else {
    insertTags('url', argument, argument);
   }
   break;
  case 'insertimage':
   insertTags('img', false, argument);
   break;
 }
}
function getCaret() {
 if(wysiwyg) {
  var obj = editdoc.body;
  var s = document.selection.createRange();
  s.setEndPoint("StartToStart", obj.createTextRange());
  return s.text.replace(/\r?\n/g, ' ').length;
 } else {
  var obj = editbox;
  var wR = document.selection.createRange();
  obj.select();
  var aR = document.selection.createRange();
  wR.setEndPoint("StartToStart", aR);
  var len = wR.text.replace(/\r?\n/g, ' ').length;
  wR.collapse(false);
  wR.select();
  return len;
 }
}
function setCaret(pos) {
 var obj = wysiwyg ? editdoc.body : editbox;
 var r = obj.createTextRange();
 r.moveStart('character', pos);
 r.collapse(true);
 r.select();
}
// 插入连接
function insertlink(cmd) {
 var sel;
 if(is_ie) {
  sel = wysiwyg ? editdoc.selection.createRange() : document.selection.createRange();
  var pos = getCaret();
 }
 var selection = sel ? (wysiwyg ? sel.htmlText : sel.text) : getSel();
 var ctrlid = editorid + '_cmd_' + cmd;
 var tag = cmd == 'insertimage' ? 'img' : (cmd == 'createlink' ? 'url' : 'email');
 var str = (tag == 'img' ? '请输入图片链接地址:' : (tag == 'url' ? '请输入链接的地址:' : '请输入此链接的邮箱地址:')) + '
';
 var div = editorMenu(ctrlid, str);
 $(ctrlid + '_param_1').focus();
 $(ctrlid + '_param_1').onkeydown = editorMenuEvent_onkeydown;
 $(ctrlid + '_submit').onclick = function() {
  checkFocus();
  if(is_ie) {
   setCaret(pos);
  }
  var input = $(ctrlid + '_param_1').value;
  if(input != '') {
   var v = selection ? selection : input;
   var href = tag != 'email' && /^(www\.)/.test(input) ? 'http://' + input : input;
   var text = wysiwyg ? (tag == 'img' ? '' : '' + v + '') : (tag == 'img' ? '[' + tag + ']' + input + '[/' + tag + ']' : '[' + tag + '=' + href + ']' + v + '[/' + tag + ']');
   var closetaglen = tag == 'email' ? 8 : 6;
   if(wysiwyg) insertText(text, text.length - v.length, 0, (selection ? true : false), sel);
   else insertText(text, text.length - v.length - closetaglen, closetaglen, (selection ? true : false), sel);
  }
  hideMenu();
  div.parentNode.removeChild(div);
 }
}
// 插入表情
function insertSmiley(smilieid) {
 checkFocus();
 var src = $('smilie_' + smilieid).src;
 var code = $('smilie_' + smilieid).alt;
 if(typeof wysiwyg != 'undefined' && wysiwyg && allowsmilies && (!$('smileyoff') || $('smileyoff').checked == false)) {
  if(is_moz) {
   applyFormat('InsertImage', false, src);
   var smilies = editdoc.body.getElementsByTagName('img');
   for(var i = 0; i < smilies.length; i++) {
    if(smilies.src == src && smilies.getAttribute('smilieid') < 1) {
     smilies.setAttribute('smilieid', smilieid);
     smilies.setAttribute('border', "0");
    }
   }
  } else {
   insertText(' ', false);
  }
 } else {
  code += ' ';
  AddText(code);
 }
 hideMenu();
}
function editorMenuEvent_onkeydown(e) {
 e = e ? e : event;
 var ctrlid = this.id.substr(0, this.id.lastIndexOf('_param_'));
 if((this.type == 'text' && e.keyCode == 13) || (this.type == 'textarea' && e.ctrlKey && e.keyCode == 13)) {
  $(ctrlid + '_submit').click();
  doane(e);
 } else if(e.keyCode == 27) {
  hideMenu();
  $(ctrlid + '_menu').parentNode.removeChild($(ctrlid + '_menu'));
 }
}
function editorMenu(ctrlid, str) {
 var div = document.createElement('div');
 div.id = ctrlid + '_menu';
 div.style.display = 'none';
 div.className = 'popupmenu_popup popupfix';
 div.style.width = '300px';
 $(editorid + '_controls').appendChild(div);
 div.innerHTML = '
' + str + '
 
';
 InFloat = InFloat_Editor;
 showMenu(ctrlid, true, 0, 3);
 return div;
}
function ubbcode(cmd, arg) {
 if(cmd != 'redo') {
  addSnapshot(getEditorContents());
 }
 checkFocus();
 if(in_array(cmd, ['quote', 'code', 'replyview'])) {
  var sel;
  if(is_ie) {
   sel = wysiwyg ? editdoc.selection.createRange() : document.selection.createRange();
   var pos = getCaret();
  }
  var selection = sel ? (wysiwyg ? sel.htmlText : sel.text) : getSel();
  var opentag = '[' + cmd + ']';
  var closetag = '[/' + cmd + ']';
  if(cmd != 'replyview' && selection) {
   return insertText((opentag + selection + closetag), strlen(opentag), strlen(closetag), true, sel);
  }
  var ctrlid = editorid + '_cmd_' + cmd;
  var str = '';
  lang['e_quote'] = '请输入要插入的引用';
  lang['e_code'] = '请输入要插入的代码';
  lang['e_replyview'] = '请输入要插入的隐藏内容';
  if(cmd != 'replyview' || !selection) {
   str += lang['e_' + cmd] + ':
';
  }
  str += cmd == 'replyview' && selection ? '' : '
';
  str += cmd == 'replyview' ? '只有当浏览者回复本帖时才显示
只有当浏览者积分高于 时才显示
' : '';
  var div = editorMenu(ctrlid, str);
  $(ctrlid + '_param_' + (cmd == 'replyview' && selection ? 2 : 1)).focus();
  $(ctrlid + '_param_' + (cmd == 'replyview' && selection ? 2 : 1)).onkeydown = editorMenuEvent_onkeydown;
  $(ctrlid + '_submit').onclick = function() {
   checkFocus();
   if(is_ie) {
    setCaret(pos);
   }
   if(cmd == 'replyview' && $(ctrlid + '_radio_2').checked) {
    var mincredits = parseInt($(ctrlid + '_param_2').value);
    opentag = mincredits > 0 ? '[replyview=' + mincredits + ']' : '[replyview]';
   }
   var text = selection ? selection : $(ctrlid + '_param_1').value;
   if(wysiwyg) {
    if(cmd == 'code') {
     text = preg_replace(['<', '>'], ['<', '>'], text);
    }
    text = text.replace(/\r?\n/g, '
');
   }
   text = opentag + text + closetag;
   insertText(text, strlen(opentag), strlen(closetag), false, sel);
   hideMenu();
   div.parentNode.removeChild(div);
  }
  return;
 } else if(!wysiwyg && cmd == 'removeformat') {
  var simplestrip = new Array('b', 'i', 'u');
  var complexstrip = new Array('font', 'color', 'size');
  var str = getSel();
  if(str === false) {
   return;
  }
  for(var tag in simplestrip) {
   str = stripSimple(simplestrip[tag], str);
  }
  for(var tag in complexstrip) {
   str = stripComplex(complexstrip[tag], str);
  }
  insertText(str);
 } else if(cmd == 'undo') {
  addSnapshot(getEditorContents());
  moveCursor(-1);
  if((str = getSnapshot()) !== false) {
   if (wysiwyg){
   editdoc.body.innerHTML=str;
   }else{
   editdoc.value = str;
    }
  }
 } else if(cmd == 'redo') {
  moveCursor(1);
  if((str = getSnapshot()) !== false) {
   if (wysiwyg){
    editdoc.body.innerHTML=str;
   }else{
   editdoc.value = str;
   }
  }
 } else if(!wysiwyg && in_array(cmd, ['insertorderedlist', 'insertunorderedlist'])) {
  var listtype = cmd == 'insertorderedlist' ? '1' : '';
  var opentag = '[list' + (listtype ? ('=' + listtype) : '') + ']\n';
  var closetag = ' ';
  if(txt = getSel()) {
   var regex = new RegExp('([\r\n]+|^[\r\n]*)(?!\\[\\*\\]|\\[\\/?list)(?=[^\r\n])', 'gi');
   txt = opentag + trim(txt).replace(regex, '$1[*]') + '\n' + closetag;
   insertText(txt, strlen(txt), 0);
  } else {
   insertText(opentag + closetag, opentag.length, closetag.length);
   while(listvalue = prompt('输入一个列表项目.\r\n留空或者点击取消完成此列表.', '')) {
    if(is_opera > 8) {
     listvalue = '\n' + '[*]' + listvalue;
     insertText(listvalue, strlen(listvalue) + 1, 0);
    } else {
     listvalue = '[*]' + listvalue + '\n';
     insertText(listvalue, strlen(listvalue), 0);
    }
   }
  }
 } else if(!wysiwyg && cmd == 'outdent') {
  var sel = getSel();
  sel = stripSimple('indent', sel, 1);
  insertText(sel);
 } else if(cmd == 'createlink') {
  insertlink('createlink');
 } else if(!wysiwyg && cmd == 'unlink') {
  var sel = getSel();
  sel = stripSimple('url', sel);
  sel = stripComplex('url', sel);
  insertText(sel);
 } else if(cmd == 'email') {
  insertlink('email');
 } else if(cmd == 'insertimage') {
  insertlink('insertimage');
 } else if(cmd == 'table') {
  if(wysiwyg) {
   var selection = getSel();
   if(is_ie) {
    var pos = getCaret();
   }
   var ctrlid = editorid + '_cmd_table';
   var str = '

表格行数:   表格列数:

表格宽度:   背景颜色:

';
   var div = editorMenu(ctrlid, str);
   $(ctrlid + '_param_rows').focus();
   var params = ['rows', 'columns', 'width', 'bgcolor'];
   for(var i = 0; i < 4; i++) {$(ctrlid + '_param_' + params).onkeydown = editorMenuEvent_onkeydown;}
   $(ctrlid + '_submit').onclick = function() {
    var rows = $(ctrlid + '_param_rows').value;
    var columns = $(ctrlid + '_param_columns').value;
    var width = $(ctrlid + '_param_width').value;
    var bgcolor = $(ctrlid + '_param_bgcolor').value;
    rows = /^[-\+]?\d+$/.test(rows) && rows > 0 && rows <= 30 ? rows : 2;
    columns = /^[-\+]?\d+$/.test(columns) && columns > 0 && columns <= 30 ? columns : 2;
    width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%');
    bgcolor = /[\(\)%,#\w]+/.test(bgcolor) ? bgcolor : '';
    var html = '';
    for (var row = 0; row < rows; row++) {
     html += '\n';
     for (col = 0; col < columns; col++) {
      html += '\n';
     }
     html+= '\n';
    }
    html += '
 
\n';
    insertText(html);
    hideMenu();
    div.parentNode.removeChild(div);
   }
  }
  return false;
 } else if(cmd == 'loadData') {
  loadData();hideMenu();
 } else if(cmd == 'saveData') {
  autosaveData(2);
 } else if(cmd == 'autosave') {
  if(getcookie('disableautosave')) {
   autosaveData(1);
  } else {
   autosaveData(0);
  }
 } else if(cmd == 'checklength') {
  checklength($('postform'));hideMenu();
 } else if(cmd == 'clearcontent') {
  clearcontent();
 } else {
  try {
   var ret = applyFormat(cmd, false, (isUndefined(arg) ? true : arg));
  } catch(e) {
   var ret = false;
  }
 }
 if(cmd != 'undo') {
  addSnapshot(getEditorContents());
 }
 if(in_array(cmd, ['fontname', 'fontsize', 'forecolor','backcolor', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist',  'removeformat', 'unlink'])) {
  hideMenu();
 }
 return ret;
}
// 文本选择区域
function getSel() {
 if(wysiwyg) {
  if(is_moz || is_opera) {
   selection = editwin.getSelection();
   checkFocus();
   range = selection ? selection.getRangeAt(0) : editdoc.createRange();
   return readNodes(range.cloneContents(), false);
  } else {
   var range = editdoc.selection.createRange();
   if(range.htmlText && range.text) {
    return range.htmlText;
   } else {
    var htmltext = '';
    for(var i = 0; i < range.length; i++) {
     htmltext += range.item(i).outerHTML;
    }
    return htmltext;
   }
  }
 } else {
  if(!isUndefined(editdoc.selectionStart)) {
   return editdoc.value.substr(editdoc.selectionStart, editdoc.selectionEnd - editdoc.selectionStart);
  } else if(document.selection && document.selection.createRange) {
   return document.selection.createRange().text;
  } else if(window.getSelection) {
   return window.getSelection() + '';
  } else {
   return false;
  }
 }
}
function insertText(text, movestart, moveend, select, sel) {
 if(wysiwyg) {
  if(is_moz || is_opera) {
   applyFormat('removeformat');
   var fragment = editdoc.createDocumentFragment();
   var holder = editdoc.createElement('span');
   holder.innerHTML = text;
   while(holder.firstChild) {
    fragment.appendChild(holder.firstChild);
   }
   insertNodeAtSelection(fragment);
  } else {
   checkFocus();
   if(!isUndefined(editdoc.selection) && editdoc.selection.type != 'Text' && editdoc.selection.type != 'None') {
    movestart = false;
    editdoc.selection.clear();
   }
   if(isUndefined(sel)) {
    sel = editdoc.selection.createRange();
   }
   sel.pasteHTML(text);
   if(text.indexOf('\n') == -1) {
    if(!isUndefined(movestart)) {
     sel.moveStart('character', -strlen(text) + movestart);
     sel.moveEnd('character', -moveend);
    } else if(movestart != false) {
     sel.moveStart('character', -strlen(text));
    }
    if(!isUndefined(select) && select) {
     sel.select();
    }
   }
  }
 } else {
  checkFocus();
  if(!isUndefined(editdoc.selectionStart)) {
   var opn = editdoc.selectionStart + 0;
   editdoc.value = editdoc.value.substr(0, editdoc.selectionStart) + text + editdoc.value.substr(editdoc.selectionEnd);
   if(!isUndefined(movestart)) {
    editdoc.selectionStart = opn + movestart;
    editdoc.selectionEnd = opn + strlen(text) - moveend;
   } else if(movestart !== false) {
    editdoc.selectionStart = opn;
    editdoc.selectionEnd = opn + strlen(text);
   }
  } else if(document.selection && document.selection.createRange) {
   if(isUndefined(sel)) {
    sel = document.selection.createRange();
   }
   sel.text = text.replace(/\r?\n/g, '\r\n');
   if(!isUndefined(movestart)) {
    sel.moveStart('character', -strlen(text) +movestart);
    sel.moveEnd('character', -moveend);
   } else if(movestart !== false) {
    sel.moveStart('character', -strlen(text));
   }
   sel.select();
  } else {
   editdoc.value += text;
  }
 }
}
function stripSimple(tag, str, iterations) {
 var opentag = '[' + tag + ']';
 var closetag = '[/' + tag + ']';
 if(isUndefined(iterations)) {
  iterations = -1;
 }
 while((startindex = stripos(str, opentag)) !== false && iterations != 0) {
  iterations --;
  if((stopindex = stripos(str, closetag)) !== false) {
   var text = str.substr(startindex + opentag.length, stopindex - startindex - opentag.length);
   str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length);
  } else {
   break;
  }
 }
 return str;
}
function stripComplex(tag, str, iterations) {
 var opentag = '[' + tag + '=';
 var closetag = '[/' + tag + ']';
 if(isUndefined(iterations)) {
  iterations = -1;
 }
 while((startindex = stripos(str, opentag)) !== false && iterations != 0) {
  iterations --;
  if((stopindex = stripos(str, closetag)) !== false) {
   var openend = stripos(str, ']', startindex);
   if(openend !== false && openend > startindex && openend < stopindex) {
    var text = str.substr(openend + 1, stopindex - openend - 1);
    str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length);
   } else {
    break;
   }
  } else {
   break;
  }
 }
 return str;
}
function stripos(haystack, needle, offset) {
 if(isUndefined(offset)) {
  offset = 0;
 }
 var index = haystack.toLowerCase().indexOf(needle.toLowerCase(), offset);
 return (index == -1 ? false : index);
}
// 切换编辑器模式
function switchEditor(mode) {
 mode = parseInt(mode);
 if(mode == wysiwyg || !allowswitcheditor)  {
  return;
 }
 
 if(!mode) {
  var controlbar = $(editorid + '_controls');
  var controls = new Array();
  var buttons = controlbar.getElementsByTagName('a');
  var buttonslength = buttons.length;
  for(var i = 0; i < buttonslength; i++) {
   if(buttons.id) {
    controls[controls.length] = buttons.id;
   }
  }
  var controlslength = controls.length;
  for(var i = 0; i < controlslength; i++) {
   var control = $(controls);
   if(control.id.indexOf(editorid + '_cmd_') != -1) {
    control.className = control.id.indexOf(editorid + '_cmd_custom') == -1 ? '' : 'plugeditor';
    control.state = false;
    control.mode = 'normal';
   } else if(control.id.indexOf(editorid + '_popup_') != -1) {
    control.state = false;
   }
  }
 }
 cursor = -1;
 stack = new Array();
 var parsedtext = getEditorContents();
 parsedtext = mode ? bbcode2html(parsedtext) : html2bbcode(parsedtext);
 wysiwyg = mode;
 $(editorid + '_mode').value = mode;
 newEditor(mode, parsedtext);
 editwin.focus();
 setCaretAtEnd();
}
function insertNodeAtSelection(text) {
 checkFocus();
 var sel = editwin.getSelection();
 var range = sel ? sel.getRangeAt(0) : editdoc.createRange();
 sel.removeAllRanges();
 range.deleteContents();
 var node = range.startContainer;
 var pos = range.startOffset;
 switch(node.nodeType) {
  case Node.ELEMENT_NODE:
   if(text.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
    selNode = text.firstChild;
   } else {
    selNode = text;
   }
   node.insertBefore(text, node.childNodes[pos]);
   add_range(selNode);
   break;
  case Node.TEXT_NODE:
   if(text.nodeType == Node.TEXT_NODE) {
    var text_length = pos + text.length;
    node.insertData(pos, text.data);
    range = editdoc.createRange();
    range.setEnd(node, text_length);
    range.setStart(node, text_length);
    sel.addRange(range);
   } else {
    node = node.splitText(pos);
    var selNode;
    if(text.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
     selNode = text.firstChild;
    } else {
     selNode = text;
    }
    node.parentNode.insertBefore(text, node);
    add_range(selNode);
   }
   break;
 }
}
function add_range(node) {
 checkFocus();
 var sel = editwin.getSelection();
 var range = editdoc.createRange();
 range.selectNodeContents(node);
 sel.removeAllRanges();
 sel.addRange(range);
}
function readNodes(root, toptag) {
 var html = "";
 var moz_check = /_moz/i;
 switch(root.nodeType) {
  case Node.ELEMENT_NODE:
  case Node.DOCUMENT_FRAGMENT_NODE:
   var closed;
   if(toptag) {
    closed = !root.hasChildNodes();
    html = '<' + root.tagName.toLowerCase();
    var attr = root.attributes;
    for(var i = 0; i < attr.length; ++i) {
     var a = attr.item(i);
     if(!a.specified || a.name.match(moz_check) || a.value.match(moz_check)) {
      continue;
     }
     html += " " + a.name.toLowerCase() + '="' + a.value + '"';
    }
    html += closed ? " />" : ">";
   }
   for(var i = root.firstChild; i; i = i.nextSibling) {
    html += readNodes(i, true);
   }
   if(toptag && !closed) {
    html += "";
   }
   break;
  case Node.TEXT_NODE:
   html = htmlspecialchars(root.data);
   break;
 }
 return html;
}
function moveCursor(increment) {
 var test = cursor + increment;
 if(test >= 0 && stack[test] != null && !isUndefined(stack[test])) {
  cursor += increment;
 }
}
function addSnapshot(str) {
 if(stack[cursor] == str) {
  return;
 } else {
  cursor++;
  stack[cursor] = str;
  if(!isUndefined(stack[cursor + 1])) {
   stack[cursor + 1] = null;
  }
 }
}
function getSnapshot() {
 if(!isUndefined(stack[cursor]) && stack[cursor] != null) {
  return stack[cursor];
 } else {
  return false;
 }
}
// 插入media类型标签
function setmediacode(editorid) {
 insertText('[media='+$(editorid + '_mediatype').value+
  ','+$(editorid + '_mediawidth').value+
  ','+$(editorid + '_mediaheight').value+
  ','+$(editorid + '_mediaautostart').value+']'+
  $(editorid + '_mediaurl').value+'[/media]');
 hideMenu();
}
// 自动判断URL中media类型
function setmediatype(editorid) {
 var ext = $(editorid + '_mediaurl').value.lastIndexOf('.') == -1 ? '' : $(editorid + '_mediaurl').value.substr($(editorid + '_mediaurl').value.lastIndexOf('.') + 1, $(editorid + '_mediaurl').value.length).toLowerCase();
 if(ext == 'rmvb') {
  ext = 'rm';
 }
 if($(editorid + '_mediatyperadio_' + ext)) {
  $(editorid + '_mediatyperadio_' + ext).checked = true;
  $(editorid + '_mediatype').value = ext;
 }
}
// 清空编辑器内容
function clearcontent() {
 if (confirm('确定清空编辑器内容吗?')){
 if(wysiwyg) {
  editdoc.body.innerHTML = is_moz ? '
' : '';
 } else {
  textobj.value = '';
 }}
}
openEditor();

//UBB切换代码
var re;
if(isUndefined(codecount)) var codecount = '-1';
if(isUndefined(codehtml)) var codehtml = new Array();
function addslashes(str) {
 return preg_replace(['\\\\', '\\\'', '\\\/', '\\\(', '\\\)', '\\\[', '\\\]', '\\\{', '\\\}', '\\\^', '\\\$', '\\\?', '\\\.', '\\\*', '\\\+', '\\\|'], ['\\\\', '\\\'', '\\/', '\\(', '\\)', '\\[', '\\]', '\\{', '\\}', '\\^', '\\$', '\\?', '\\.', '\\*', '\\+', '\\|'], str);
}
function atag(aoptions, text) {
 if(trim(text) == '') {
  return '';
 }
 href = getoptionvalue('href', aoptions);
 if(href.substr(0, 11) == 'javascript:') {
  return trim(recursion('a', text, 'atag'));
 } else if(href.substr(0, 7) == 'mailto:') {
  tag = 'email';
  href = href.substr(7);
  return (href);
 } else {
  tag = 'url';
 }
 return '[' + tag + '=' + href + ']' + trim(recursion('a', text, 'atag')) + '[/' + tag + ']';
}
function bbcode2html(str) {
 str = trim(str);
 if(str == '') {
  return '';
 }
 if(allowbbcode) {
  str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return parsecode($2);});
 }
 if(!forumallowhtml && !allowhtml) {
  str = str.replace(/  str = str.replace(/>/g, '>');
  str = parseurl(str, 'html', false);
 }
 if(allowsmilies) {
  for(id in smilies) {
   re = new RegExp(addslashes(smilies[id]['code']), "g");
   str = str.replace(re, '' + smilies[id]['code'] + '');
  }
 }
 if(allowbbcode) {
  str = str.replace(/\[hr\]/ig,'
');
  str= str.replace(/\[url\]\s*([url=http://www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|bctp:\/\/|ed2k:\/\/){1}([^\[\]www.|https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|bctp:\/\/|ed2k:\/\/){1}([^\[\"']+?)\s*\[\/url\]/ig[/url], function($1, $2, $3) {return cuturl($2 + $3);});
  str= str.replace(/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/ig, 'http://www.$1" target="_blank">$2');
  str= str.replace(/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k){1}:\/\/([^\[\"']+?)\]([\s\S]+?)\[\/url\]/ig, '$3');
  //str= str.replace(/\[email\](.*?)\[\/email\]/ig, 'mailto:$1">$1');
  //str= str.replace(/\[email=(.[^\[]*)\](.*?)\[\/email\]/ig, '$2');
  str = str.replace(/\[color=([^\[\<]+?)\]/ig, '');
  str = str.replace(/\[backcolor=([^\[\<]+?)\]/ig, '');
  str = str.replace(/\[size=(\d+?)\]/ig, '');
  str = str.replace(/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/ig, '');
  str = str.replace(/\[font=([^\[\<]+?)\]/ig, '');
  str = str.replace(/\[align=([^\[\<]+?)\]/ig, '

');
  str = str.replace(/\[float=([^\[\<]+?)\]/ig, '
');
  re = /\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*([\s\S]+?)\s*\[\/table\]/ig;
  for (i = 0; i < 4; i++) {
   str = str.replace(re, function($1, $2, $3, $4) {return parsetable($2, $3, $4);});
  }
  str = preg_replace([
   '\\\[\\\/backcolor\\\]','\\\[\\\/color\\\]', '\\\[\\\/size\\\]', '\\\[\\\/font\\\]', '\\\[\\\/align\\\]', '\\\[b\\\]', '\\\[\\\/b\\\]',
   '\\\[i\\\]', '\\\[\\\/i\\\]','\\\[strike\\\]','\\\[\\\/strike\\\]','\\\[sup\\\]','\\\[\\\/sup\\\]','\\\[sub\\\]','\\\[\\\/sub\\\]', '\\\[u\\\]', '\\\[\\\/u\\\]', '\\\[list\\\]', '\\\[list=1\\\]', '\\\[list=a\\\]',
   '\\\[list=A\\\]', '\\\[\\\*\\\]', '\\\[\\\/list\\\]', '\\\[indent\\\]', '\\\[\\\/indent\\\]', '\\\[\\\/float\\\]'
   ], [
   '
','
', '
', '
', '

', '', '', '',
   '
','','','','','','', '', '', '
    ', '
      ', '
        ',
           '
          ', '
        • ', '
        ', '
        ', '
        ', ''
           ], str);
         }

         if(allowimgcode) {
          str = str.replace(/\[localimg=(\d{1,4}),(\d{1,4})\](\d+)\[\/localimg\]/ig, function ($1, $2, $3, $4) {if($('attach_' + $4)) {var src = $('attach_' + $4).value; if(src != '') return '';}});
          str = str.replace(/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '');
          str = str.replace(/\[attachimg\](\d+)\[\/attachimg\]/ig, function ($1, $2) {eval('var attachimg = $(\'preview_' + $2 + '\')');width = is_ie ? parseInt(attachimg.currentStyle.width) : attachimg.width;return '';});
          str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '');
         } else {
          str = str.replace(/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '$1');
          str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '$1');
         }
         for(var i = 0; i <= codecount; i++) {
          str = str.replace("[\tUBB_CODE_" + i + "\t]", codehtml);
         }
         if(!forumallowhtml && !allowhtml) {
          str = preg_replace(['\t', '   ', '  ', '(\r\n|\n|\r)'], ['        ', '   ', '  ', '
        '], str);
         }
         return str;
        }
        function cuturl(url) {
         var length = 65;
         var urllink = '';
         if(url.length > length) {
          url = url.substr(0, parseInt(length * 0.5)) + ' ... ' + url.substr(url.length - parseInt(length * 0.3));
         }
         urllink += url + '
        ';
         return urllink;
        }
        function dpstag(options, text, tagname) {
         if(trim(text) == '') {
          return '\n';
         }
         var pend = parsestyle(options, '', '');
         var prepend = pend['prepend'];
         var append = pend['append'];
         if(in_array(tagname, ['div', 'p'])) {
          align = getoptionvalue('align', options);
          if(in_array(align, ['left', 'center', 'right'])) {
           prepend = '[align=' + align + ']' + prepend;
           append += '
        ';
          } else {
           append += '\n';
          }
         }
         return prepend + recursion(tagname, text, 'dpstag') + append;
        }
        function fetchoptionvalue(option, text) {
         if((position = strpos(text, option)) !== false) {
          delimiter = position + option.length;
          if(text.charAt(delimiter) == '"') {
           delimchar = '"';
          } else if(text.charAt(delimiter) == '\'') {
           delimchar = '\'';
          } else {
           delimchar = ' ';
          }
          delimloc = strpos(text, delimchar, delimiter + 1);
          if(delimloc === false) {
           delimloc = text.length;
          } else if(delimchar == '"' || delimchar == '\'') {
           delimiter++;
          }
          return trim(text.substr(delimiter, delimloc - delimiter));
         } else {
          return '';
         }
        }
        function fonttag(fontoptions, text) {
         var prepend = '';
         var append = '';
         var tags = new Array();
         tags = {'font' : 'face=', 'size' : 'size=', 'color' : 'color=','backcolor':'backcolor='};
         for(bbcode in tags) {
          optionvalue = fetchoptionvalue(tags[bbcode], fontoptions);
          if(optionvalue) {
           prepend += '[' + bbcode + '=' + optionvalue + ']';
           append = '[/' + bbcode + ']' + append;
          }
         }
         var pend = parsestyle(fontoptions, prepend, append);
         return pend['prepend'] + recursion('font', text, 'fonttag') + pend['append'];
        }
        function getoptionvalue(option, text) {
         re = new RegExp(option + "(\s+?)?\=(\s+?)?[\"']?(.+?)([\"']|$|>)", "ig");
         var matches = re.exec(text);
         if(matches != null) {
          return trim(matches[3]);
         }
         return '';
        }
        function html2bbcode(str) {
         if(forumallowhtml || allowhtml || trim(str) == '') {
          str = str.replace(/]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smilies[$3]['code'];});
          str = str.replace(/]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);});
          return str;
         }
         str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return codetag($2);});
         str = preg_replace(['[\\\s\\\S]*?<\/style>', '[\\\s\\\S]*?<\/script>', '[\\\s\\\S]*?<\/noscript>', '[\s\S]*?<\/select>', '[\s\S]*?<\/object>', '', ' on[a-zA-Z]{3,16}\\\s?=\\\s?"[\\\s\\\S]*?"'], '', str);
         str= str.replace(/(\r\n|\n|\r)/ig, '');
         str= trim(str.replace(/&((#(32|127|160|173))|shy|nbsp);/ig, ' '));
         str = parseurl(str, 'bbcode', false);
         str = str.replace(/]*>/ig, '');
         str = str.replace(/]*>/ig, "\n");
         if(allowbbcode) {
          str = preg_replace([']*(width|background|background-color|bgcolor)[^>]*)>', ']*>', ']*(?:background|background-color|bgcolor)[:=]\\\s*(["\']?)([\(\)%,#\\\w]+)([url=file://\\1)[^>]*>]\\1)[^>]*>'[/url], ']*>', ']*(width|colspan|rowspan)[^>]*)>', ']*>', '<\/t[dh]>', '<\/tr>', '<\/table>'], [function($1, $2) {return tabletag($2);}, ' ', function($1, $2, $3) {return '[tr=' + $3 + ']';}, ' ', '
        ', function($1, $2) {return tdtag($2);}, ' [td]', '[/td]', '
        '], str);
          str = str.replace(/]*>(.*)<\/h\\1>/ig, "[size=$1]$2\n\n");
          str = str.replace(/]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smilies[$3]['code'];});
          str = str.replace(/]*src[^>]*)>/ig, function($1, $2) {return imgtag($2);});
          str = str.replace(/([\s\S]*?)<\/a>/ig, '$4');
          str = str.replace(/]*>/ig,'
        ');
          str = recursion('b', str, 'simpletag', 'b');
          str = recursion('strong', str, 'simpletag', 'b');
          str = recursion('i', str, 'simpletag', 'i');
          str = recursion('em', str, 'simpletag', 'i');
          str = recursion('u', str, 'simpletag', 'u');
          str = recursion('strike', str, 'simpletag', 'strike');
          str = recursion('sup', str, 'simpletag', 'sup');
          str = recursion('sub', str, 'simpletag', 'sub');
          str = recursion('a', str, 'atag');
          str = recursion('font', str, 'fonttag');
          str = recursion('blockquote', str, 'simpletag', 'indent');
          str = recursion('ol', str, 'listtag');
          str = recursion('ul', str, 'listtag');
          str = recursion('div', str, 'dpstag');
          str = recursion('p', str, 'dpstag');
          str = recursion('span', str, 'dpstag');
         }
         str = str.replace(/<[\/\!]*?[^<>]*?>/ig, '');
         for(var i = 0; i <= codecount; i++) {
          str = str.replace("[\tUBB_CODE_" + i + "\t]", codehtml);
         }
         return preg_replace([' ', '<', '>', '&'], [' ', '<', '>', '&'], str);
        }
        function htmlspecialchars(str) {
         return preg_replace(['&', '<', '>', '"'], ['&', '<', '>', '"'], str);
        }
        function imgtag(attributes) {
         var width = '';
         var height = '';
         re = /src=(["']?)([\s\S]*?)(\1)/i;
         var matches = re.exec(attributes);
         if(matches != null) {
          var src = matches[2];
         } else {
          return '';
         }
         re = /width\s?:\s?(\d{1,4})(px)?/ig;
         var matches = re.exec(attributes);
         if(matches != null) {
          width = matches[1];
         }
         re = /height\s?:\s?(\d{1,4})(px)?/ig;
         var matches = re.exec(attributes);
         if(matches != null) {
          height = matches[1];
         }
         if(!width || !height) {
          re = /width=(["']?)(\d+)(\1)/i;
          var matches = re.exec(attributes);
          if(matches != null) {
           width = matches[2];
          }
          re = /height=(["']?)(\d+)(\1)/i;
          var matches = re.exec(attributes);
          if(matches != null) {
           height = matches[2];
          }
         }
         re = /aid=(["']?)attach_(\d+)(\1)/i;
         var matches = re.exec(attributes);
         var imgtag = 'img';
         if(matches != null) {
          imgtag = 'localimg';
          src = matches[2];
         }
         re = /aid=(["']?)attachimg_(\d+)(\1)/i;
         var matches = re.exec(attributes);
         if(matches != null) {
          return '[attachimg]' + matches[2] + '[/attachimg]';
         }
         return width > 0 && height > 0 ?
          '[' + imgtag + '=' + width + ',' + height + ']' + src + '[/' + imgtag + ']' :
          '';
        }
        function listtag(listoptions, text, tagname) {
         text = text.replace(/
      • (([\s\S](?!<\/li))*?)(?=<\/?ol|<\/?ul|$1
      • ') + (is_opera ? '' : '');
         text = recursion('li', text, 'litag');
         var opentag = '
          ';
           var listtype = fetchoptionvalue('type=', listoptions);
           listtype = listtype != '' ? listtype : (tagname == 'ol' ? '1' : '');
           if(in_array(listtype, ['1', 'a', 'A'])) {
            opentag = '[list=' + listtype + ']';
           }
           return text ? opentag + recursion(tagname, text, 'listtag') + '
        ' : '';
        }
        function litag(listoptions, text) {
         return '[*]' + text.replace(/(\s+)$/g, '');
        }
        function parsecode(text) {
         codecount++;
         codehtml[codecount] = '
        كودنى نۇسخىلاش
        1. ' + htmlspecialchars(text) + '
        ';
         return "[\tUBB_CODE_" + codecount + "\t]";
        }
        function parsestyle(tagoptions, prepend, append) {
         var searchlist = [
          ['align', true, 'text-align:\\s*(left|center|right);?', 1],
          ['float', true, 'float:\\s*(left|right);?', 1],
          ['color', true, '^(?:\\s|)color:\\s*([^;]+);?', 1],
          ['backcolor', true, '^(?:\\s|)background-color:\\s*([^;]+);?', 1],
          ['font', true, 'font-family:\\s*([^;]+);?', 1],
          ['size', true, 'font-size:\\s*([url=file://d+(//.//d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?]\\d+(\\.\\d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?'[/url], 1],
          ['b', false, 'font-weight:\\s*(bold);?'],
          ['i', false, 'font-style:\\s*(italic);?'],
          ['u', false, 'text-decoration:\\s*(underline);?']
         ];
         var style = getoptionvalue('style', tagoptions);
         re = /^(?:\s|)color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)/ig;
         style = style.replace(re, function($1, $2, $3, $4, $5) {return("color:#" + parseInt($2).toString(16) + parseInt($3).toString(16) + parseInt($4).toString(16) + $5);});
         var len = searchlist.length;
         for(var i = 0; i < len; i++) {
          re = new RegExp(searchlist[2], "ig");
          match = re.exec(style);
          if(match != null) {
           opnvalue = match[searchlist[3]];
           prepend += '[' + searchlist[0] + (searchlist[1] == true ? '=' + opnvalue + ']' : ']');
           append = '[/' + searchlist[0] + ']' + append;
          }
         }
         return {'prepend' : prepend, 'append' : append};
        }
        function parsetable(width, bgcolor, str) {
         if(isUndefined(width)) {
          var width = '';
         } else {
          width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%');
         }
         str = str.replace(/\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4, $5) {
          return '';
         });
         str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4) {
          return '
' + str + '
';
}
function preg_replace(search, replace, str) {
 var len = search.length;
 for(var i = 0; i < len; i++) {
  re = new RegExp(search, "ig");
  str = str.replace(re, typeof replace == 'string' ? replace : (replace ? replace : replace[0]));
 }
 return str;
}
function recursion(tagname, text, dofunction, extraargs) {
 if(extraargs == null) {
  extraargs = '';
 }
 tagname = tagname.toLowerCase();
 var open_tag = '<' + tagname;
 var open_tag_len = open_tag.length;
 var close_tag = '';
 var close_tag_len = close_tag.length;
 var beginsearchpos = 0;
 do {
  var textlower = text.toLowerCase();
  var tagbegin = textlower.indexOf(open_tag, beginsearchpos);
  if(tagbegin == -1) {
   break;
  }
  var strlen = text.length;
  var inquote = '';
  var found = false;
  var tagnameend = false;
  var optionend = 0;
  var t_char = '';
  for(optionend = tagbegin; optionend <= strlen; optionend++) {
   t_char = text.charAt(optionend);
   if((t_char == '"' || t_char == "'") && inquote == '') {
    inquote = t_char;
   } else if((t_char == '"' || t_char == "'") && inquote == t_char) {
    inquote = '';
   } else if(t_char == '>' && !inquote) {
    found = true;
    break;
   } else if((t_char == '=' || t_char == ' ') && !tagnameend) {
    tagnameend = optionend;
   }
  }
  if(!found) {
   break;
  }
  if(!tagnameend) {
   tagnameend = optionend;
  }
  var offset = optionend - (tagbegin + open_tag_len);
  var tagoptions = text.substr(tagbegin + open_tag_len, offset)
  var acttagname = textlower.substr(tagbegin * 1 + 1, tagnameend - tagbegin - 1);
  if(acttagname != tagname) {
   beginsearchpos = optionend;
   continue;
  }
  var tagend = textlower.indexOf(close_tag, optionend);
  if(tagend == -1) {
   break;
  }
  var nestedopenpos = textlower.indexOf(open_tag, optionend);
  while(nestedopenpos != -1 && tagend != -1) {
   if(nestedopenpos > tagend) {
    break;
   }
   tagend = textlower.indexOf(close_tag, tagend + close_tag_len);
   nestedopenpos = textlower.indexOf(open_tag, nestedopenpos + open_tag_len);
  }
  if(tagend == -1) {
   beginsearchpos = optionend;
   continue;
  }
  var localbegin = optionend + 1;
  var localtext = eval(dofunction)(tagoptions, text.substr(localbegin, tagend - localbegin), tagname, extraargs);
  text = text.substring(0, tagbegin) + localtext + text.substring(tagend + close_tag_len);
  beginsearchpos = tagbegin + localtext.length;
 } while(tagbegin != -1);
 return text;
}
function simpletag(options, text, tagname, parseto) {
 if(trim(text) == '') {
  return '';
 }
 text = recursion(tagname, text, 'simpletag', parseto);
 return '[' + parseto + ']' + text + '[/' + parseto + ']';
}
function strpos(haystack, needle, offset) {
 if(isUndefined(offset)) {
  offset = 0;
 }
 index = haystack.toLowerCase().indexOf(needle.toLowerCase(), offset);
 return index == -1 ? false : index;
}
function tabletag(attributes) {
 var width = '';
 re = /width=(["']?)(\d{1,4}%?)(\1)/i;
 var matches = re.exec(attributes);
 if(matches != null) {
  width = matches[2].substr(matches[2].length - 1, matches[2].length) == '%' ?
   (matches[2].substr(0, matches[2].length - 1) <= 98 ? matches[2] : '98%') :
   (matches[2] <= 560 ? matches[2] : '98%');
 } else {
  re = /width\s?:\s?(\d{1,4})([px|%])/ig;
  var matches = re.exec(attributes);
  if(matches != null) {
   width = matches[2] == '%' ? (matches[1] <= 98 ? matches[1] : '98%') : (matches[1] <= 560 ? matches[1] : '98%');
  }
 }
 var bgcolor = '';
 re = /(?:background|background-color|bgcolor)[:=]\s*(["']?)((rgb\(\d{1,3}%?,\s*\d{1,3}%?,\s*\d{1,3}%?\))|(#[0-9a-fA-F]{3,6})|([a-zA-Z]{1,20}))(\1)/i;
 var matches = re.exec(attributes);
 if(matches != null) {
  bgcolor = matches[2];
  width = width ? width : '98%';
 }
 return bgcolor ? '[table=' + width + ',' + bgcolor + ']' : (width ? '[table=' + width + ']' : '[table]');
}
function tdtag(attributes) {
 var colspan = 1;
 var rowspan = 1;
 var width = '';
 re = /colspan=(["']?)(\d{1,2})(\1)/ig;
 var matches = re.exec(attributes);
 if(matches != null) {
  colspan = matches[2];
 }
 re = /rowspan=(["']?)(\d{1,2})(\1)/ig;
 var matches = re.exec(attributes);
 if(matches != null) {
  rowspan = matches[2];
 }
 re = /width=(["']?)(\d{1,4}%?)(\1)/ig;
 var matches = re.exec(attributes);
 if(matches != null) {
  width = matches[2];
 }
 return in_array(width, ['', '0', '100%']) ?
  (colspan == 1 && rowspan == 1 ? '[td]' : '[td=' + colspan + ',' + rowspan + ']') :
  '[td=' + colspan + ',' + rowspan + ',' + width + ']';
}
[/code]


تېما تەستىقلىغۇچى:ئوغلان
ئالدىنقى تېماكىيىنكى تېما
 كەڭ ساي مۇنازىرە مۇنبىرى » كومپىيوتېر تور بىلىملىرى