📄 ubb.js
字号:
// -----------------------------------------
// UBB Codes
// -----------------------------------------
function insertText(str) {
var oContent = findObj('content');
if (oContent) {
if (document.all) {
insertAtCaret(oContent, str);
} else {
oContent.value += str;
}
oContent.focus();
}
}
function insertAtCaret(textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
} else if (textEl) {
textEl.value += text;
} else {
textEl.value = text;
}
CountStrByte(this.form.content,this.form.used,this.form.remain)
}
function findObj(theObj, theDoc){
var i, foundObj;
if(!theDoc) theDoc = document;
if(!(foundObj = theDoc[theObj]) && theDoc.all)
foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
if(!foundObj && document.getElementById)
foundObj = document.getElementById(theObj);
return foundObj;
}
function insertCode(code, option){
var promptTitle;
var promptValue;
var codeBegin;
var codeClose;
var text;
var text1;
var Url = false;
switch (code){
case 'B':
promptTitle = promptValue = "粗体文字";
codeBegin = "[b]";
codeClose = "[/b]";
break;
case 'I':
promptTitle = promptValue = "斜体文字";
codeBegin = "[i]";
codeClose = "[/i]";
break;
case 'U':
promptTitle = promptValue = "下划线文字";
codeBegin = "[u]";
codeClose = "[/u]";
break;
case 'IMG':
promptTitle = "图象地址";
promptValue = "http://";
codeBegin = "[img]";
codeClose = "[/img]";
break;
case 'URL':
promptTitle = "超级链接";
promptValue = "http://";
codeBegin = "[url]";
codeClose = "[/url]";
Url = true;
break;
case 'EMAIL':
promptTitle = "电子邮件";
promptValue = "@";
codeBegin = "[email]";
codeClose = "[/email]";
break;
case 'FLY':
promptTitle = promptValue = "飞行文字";
codeBegin = "[fly]";
codeClose = "[/fly]";
break;
case 'MOVE':
promptTitle = promptValue = "滚动文字";
codeBegin = "[move]";
codeClose = "[/move]";
break;
case 'SHADOW':
promptTitle = "阴影文字 (参数: shadow=颜色,方向,阴影大小)";
promptValue = "阴影文字";
codeBegin = "[shadow=green,45,2]";
codeClose = "[/shadow]";
break;
case 'FONT' :
promptTitle = "字体 (" +option+ ")";
promptValue = option;
codeBegin = "[font=" +option+ "]";
codeClose = "[/font]";
break;
case 'COLOR' :
promptTitle = "字体颜色 (" +option+ ")";
promptValue = "颜色字";
codeBegin = "[color=" +option+ "]";
codeClose = "[/color]";
break;
default:
text = code;
}
if(text){
insertText(text);
}else if(code && option!='false'){
if(Url){
txt1=prompt("YHPbook - 链接文本显示:\n如果不想使用, 可以为空, 将只显示超级链接地址. ","");
if (txt1!=null) {
txt=prompt("YHPbook - " + promptTitle + ": ",promptValue);
if (txt!=null) {
if (txt1 != "") {
codeBegin="[url="+txt+"]";
txt = txt1;
}
insertText(codeBegin + txt + codeClose);
}
}
}else{
txt = prompt( "YHPbook - " + promptTitle + ": ", promptValue);
if (txt != null) {
insertText(codeBegin + txt + codeClose);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -