📄 initial.js
字号:
SuperWebEdit.document.open();
SuperWebEdit.document.write("<head><link href=\"../../css/css.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>");
SuperWebEdit.document.body.innerText=sBody;
SuperWebEdit.document.body.contentEditable="true";
SuperWebEdit.document.close();
bEditMode=false;
break;
case "EDIT":
//var TempNewsContent=SuperWebEdit.document.body.innerHTML;
SuperWebEdit.document.designMode="On";
SuperWebEdit.document.open();
SuperWebEdit.document.write("<head><link href=\"../../css/css.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>"+sBody);
SuperWebEdit.document.body.contentEditable="true";
SuperWebEdit.document.execCommand("2D-Position",true,true);
SuperWebEdit.document.execCommand("MultipleSelection", true, true);
SuperWebEdit.document.execCommand("LiveResize", true, true);
SuperWebEdit.document.close();
doZoom(nCurrZoomSize);
bEditMode=true;
break;
case "TEXT":
SuperWebEdit.document.designMode="On";
SuperWebEdit.document.open();
SuperWebEdit.document.write("<head><link href=\"../../css/css.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>");
SuperWebEdit.document.body.innerText=sBody;
SuperWebEdit.document.body.contentEditable="true";
SuperWebEdit.document.close();
bEditMode=false;
break;
case "VIEW":
SuperWebEdit.document.designMode="off";
SuperWebEdit.document.open();
SuperWebEdit.document.write("<head><link href=\"../../css/css.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>"+sBody);
SuperWebEdit.document.body.contentEditable="false";
SuperWebEdit.document.close();
bEditMode=false;
break;
}
sCurrMode=NewMode;
ModeEdit.value = NewMode;
disableChildren(SuperWebEdit_Toolbar);
//SuperWebEdit.document.body.onpaste = onPaste ;
//SuperWebEdit.document.onkeypress = new Function("return onKeyPress(SuperWebEdit.event);");
//SuperWebEdit.document.oncontextmenu=new Function("return showContextMenu(SuperWebEdit.event);");
if ((borderShown != "no")&&bEditMode)
{
borderShown = "no";
showBorders()
}
}
SuperWebEdit.focus();
}
// 使工具栏无效
function disableChildren(obj)
{
if (obj)
{
obj.disabled=(!bEditMode);
for (var i=0; i<obj.children.length; i++)
{
disableChildren(obj.children[i]);
}
}
}
// 显示无模式对话框
function ShowDialog(url, width, height, optValidate)
{
if (optValidate)
{
if (!validateMode()) return;
}
SuperWebEdit.focus();
var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
SuperWebEdit.focus();
}
// 全屏编辑
function Maximize()
{
if (!validateMode()) return;
window.open("editor/fullscreen.htm?style="+config.StyleName, 'FullScreen'+sLinkFieldName, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,fullscreen=yes');
}
// 替换特殊字符
function HTMLEncode(text)
{
text = text.replace(/&/g, "&") ;
text = text.replace(/"/g, """) ;
text = text.replace(/</g, "<") ;
text = text.replace(/>/g, ">") ;
text = text.replace(/'/g, "’") ;
text = text.replace(/\ /g," ");
text = text.replace(/\n/g,"<br>");
text = text.replace(/\t/g," ");
return text;
}
// 显示或隐藏指导方针
var borderShown = "no";
function showBorders()
{
if (!validateMode()) return;
var allForms = SuperWebEdit.document.body.getElementsByTagName("FORM");
var allInputs = SuperWebEdit.document.body.getElementsByTagName("INPUT");
var allTables = SuperWebEdit.document.body.getElementsByTagName("TABLE");
var allLinks = SuperWebEdit.document.body.getElementsByTagName("A");
// 表单
for (a=0; a < allForms.length; a++)
{
if (borderShown == "no")
{
allForms[a].runtimeStyle.border = "1px dotted #FF0000"
}
else
{
allForms[a].runtimeStyle.cssText = ""
}
}
// Input Hidden类
for (b=0; b < allInputs.length; b++)
{
if (borderShown == "no")
{
if (allInputs[b].type.toUpperCase() == "HIDDEN")
{
allInputs[b].runtimeStyle.border = "1px dashed #000000"
allInputs[b].runtimeStyle.width = "15px"
allInputs[b].runtimeStyle.height = "15px"
allInputs[b].runtimeStyle.backgroundColor = "#FDADAD"
allInputs[b].runtimeStyle.color = "#FDADAD"
}
}
else
{
if (allInputs[b].type.toUpperCase() == "HIDDEN")
allInputs[b].runtimeStyle.cssText = ""
}
}
// 表格
for (i=0; i < allTables.length; i++)
{
if (borderShown == "no")
{
allTables[i].runtimeStyle.border = "1px dotted #BFBFBF"
}
else
{
allTables[i].runtimeStyle.cssText = ""
}
allRows = allTables[i].rows
for (y=0; y < allRows.length; y++)
{
allCellsInRow = allRows[y].cells
for (x=0; x < allCellsInRow.length; x++) {
if (borderShown == "no") {
allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allCellsInRow[x].runtimeStyle.cssText = ""
}
}
}
}
// 链接 A
for (a=0; a < allLinks.length; a++)
{
if (borderShown == "no") {
if (allLinks[a].href.toUpperCase() == "") {
allLinks[a].runtimeStyle.border = "1px dashed #000000"
allLinks[a].runtimeStyle.width = "20px"
allLinks[a].runtimeStyle.height = "16px"
allLinks[a].runtimeStyle.backgroundColor = "#FFFFCC"
allLinks[a].runtimeStyle.color = "#FFFFCC"
}
} else {
allLinks[a].runtimeStyle.cssText = ""
}
}
if (borderShown == "no") {
borderShown = "yes"
} else {
borderShown = "no"
}
scrollUp()
}
// 返回页面最上部
function scrollUp()
{
SuperWebEdit.scrollBy(0,0);
}
// 缩放操作
var nCurrZoomSize = 100;
var aZoomSize = new Array(10, 25, 50, 75, 100, 150, 200, 500);
function doZoom(size)
{
SuperWebEdit.document.body.runtimeStyle.zoom = size + "%";
nCurrZoomSize = size;
}
// 拼写检查
function spellCheck()
{
ShowDialog('editor/spellcheck.htm', 300, 220, true)
}
// 是否选中指定类型的控件
function isControlSelected(tag){
if (SuperWebEdit.document.selection.type == "Control")
{
var oControlRange = SuperWebEdit.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == tag)
{
return true;
}
}
return false;
}
// 改变编辑区高度
function sizeChange(size)
{
if (!BrowserInfo.IsIE55OrMore)
{
alert("此功能需要IE5.5版本以上的支持!");
return false;
}
for (var i=0; i<parent.frames.length; i++)
{
if (parent.frames[i].document==self.document)
{
var obj=parent.frames[i].frameElement;
var height = parseInt(obj.offsetHeight);
if (height+size>=300)
{
obj.height=height+size;
}
break;
}
}
}
// 热点链接
function mapEdit()
{
if (!validateMode()) return;
var b = false;
if (SuperWebEdit.document.selection.type == "Control")
{
var oControlRange = SuperWebEdit.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == "IMG")
{
b = true;
}
}
if (!b)
{
alert("热点链接只能作用于图片");
return;
}
window.open("editor/map.htm", 'mapEdit'+sLinkFieldName, 'toolbar=no,location=no,directories=no,status=not,menubar=no,scrollbars=no,resizable=yes,width=450,height=300');
}
// 上传文件成功返回原文件名和保存后的文件名,提供接口
function addUploadFile(sourceFileName, saveFileName){
if (sLinkSourceFileName){
var oSourceFileName = parent.document.getElementsByName(sLinkSourceFileName)[0];
if (oSourceFileName){
if (oSourceFileName.value!=""){
oSourceFileName.value = oSourceFileName.value + "|";
}
oSourceFileName.value = oSourceFileName.value + sourceFileName;
oSourceFileName.fireEvent("onchange");
}
}
if (sLinkSaveFileName){
var oSaveFileName = parent.document.getElementsByName(sLinkSaveFileName)[0];
if (oSaveFileName){
if (oSaveFileName.value!=""){
oSaveFileName.value = oSaveFileName.value + "|";
}
oSaveFileName.value = oSaveFileName.value + saveFileName;
oSaveFileName.fireEvent("onchange");
}
}
}
// 清除WORD冗余格式并粘贴
function cleanAndPaste( html )
{
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
html = html.replace(/ /, " " );
var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
html = html.replace( re, "<div$2</div>" ) ;
insertHTML( html ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -