/* [Discuz!] (C)2001-2099 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: bbcode.js 36348 2017-01-13 06:36:44Z nemohou $ */ var re, DISCUZCODE = []; DISCUZCODE['num'] = '-1'; DISCUZCODE['html'] = []; EXTRAFUNC['bbcode2html'] = []; EXTRAFUNC['html2bbcode'] = []; function addslashes(str) { return preg_replace(['\\\\', '\\\'', '\\\/', '\\\(', '\\\)', '\\\[', '\\\]', '\\\{', '\\\}', '\\\^', '\\\$', '\\\?', '\\\.', '\\\*', '\\\+', '\\\|'], ['\\\\', '\\\'', '\\/', '\\(', '\\)', '\\[', '\\]', '\\{', '\\}', '\\^', '\\$', '\\?', '\\.', '\\*', '\\+', '\\|'], str); } function atag(aoptions, text) { if(trim(text) == '') { return ''; } var pend = parsestyle(aoptions, '', ''); href = getoptionvalue('href', aoptions); if(href.substr(0, 11) == 'javascript:') { return trim(recursion('a', text, 'atag')); } return pend['prepend'] + '[url=' + href + ']' + trim(recursion('a', text, 'atag')) + '[/url]' + pend['append']; } function bbcode2html(str) { if(str == '') { return ''; } if(typeof(parsetype) == 'undefined') { parsetype = 0; } if(!fetchCheckbox('bbcodeoff') && allowbbcode && parsetype != 1) { str = str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function($1, $2) {return parsecode($2);}); } if(fetchCheckbox('allowimgurl')) { 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, '$1[img]$2[/img]'); } if(!allowhtml || !fetchCheckbox('htmlon')) { str = str.replace(//g, '>'); if(!fetchCheckbox('parseurloff')) { str = parseurl(str, 'html', false); } } for(i in EXTRAFUNC['bbcode2html']) { EXTRASTR = str; try { eval('str = ' + EXTRAFUNC['bbcode2html'][i] + '()'); } catch(e) {} } if(!fetchCheckbox('smileyoff') && allowsmilies) { if(typeof smilies_type == 'object') { for(var typeid in smilies_array) { for(var page in smilies_array[typeid]) { for(var i in smilies_array[typeid][page]) { re = new RegExp(preg_quote(smilies_array[typeid][page][i][1]), "g"); str = str.replace(re, '' + smilies_array[typeid][page][i][1] + ''); } } } } } if(!fetchCheckbox('bbcodeoff') && allowbbcode) { str = clearcode(str); str = str.replace(/\[url\]\s*((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)([^\[\"']+?)\s*\[\/url\]/ig, function($1, $2, $3, $4) {return cuturl($2 + $4);}); str = str.replace(/\[url=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:)?([^\r\n\[\"']+?)\]([\s\S]+?)\[\/url\]/ig, '$4'); str = str.replace(/\[email\](.[^\\=[]*)\[\/email\]/ig, '$1'); str = str.replace(/\[email=(.[^\\=[]*)\](.*?)\[\/email\]/ig, '$2'); str = str.replace(/\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]/ig, function($1, $2) { addCSS = ''; if(in_array($2, postimg_type["postbg"])) { addCSS = ''; } return addCSS; }); str = str.replace(/\[color=([\w#\(\),\s]+?)\]/ig, ''); str = str.replace(/\[backcolor=([\w#\(\),\s]+?)\]/ig, ''); str = str.replace(/\[size=(\d+?)\]/ig, ''); str = str.replace(/\[size=(\d+(\.\d+)?(px|pt)+?)\]/ig, ''); str = str.replace(/\[font=([^\[\<\=]+?)\]/ig, ''); str = str.replace(/\[align=([^\[\<\=]+?)\]/ig, '
'); str = str.replace(/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/ig, '

'); str = str.replace(/\[float=left\]/ig, '
'); str = str.replace(/\[float=right\]/ig, '
'); if(parsetype != 1) { str = str.replace(/\[quote]([\s\S]*?)\[\/quote\]\s?\s?/ig, '

$1
\n'); } 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([ '\\\[\\\/color\\\]', '\\\[\\\/backcolor\\\]', '\\\[\\\/size\\\]', '\\\[\\\/font\\\]', '\\\[\\\/align\\\]', '\\\[\\\/p\\\]', '\\\[b\\\]', '\\\[\\\/b\\\]', '\\\[i\\\]', '\\\[\\\/i\\\]', '\\\[u\\\]', '\\\[\\\/u\\\]', '\\\[s\\\]', '\\\[\\\/s\\\]', '\\\[hr\\\]', '\\\[list\\\]', '\\\[list=1\\\]', '\\\[list=a\\\]', '\\\[list=A\\\]', '\\s?\\\[\\\*\\\]', '\\\[\\\/list\\\]', '\\\[indent\\\]', '\\\[\\\/indent\\\]', '\\\[\\\/float\\\]' ], [ '
', '
', '
', '
', '
', '

', '', '', '', '', '', '', '', '', '
', '