📄 post.js
字号:
return text ? opentag + recursion(tagname, text, 'listtag') + '[/list]' : '';
}
function litag(listoptions, text) {
return '[*]' + text.replace(/(\s+)$/g, '');
}
function parsecode(text) {
codecount++;
codehtml[codecount] = '[code]' + htmlspecialchars(text) + '[/code]';
return "[\tBB_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],
['font', true, 'font-family:\\s*([^;]+);?', 1],
['size', true, 'font-size:\\s*([^;]+);?', 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[i][2], "ig");
match = re.exec(style);
if(match != null) {
opnvalue = match[searchlist[i][3]];
prepend += '[' + searchlist[i][0] + (searchlist[i][1] == true ? '=' + opnvalue + ']' : ']');
append = '[/' + searchlist[i][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 '<tr' + ($2 ? ' style="background: ' + $2 + '"' : '') + '><td' + ($3 ? ' colspan="' + $3 + '"' : '') + ($4 ? ' rowspan="' + $4 + '"' : '') + ($5 ? ' width="' + $5 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4) {
return '</td><td' + ($2 ? ' colspan="' + $2 + '"' : '') + ($3 ? ' rowspan="' + $3 + '"' : '') + ($4 ? ' width="' + $4 + '"' : '') + '>';
});
str = str.replace(/\[\/td\]\s*\[\/tr\]/ig, '</td></tr>');
return '<table border=1 ' + (width == '' ? '' : 'width="' + width + '" ') + (isUndefined(bgcolor) ? '' : ' style="background: ' + bgcolor + '"') + '>' + str + '</table>';
}
function preg_replace(search, replace, str) {
var len = search.length;
for(var i = 0; i < len; i++) {
re = new RegExp(search[i], "ig");
str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : 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 = '</' + tagname + '>';
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 InArray(width, ['', '0', '100%']) ?
(colspan == 1 && rowspan == 1 ? '[td]' : '[td=' + colspan + ',' + rowspan + ']') :
'[td=' + colspan + ',' + rowspan + ',' + width + ']';
}
//BBCode与HTML切换 End
function BBSXPDisplayMenu(cmd)
{
BBSXPEditorForm.focus();
BBSXPSelection();
var Top = ie_y($(cmd))+25;
var Left = ie_x($(cmd));
$('Yuzi_TempDiv').style.top = Top.toString(10) + 'px';
$('Yuzi_TempDiv').style.left = Left.toString(10) + 'px';
$('Yuzi_TempDiv').style.display = 'block';
$('Yuzi_TempDiv').innerHTML = BBSXPRealTimePopup(cmd);
}
function BBSXPDisableMenu()
{
$('Yuzi_TempDiv').innerHTML = 'Loading...';
$('Yuzi_TempDiv').style.display = 'none';
}
function BBSXPGetMenuCommonStyle()
{
var str = 'position:absolute;top:1px;left:1px;font-size:12px;color:'+YuZi_MENU_TEXT_COLOR+
';background-color:'+YuZi_MENU_BG_COLOR+';border:solid 1px '+YuZi_MENU_BORDER_COLOR+';z-index:1;display:none;';
return str;
}
function BBSXPCreateColorTable(cmd, eventStr)
{
var str = '';
str += '<table cellpadding="0" cellspacing="2" border="0">';
for (i = 0; i < YuZi_COLOR_TABLE.length; i++) {
if (i == 0 || (i >= 8 && i%8 == 0)) {
str += '<tr>';
}
str += '<td style="width:12px;height:12px;border:1px solid #AAAAAA;font-size:1px;cursor:pointer;background-color:' +
YuZi_COLOR_TABLE[i] + ';" onmouseover="this.style.borderColor=\'#000000\';' + ((eventStr) ? eventStr : '') + '" ' +
'onmouseout="this.style.borderColor=\'#AAAAAA\';" ' +
'onclick="BBSXPExecute(\''+cmd+'_END\', \'' + YuZi_COLOR_TABLE[i] + '\');"> </td>';
if (i >= 7 && i%(i-1) == 0) {
str += '</tr>';
}
}
str += '</table>';
return str;
}
//弹出菜单
function BBSXPRealTimePopup(cmd){
switch (cmd)
{
case 'YuZi_FONTNAME':
var str = '';
for (i = 0; i < YuZi_FONT_NAME.length; i++) {
str += '<div style="font-family:' + YuZi_FONT_NAME[i][0] +
';padding:2px;cursor:pointer;" ' +
'onclick="BBSXPExecute(\'YuZi_FONTNAME_END\', \'' + YuZi_FONT_NAME[i][0] + '\');" ' +
'onmouseover="this.style.backgroundColor=\''+YuZi_MENU_SELECTED_COLOR+'\';" ' +
'onmouseout="this.style.backgroundColor=\''+YuZi_MENU_BG_COLOR+'\';">' +
YuZi_FONT_NAME[i][1] + '</div>';
}
return str;
break;
case 'YuZi_FONTSIZE':
var str = '';
for (i = 0; i < YuZi_FONT_SIZE.length; i++) {
str += '<div style="font-size:' + YuZi_FONT_SIZE[i][1] +
';padding:2px;cursor:pointer;" ' +
'onclick="BBSXPExecute(\'YuZi_FONTSIZE_END\', \'' + YuZi_FONT_SIZE[i][0] + '\');" ' +
'onmouseover="this.style.backgroundColor=\''+YuZi_MENU_SELECTED_COLOR+'\';" ' +
'onmouseout="this.style.backgroundColor=\''+YuZi_MENU_BG_COLOR+'\';">' +
YuZi_FONT_SIZE[i][1] + '</div>';
}
return str;
break;
case 'YuZi_TEXTCOLOR':
var str = '';
str = BBSXPCreateColorTable('YuZi_TEXTCOLOR');
return str;
break;
case 'YuZi_SPECIALCHAR':
var str = '';
str += '<table cellpadding="0" cellspacing="2">';
for (i = 0; i < YuZi_SPECIAL_CHARACTER.length; i++) {
if (i == 0 || (i >= 10 && i%10 == 0)) {
str += '<tr>';
}
str += '<td style="padding:2px;border:1px solid #AAAAAA;cursor:pointer;" ' +
'onclick="BBSXPExecute(\'YuZi_SPECIALCHAR_END\', \'' + YuZi_SPECIAL_CHARACTER[i] + '\');" ' +
'onmouseover="this.style.borderColor=\'#000000\';" ' +
'onmouseout="this.style.borderColor=\'#AAAAAA\';">' + YuZi_SPECIAL_CHARACTER[i] + '</td>';
if (i >= 9 && i%(i-1) == 0) {
str += '</tr>';
}
}
str += '</table>';
return str;
break;
case 'YuZi_TABLE':
var str = '';
var num = 10;
str += '<table cellpadding="0" cellspacing="0">';
for (i = 1; i <= num; i++) {
str += '<tr>';
for (j = 1; j <= num; j++) {
var value = i.toString(10) + ',' + j.toString(10);
str += '<td id="BBSXPTableTd' + i.toString(10) + '_' + j.toString(10) +
'" style="width:15px;height:15px;background-color:#FFFFFF;border:1px solid #DDDDDD;cursor:pointer;" ' +
'onclick="BBSXPExecute(\'YuZi_TABLE_END\', \'' + value + '\');" ' +
'onmouseover="BBSXPDrawTableSelected(\''+i.toString(10)+'\', \''+j.toString(10)+'\');" ' +
'onmouseout=""> </td>';
}
str += '</tr>';
}
str += '<tr><td colspan="10" id="tableLocation" style="text-align:center;height:20px;"></td></tr>';
str += '</table>';
return str;
break;
case 'YuZi_ICON':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -