📄 mainscript.js
字号:
function FTB_HideToolbar(ftbName) {
return (eval(ftbName + "_HideToolbar"));
}
function FTB_UpdateToolbar(ftbName) {
return (eval(ftbName + "_UpdateToolbar"));
}
function FTB_GetHiddenField(ftbName) {
return document.getElementById(ftbName);
}
function FTB_GetTextDirection(ftbName) {
return (eval(ftbName + "_TextDirection"));
}
function FTB_GetIFrame(ftbName) {
if (isIE_1) {
return eval(ftbName + "_Editor");
//return document.getElementById(ftbName + "_Editor");
} else {
return document.getElementById(ftbName + "_Editor").contentWindow;
}
}
function FTB_GetToolbar(ftbName) {
return document.getElementById(ftbName + "_Toolbar");
}
function FTB_GetToolbarArray(ftbName) {
return eval(ftbName + "_ToolbarItems");
}
function FTB_GetCssID(ftbName) {
cssID = ftbName;
while (cssID.substring(0,1) == '_') {
cssID = cssID.substring(1);
}
return cssID;
}
function FTB_SetButtonStyle(buttonTD,style,checkstyle) {
if (buttonTD == null) return;
if (buttonTD.className != checkstyle)
buttonTD.className = style;
}
function FTB_GetClassSubName(className) {
underscore = className.indexOf("_");
if (underscore < 0) return className;
return className.substring(underscore+1);
}
/** 结束属性 ********************/
/** 选项卡 ********************/
function FTB_SetActiveTab(theTD,ftbName) { //设置选项卡
parentTR = theTD.parentElement;
parentTR = document.getElementById(ftbName + "_TabRow");
selectedTab = 1;
totalButtons = parentTR.cells.length-1;
for (var i=1;i< totalButtons;i++) {
parentTR.cells[i].className = FTB_GetCssID(ftbName) + "_TabOffRight";
if (theTD == parentTR.cells[i]) { selectedTab = i; }
}
if (selectedTab==1) {
parentTR.cells[0].className = FTB_GetCssID(ftbName) + "_StartTabOn";
} else {
parentTR.cells[0].className = FTB_GetCssID(ftbName) + "_StartTabOff";
parentTR.cells[selectedTab-1].className = FTB_GetCssID(ftbName) + "_TabOffLeft";
}
theTD.className = FTB_GetCssID(ftbName) + "_TabOn";
}
function FTB_TabOver() {
document.body.style.cursor='default';
}
function FTB_TabOut() {
document.body.style.cursor='auto';
}
/** 结束 CODE:0457 ********************/
function FTB_SetToolbarItems(ftbName) {
editor = FTB_GetIFrame(ftbName);
htmlMode = FTB_IsHtmlMode(ftbName);
toolbarArray = FTB_GetToolbarArray(ftbName);
//document.getElementById("Debug").value = "";
if (toolbarArray) {
for (var i=0; i<toolbarArray.length; i++) {
toolbarItemID = toolbarArray[i][0];
toolbarItem = document.getElementById(toolbarItemID);
commandIdentifier = toolbarArray[i][1];
state = "";
try {
if (toolbarItemID.indexOf("Button") > -1) {
state = editor.document.queryCommandState(commandIdentifier);
FTB_SetButtonState(toolbarItemID,ftbName,state);
} else {
state = editor.document.queryCommandValue(commandIdentifier);
switch (commandIdentifier) {
case "backcolor":
if (isIE_1) {
state = FTB_GetHexColor(state);
} else {
if (state == "") state = "#FFFFFF";
}
break;
case "forecolor":
if (isIE_1) {
state = FTB_GetHexColor(state);
} else {
if (state == "") state = "#000000";
}
break;
case "formatBlock":
//document.getElementById("Debug").value += "****: " + state + "\n";
if (!isIE_1) {
if (state == "p" || state == "" || state == "<x>")
state = "<body>";
else
state = "<" + state + ">";
}
break;
}
//document.getElementById("Debug").value += commandIdentifier + ": " + state + "\n";
FTB_SetDropDownListState(toolbarItemID,state);
}
} catch(e) {
}
}
}
}
function FTB_GetHexColor(intColor) {
intColor = intColor.toString(16).toUpperCase();
while (intColor.length < 6) {
intColor = "0" + intColor;
}
return "#" + intColor.substring(4,6) + intColor.substring(2,4) + intColor.substring(0,2);
}
function FTB_SetDropDownListState(ddlName,value) {
ddl = document.getElementById(ddlName);
if (ddl) {
for (var i=0; i<ddl.options.length; i++) {
if (ddl.options[i].text == value || ddl.options[i].value == value) {
ddl.options.selectedIndex = i;
return;
}
}
}
}
function FTB_SetButtonState(buttonName,ftbName,value) {
buttonTD = document.getElementById(buttonName);
if (buttonTD) {
if (value) {
buttonTD.className = FTB_GetCssID(ftbName) + "_ButtonActive";
//FTB_ButtonOver(buttonTD,ftbName,0,0);
} else {
buttonTD.className = FTB_GetCssID(ftbName) + "_ButtonNormal";
//FTB_ButtonOut(buttonTD,ftbName,0,0);
}
}
}
// *******************************
function FTB_GetParentElement(ftbName) {
editor = FTB_GetIFrame(ftbName);
var sel = FTB_GetSelection(ftbName);
var range = FTB_CreateRange(ftbName,sel);
if (isIE_1) {
switch (sel.type) {
case "Text":
case "None":
// It seems that even for selection of type "None",
// there _is_ a parent element and it's value is not
// only correct, but very important to us. MSIE is
// certainly the buggiest browser in the world and I
// wonder, God, how can Earth stand it?
return range.parentElement();
case "Control":
return range.item(0);
default:
return editor.document.body;
}
} else try {
var p = range.commonAncestorContainer;
if (!range.collapsed && range.startContainer == range.endContainer &&
range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes())
p = range.startContainer.childNodes[range.startOffset];
/*
alert(range.startContainer + ":" + range.startOffset + "\n" +
range.endContainer + ":" + range.endOffset);
*/
while (p.nodeType == 3) {
p = p.parentNode;
}
return p;
} catch (e) {
return null;
}
};
// returns the current selection object
function FTB_GetSelection(ftbName) {
editor = FTB_GetIFrame(ftbName);
if (isIE_1) {
return editor.document.selection;
} else {
return editor.getSelection();
}
}
// returns a range for the current selection
function FTB_CreateRange(ftbName,sel) {
editor = FTB_GetIFrame(ftbName);
if (isIE_1) {
return sel.createRange();
} else {
//TODO: this.focusEditor();
if (typeof sel != "undefined") {
try {
return sel.getRangeAt(0);
} catch(e) {
return editor.document.createRange();
}
} else {
return editor.document.createRange();
}
}
}
function FTB_FilterScript(str) { // 代码转为 BMB Code
str = str.replace(/\n+/g,"");
str = str.replace(/\r/g,"");
if (html_codeinfo != "yes" || document.__bmbForm.openhtmlcode.checked == true) {
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");
str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"[url=$1]$2[/url]");
str = str.replace(/<font[^>]+face=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[font=$1]$2[/font]");
str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
str = str.replace(/<font[^>]+size=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[size=$1]$2[/size]");
str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"[img]$1[/img]");
str = str.replace(/<p[^>]+align=([^ >]+)[^>]*>(.*?)<\/p>/ig,"[align=$1]$2[/align]");
str = str.replace(/<([\/]?)H1>/ig,"[$1H1]");
str = str.replace(/<([\/]?)H2>/ig,"[$1H2]");
str = str.replace(/<([\/]?)H3>/ig,"[$1H3]");
str = str.replace(/<([\/]?)H4>/ig,"[$1H4]");
str = str.replace(/<([\/]?)H5>/ig,"[$1H5]");
str = str.replace(/<([\/]?)H6>/ig,"[$1H6]");
str = str.replace(/<([\/]?)b>/ig,"[$1b]");
str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
str = str.replace(/<([\/]?)u>/ig,"[$1u]");
str = str.replace(/<([\/]?)em>/ig,"[$1i]");
str = str.replace(/<([\/]?)STRIKE>/ig,"[$1STRIKE]");
str = str.replace(/<([\/]?)sub>/ig,"[$1sub]");
str = str.replace(/<([\/]?)sup>/ig,"[$1sup]");
str = str.replace(/<([\/]?)UL>/ig,"[$1list]");
str = str.replace(/<([\/]?)OL>/ig,"[$1olist]");
str = str.replace(/<li>/ig,"[*]");
str = str.replace(/ /g," ");
str = str.replace(/&/g,"&");
str = str.replace(/"/g,"\"");
str = str.replace(/</g,"<");
str = str.replace(/>/g,">");
str = str.replace(/<\/\p>/ig,"\n\n");
str = str.replace(/<br>/ig,"\n");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(/\[url=([^\]]+)\](\[img\]\1\[\/img\])\[\/url\]/g,"$2");
}
return str;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -