📄 edit.js
字号:
var bodyID,htmlableID;
var WBTB_yToolbars = new Array();
var WBTB_YInitialized = false;
var WBTB_filterScript = false;
var WBTB_charset="UTF-8";
function document.onreadystatechange()
{
if (WBTB_YInitialized) return;
WBTB_YInitialized = true;
var i, s, curr;
for (i=0; i<document.body.all.length; i++)
{
curr=document.body.all[i];
if (curr.className == "yToolbar")
{
WBTB_InitTB(curr);
WBTB_yToolbars[WBTB_yToolbars.length] = curr;
}
}
}
function WBTB_InitBtn(btn)
{
btn.onmouseover = WBTB_BtnMouseOver;
btn.onmouseout = WBTB_BtnMouseOut;
btn.onmousedown = WBTB_BtnMouseDown;
btn.onmouseup = WBTB_BtnMouseUp;
btn.ondragstart = WBTB_YCancelEvent;
btn.onselectstart = WBTB_YCancelEvent;
btn.onselect = WBTB_YCancelEvent;
btn.YUSERONCLICK = btn.onclick;
btn.onclick = WBTB_YCancelEvent;
btn.YINITIALIZED = true;
return true;
}
function WBTB_InitTB(y)
{
y.TBWidth = 0;
if (!WBTB_PopulateTB(y)) return false;
y.style.posWidth = y.TBWidth;
return true;
}
function WBTB_YCancelEvent()
{
event.returnValue=false;
event.cancelBubble=true;
return false;
}
function WBTB_BtnMouseOver()
{
if (event.srcElement.tagName != "IMG") return false;
var image = event.srcElement;
var element = image.parentElement;
if (image.className == "WBTB_Ico") element.className = "WBTB_BtnMouseOverUp";
else if (image.className == "WBTB_IcoDown") element.className = "WBTB_BtnMouseOverDown";
event.cancelBubble = true;
}
function WBTB_BtnMouseOut()
{
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
yRaisedElement = null;
element.className = "WBTB_Btn";
image.className = "WBTB_Ico";
event.cancelBubble = true;
}
function WBTB_BtnMouseDown()
{
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
event.returnValue=false;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
element.className = "WBTB_BtnMouseOverDown";
image.className = "WBTB_IcoDown";
event.cancelBubble = true;
event.returnValue=false;
return false;
}
function WBTB_BtnMouseUp()
{
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
element.className = "WBTB_BtnMouseOverUp";
image.className = "WBTB_Ico";
event.cancelBubble = true;
return false;
}
function WBTB_PopulateTB(y)
{
var i, elements, element;
elements = y.children;
for (i=0; i<elements.length; i++) {
element = elements[i];
if (element.tagName== "SCRIPT" || element.tagName == "!") continue;
switch (element.className) {
case "WBTB_Btn":
if (element.YINITIALIZED == null) {
if (! WBTB_InitBtn(element))
return false;
}
element.style.posLeft = y.TBWidth;
y.TBWidth += element.offsetWidth + 1;
break;
case "WBTB_TBGen":
element.style.posLeft = y.TBWidth;
y.TBWidth += element.offsetWidth + 1;
break;
//default:
// return false;
}
}
y.TBWidth += 1;
return true;
}
function WBTB_DebugObject(obj)
{
var msg = "";
for (var i in TB) {
ans=prompt(i+"="+TB[i]+"\n");
if (! ans) break;
}
}
function WBTB_validateMode()
{
if (!WBTB_bTextMode) return true;
alert("请取消“查看HTML源代码”选项再使用系统编辑功能或者提交!");
WBTB_Composition.focus();
return false;
}
function WBTB_format1(what,opt)
{
if (opt=="removeFormat")
{
what=opt;
opt=null;
}
WBTB_Composition.focus();
if (opt==null)
{
WBTB_Composition.document.execCommand(what);
}else{
WBTB_Composition.document.execCommand(what,"",opt);
}
WBTB_pureText = false;
WBTB_Composition.focus();
}
function WBTB_format(what,opt)
{
if (!WBTB_validateMode()) return;
WBTB_format1(what,opt);
}
function WBTB_setMode()
{
WBTB_bTextMode=!WBTB_bTextMode;
WBTB_setTab();
var cont;
if (WBTB_bTextMode) {
document.all.WBTB_Toolbars.style.display='none';
WBTB_cleanHtml();
cont=WBTB_rCode(WBTB_Composition.document.body.innerHTML,"<a> </a>","");
cont=WBTB_correctUrl(cont);
if (WBTB_filterScript)
cont=WBTB_FilterScript(cont);
WBTB_Composition.document.body.innerText=cont;
} else {
document.all.WBTB_Toolbars.style.display='';
cont=WBTB_Composition.document.body.innerText;
cont=WBTB_correctUrl(cont);
if (WBTB_filterScript)
cont=WBTB_FilterScript(cont);
WBTB_Composition.document.body.innerHTML="<a> </a>"+cont;
}
//WBTB_setStyle();
WBTB_Composition.focus();
}
function WBTB_setStyle()
{
bs = WBTB_Composition.document.body.runtimeStyle;
//根据mode设置iframe样式表
if (WBTB_bTextMode) {
bs.fontFamily="Arial";
bs.fontSize="10pt";
}else{
bs.fontFamily="Arial";
bs.fontSize="10.5pt";
}
bs.scrollbar3dLightColor= '#D4D0C8';
bs.scrollbarArrowColor= '#000000';
bs.scrollbarBaseColor= '#D4D0C8';
bs.scrollbarDarkShadowColor= '#D4D0C8';
bs.scrollbarFaceColor= '#D4D0C8';
bs.scrollbarHighlightColor= '#808080';
bs.scrollbarShadowColor= '#808080';
bs.scrollbarTrackColor= '#D4D0C8';
bs.border='0';
}
function WBTB_setTab()
{
//html和design按钮的样式更改
var mhtml=document.all.WBTB_TabHtml;
var mdesign=document.all.WBTB_TabDesign;
if (WBTB_bTextMode)
{
mhtml.className="WBTB_TabOn";
mdesign.className="WBTB_TabOff";
}else{
mhtml.className="WBTB_TabOff";
mdesign.className="WBTB_TabOn";
}
}
function WBTB_getEl(sTag,start)
{
while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
return start;
}
function WBTB_UserDialog(what)
{
if (!WBTB_validateMode()) return;
WBTB_Composition.focus();
WBTB_Composition.document.execCommand(what, true);
//去掉添加图片时的src="file://
if(what=="InsertImage")
{
WBTB_Composition.document.body.innerHTML=(WBTB_Composition.document.body.innerHTML).replace("src=\"file://","src=\"");
}
WBTB_pureText = false;
WBTB_Composition.focus();
}
function WBTB_foreColor()
{
if (!WBTB_validateMode()) return;
var arr = showModalDialog("../htmledit/wbTextBox/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
if (arr != null) WBTB_format('forecolor', arr);
else WBTB_Composition.focus();
}
function WBTB_backColor()
{
if (!WBTB_validateMode()) return;
var arr = showModalDialog("../htmledit/wbTextBox/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
if (arr != null) WBTB_format('backcolor', arr);
else WBTB_Composition.focus();
}
function WBTB_fortable()
{
if (!WBTB_validateMode()) return;
var arr = showModalDialog("../htmledit/wbTextBox/table.html", "", "dialogWidth:14.5em; dialogHeight:18em; status:0; help:0");
if (arr != null)
{
var ss;
ss=arr.split("*")
row=ss[0];
if (row=="") row=1;
col=ss[1];
if (col=="") col=1;
tbwidth=ss[2];
if (tbwidth=="") tbwidth=500;
tbborder=ss[3];
if (tbborder=="") tbborder=1;
celpadding=ss[4];
if (celpadding=="") celpadding=2;
bdcolor=ss[5];
if (bdcolor=="") bdcolor="#CCCCCC";
bgcolor=ss[6];
if (bgcolor=="") bgcolor="#FFFFFF";
tbalign=ss[7];
if (tbalign=="") tbalign="center";
var string;
string="<table border="+ tbborder +" cellspacing=0 width="+tbwidth+" cellpadding="+ celpadding +" align="+tbalign+" bgcolor='"+ bgcolor +"' bordercolor="+ bdcolor +" style='border-collapse:collapse'>";
for(i=1;i<=row;i++){
string=string+"<tr>";
for(j=1;j<=col;j++){
string=string+"<td> </td>";
}
string=string+"</tr>";
}
string=string+"</table>";
content=WBTB_Composition.document.body.innerHTML;
content=content+string;
WBTB_Composition.document.body.innerHTML=content;
WBTB_Composition.focus();
}
else
WBTB_Composition.focus();
}
function WBTB_forswf()
{
var arr = showModalDialog("../htmledit/wbTextBox/swf.htm", "", "dialogWidth:18em; dialogHeight:13em; status:0; help:0");
if (arr != null){
var ss;
ss=arr.split("*")
path=ss[0];
row=ss[1];
col=ss[2];
var string;
string="<div align='center'><div style='width:640;text-align:left'><a href="+path+">[全屏查看]</a></div><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width="+row+" height="+col+"><param name=movie value="+path+"><param name=quality value=high><embed src="+path+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+row+" height="+col+"></embed></object>"
content=WBTB_Composition.document.body.innerHTML;
content=content+string;
WBTB_Composition.document.body.innerHTML=content;
WBTB_Composition.focus();
}
else WBTB_Composition.focus();
}
function WBTB_forwmv()
{
var arr = showModalDialog("../htmledit/wbTextBox/wmv.htm", "", "dialogWidth:18em; dialogHeight:14em; status:0; help:0");
if (arr != null){
var ss;
ss=arr.split("*")
path=ss[0];
width=ss[1];
height=ss[2];
var string;
//string="<object align=center classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 hspace=5 vspace=5 width="+ width +" height="+ height +"><param name=Filename value="+ path +"><param name=ShowStatusBar value=1><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src="+ path +" width="+ width +" height="+ height +"></embed></object>";
string="<embed src='"+ path+"' width="+ width +" height="+ height +" autostart=false loop=false ></embed>";
content=WBTB_Composition.document.body.innerHTML;
content=content+string;
WBTB_Composition.document.body.innerHTML=content;
WBTB_Composition.focus();
}
else WBTB_Composition.focus();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -