"
if (s_Image !=""){
s_MenuRow += " ";
}else{
s_MenuRow += " ";
}
s_MenuRow += s_Html+"<\/td><\/tr><\/TABLE><\/td><\/tr>";
return s_MenuRow;
}
// 取标准的format菜单行
function getFormatMenuRow(menu, html, image){
var s_Disabled = "";
if (!HtmlEdit.document.queryCommandEnabled(menu)){
s_Disabled = "disabled";
}
var s_Event = "format('"+menu+"')";
var s_Image = menu+".gif";
if (image){
s_Image = image;
}
return getMenuRow(s_Disabled, s_Event, s_Image, html)
}
// 暂时解决一下 不能通用右键的问题
function getFormatMenuRow2(menu, html, image){
var s_Disabled = "";
if (!HtmlEdit.document.queryCommandEnabled(menu)){
s_Disabled = "disabled";
}
var s_Event = "format2('"+menu+"')";
var s_Image = menu+".gif";
if (image){
s_Image = image;
}
return getMenuRow(s_Disabled, s_Event, s_Image, html)
}
//表格菜单
function tableMenu(){
if (!bEditMode) return false;
var sMenu = ""
var width = 150;
var height = 0;
var lefter = event.clientX;
var leftoff = event.offsetX
var topper = event.clientY;
var topoff = event.offsetY;
var oPopDocument = oPopupMenu.document;
var oPopBody = oPopupMenu.document.body;
sMenu += getTableMenuRow("TableInsert");
sMenu += getTableMenuRow("TableProp");
sMenu += sMenuHr;
sMenu += getTableMenuRow("TableCell");
height = 306;
}
// 取表格菜单行
function getTableMenuRow(what){
var s_Menu = "";
var s_Disabled = "disabled";
switch(what){
case "TableInsert":
if (!isTableSelected()) s_Disabled="";
s_Menu += getMenuRow(s_Disabled, "TableInsert()", "table_cr.gif", "插入表格...")
break;
case "TableProp":
if (isTableSelected()||isCursorInTableCell()) s_Disabled="";
s_Menu += getMenuRow(s_Disabled, "TableProp()", "table_sx.gif", "表格属性...")
break;
case "TableCell":
if (isCursorInTableCell()) s_Disabled="";
s_Menu += getMenuRow(s_Disabled, "TableCellProp()", "table_sx2.gif", "单元格属性...")
s_Menu += getMenuRow(s_Disabled, "TableCellSplit()", "table_cf.gif", "拆分单元格...")
s_Menu += sMenuHr;
s_Menu += getMenuRow(s_Disabled, "TableRowProp()", "table_sxh.gif", "表格行属性...")
s_Menu += getMenuRow(s_Disabled, "TableRowInsertAbove()", "table_tr.gif", "插入行(在上方)");
s_Menu += getMenuRow(s_Disabled, "TableRowInsertBelow()", "table_trx.gif", "插入行(在下方)");
s_Menu += getMenuRow(s_Disabled, "TableRowMerge()", "table_hbx.gif", "合并行(向下方)");
s_Menu += getMenuRow(s_Disabled, "TableRowSplit(2)", "table_cfh.gif", "拆分行");
s_Menu += getMenuRow(s_Disabled, "TableRowDelete()", "table_trdel.gif", "删除行");
s_Menu += sMenuHr;
s_Menu += getMenuRow(s_Disabled, "TableColInsertLeft()", "table_td.gif", "插入列(在左侧)");
s_Menu += getMenuRow(s_Disabled, "TableColInsertRight()", "table_tdr.gif", "插入列(在右侧)");
s_Menu += getMenuRow(s_Disabled, "TableColMerge()", "table_hby.gif", "合并列(向右侧)");
s_Menu += getMenuRow(s_Disabled, "TableColSplit(2)", "table_cf.gif", "拆分列");
s_Menu += getMenuRow(s_Disabled, "TableColDelete()", "table_tddel.gif", "删除列");
break;
}
return s_Menu;
}
// 右键是否在编辑状态
function isyou(){
var range = HtmlEdit.document.selection.createRange();
var RangeType = HtmlEdit.document.selection.type;
if (RangeType == "Text"){
return true;
}
}
// 右键调用类型
function youjiantype(){
if (youjian=true){
return true;
}
}
// 右键菜单
function showContextMenu(event){
if (!bEditMode) return false;
var width = 150;
var height = 0;
var lefter = event.clientX;
var topper = event.clientY;
var oPopDocument = oPopupMenu.document;
var oPopBody = oPopupMenu.document.body;
var sMenu="";
sMenu += getFormatMenuRow2("cut", "剪切");
sMenu += getFormatMenuRow2("copy", "复制");
sMenu += getFormatMenuRow2("paste", "常规粘贴");
sMenu += getFormatMenuRow2("delete", "删除");
height += 102;
if (HtmlEdit.document.selection.type == "Control") {
sMenu += getMenuRow("", "insert('Attribute')", "label3.gif", "代码属性...");
height+= 19;
}
if (sCurrMode=="EDIT"){
if (isyou()){
sMenu += getMenuRow("", "insert('fgcolor')", "fgcolor.gif", "文字颜色");
sMenu += getMenuRow("", "insert('fgbgcolor')", "fgbgcolor.gif", "文字背景色");
sMenu += getMenuRow("", "format('bold')", "bold.gif", "文字加粗");
sMenu += getMenuRow("", "format('italic')", "italic.gif", "文字斜体");
sMenu += getMenuRow("", "format('underline')", "underline.gif", "文字下划线");
sMenu += getMenuRow("", "format('StrikeThrough')", "strikethrough.gif", "文字删除线");
height += 119;
}
if (isCursorInTableCell()){
sMenu += getTableMenuRow("TableProp");
sMenu += getTableMenuRow("TableCell");
sMenu += sMenuHr;
height += 286;
}
if (isControlSelected("TABLE")){
sMenu += getTableMenuRow("TableProp");
sMenu += sMenuHr;
height += 22;
}
if (isControlSelected("IMG")){
sMenu += getMenuRow("", "insert('pic')", "img.gif", "图片属性...");
sMenu += sMenuHr;
sMenu += getMenuRow("", "imgalign('left')", "imgleft.gif", "图片左环绕...");
sMenu += getMenuRow("", "imgalign('center')", "imgcenter.gif", "图片单行居中...");
sMenu += getMenuRow("", "imgalign('right')", "imgright.gif", "图片右环绕...");
sMenu += sMenuHr;
sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", "上移一层");
sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", "下移一层");
sMenu += sMenuHr;
height+= 127;
}
}
sMenu += getFormatMenuRow2("selectall", "全选");
sMenu += getMenuRow("", "findstr()", "find.gif", "查找替换...");
height += 20;
sMenu = sMenu1 + sMenu + sMenu2;
oPopDocument.open();
oPopDocument.write("
"+sMenu);
oPopDocument.close();
height+=2;
if(lefter+width > document.body.clientWidth) lefter=lefter-width;
oPopupMenu.show(lefter, topper, width, height, HtmlEdit.document.body);
return false;
}
// 右键下拉工具栏菜单
function showToolMenu(menu){
if (!bEditMode) return false;
var sMenu = ""
var width = 150;
var height = 0;
var lefter = event.clientX;
var leftoff = event.offsetX
var topper = event.clientY;
var topoff = event.offsetY;
var oPopDocument = oPopupMenu.document;
var oPopBody = oPopupMenu.document.body;
switch(menu){
case "font":
// 字体菜单
sMenu += getFormatMenuRow("superscript", "上标", "sup.gif");
sMenu += getFormatMenuRow("subscript", "下标", "sub.gif");
sMenu += sMenuHr;
sMenu += getMenuRow("", "insert('big')", "tobig.gif", "字体增大");
sMenu += getMenuRow("", "insert('small')", "tosmall.gif", "字体减小");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("insertorderedlist", "编号", "num.gif");
sMenu += getFormatMenuRow("insertunorderedlist", "项目符号", "list.gif");
sMenu += getFormatMenuRow("indent", "增加缩进量", "indent.gif");
sMenu += getFormatMenuRow("outdent", "减少缩进量", "outdent.gif");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("insertparagraph", "插入段落", "paragraph.gif");
sMenu += getMenuRow("", "insert('br')", "chars.gif", "插入换行符");
height = 206;
break;
case "paragraph":// 段落菜单
sMenu += getFormatMenuRow("JustifyLeft", "左对齐", "JustifyLeft.gif");
sMenu += getFormatMenuRow("JustifyCenter", "居中对齐", "JustifyCenter.gif");
sMenu += getFormatMenuRow("JustifyRight", "右对齐", "JustifyRight.gif");
sMenu += getFormatMenuRow("JustifyFull", "两端对齐", "JustifyFull.gif");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("insertorderedlist", "编号", "insertorderedlist.gif");
sMenu += getFormatMenuRow("insertunorderedlist", "项目符号", "insertunorderedlist.gif");
sMenu += getFormatMenuRow("indent", "增加缩进量", "indent.gif");
sMenu += getFormatMenuRow("outdent", "减少缩进量", "outdent.gif");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("insertparagraph", "插入段落", "insertparagraph.gif");
sMenu += getMenuRow("", "insert('br')", "br.gif", "插入换行符");
height = 204;
break;
case "gongshi":// 公式编辑器
sMenu += getMenuRow("","insert('InsertEQ')", "eq1.gif", "插入公式");
sMenu += getMenuRow("","insert('InstallEQ')", "eq2.gif", "安装公式编辑器插件");
height = 42;
break;
case "edit": // 编辑菜单
var s_Disabled = "";
if (history.data.length <= 1 || history.position <= 0) s_Disabled = "disabled";
sMenu += getMenuRow(s_Disabled, "goHistory(-1)", "undo.gif", "撤消")
if (history.position >= history.data.length-1 || history.data.length == 0) s_Disabled = "disabled";
sMenu += getMenuRow(s_Disabled, "goHistory(1)", "redo.gif", "恢复")
sMenu += sMenuHr;
sMenu += getFormatMenuRow("Cut", "剪切", "cut.gif");
sMenu += getFormatMenuRow("Copy", "复制", "copy.gif");
sMenu += getFormatMenuRow("Paste", "常规粘贴", "paste.gif");
sMenu += getMenuRow("", "PasteText()", "pastetext.gif", "纯文本粘贴");
sMenu += getMenuRow("", "PasteWord()", "pasteword.gif", "从Word中粘贴");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("delete", "删除", "del.gif");
sMenu += getFormatMenuRow("RemoveFormat", "删除文字格式", "removeformat.gif");
sMenu += sMenuHr;
sMenu += getFormatMenuRow("SelectAll", "全部选中", "selectall.gif");
sMenu += getFormatMenuRow("Unselect", "取消选择", "unselect.gif");
sMenu += sMenuHr;
sMenu += getMenuRow("", "findReplace()", "findreplace.gif", "查找替换");
height = 248;
break;
case "object": // 对象效果菜单
sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", "上移一层");
sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", "下移一层");
sMenu += sMenuHr;
sMenu += getMenuRow("", "insert('quote')", "quote.gif", "引用样式");
sMenu += getMenuRow("", "insert('code')", "code.gif", "代码样式");
height = 86;
break;
case "table": // 表格菜单
sMenu += getTableMenuRow("TableInsert");
sMenu += getTableMenuRow("TableProp");
sMenu += sMenuHr;
sMenu += getTableMenuRow("TableCell");
height = 306;
break;
case "form": // 表单菜单
sMenu += getMenuRow("", "Insermenu('time')", "FormDropdown.gif", "转向菜单");
sMenu += getFormatMenuRow("InsertInputText", "插入输入框", "FormText.gif");
sMenu += getFormatMenuRow("InsertTextArea", "插入输入区", "FormTextArea.gif");
sMenu += getFormatMenuRow("InsertInputRadio", "插入单选钮", "FormRadio.gif");
sMenu += getFormatMenuRow("InsertInputCheckbox", "插入复选钮", "FormCheckBox.gif");
sMenu += getFormatMenuRow("InsertSelectDropdown", "插入下拉框", "FormDropdown.gif");
sMenu += getFormatMenuRow("InsertButton", "插入按钮", "FormButton.gif");
height = 150;
break;
case "zoom": // 缩放菜单
for (var i=0; i
"+sMenu);
oPopDocument.close();
height+=2;
if(lefter+width > document.body.clientWidth) lefter=lefter-width;
oPopupMenu.show(lefter - leftoff - 2, topper - topoff + 22, width, height, document.body);
return false;
}
// 右键菜单定义函数组结速
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 编辑器设置 函数组开始
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 改变编辑区高度
function sizeChange(size){
if (!BrowserInfo.IsIE55OrMore){
alert("此功能需要IE5.5版本以上的支持!");
return false;
}
for (var i=0; i=100){
obj.height=height+size;
}
break;
}
}
}
// 快捷键
function onKeyDown(event){
var key = String.fromCharCode(event.keyCode).toUpperCase();
// F2:显示或隐藏指导方针
if (event.keyCode==113){
showBorders();
return false;
}
if (event.ctrlKey){
// Ctrl+Enter:提交
if (event.keyCode==10){
doSubmit();
return false;
}
// Ctrl++:增加编辑区
if (key=="+"){
sizeChange(300);
return false;
}
// Ctrl+-:减小编辑区
if (key=="-"){
sizeChange(-300);
return false;
}
// Ctrl+1:设计模式
if (key=="1"){
setMode("EDIT");
return false;
}
// Ctrl+2:代码模式
if (key=="2"){
setMode("CODE");
return false;
}
// Ctrl+3:纯文本
if (key=="3"){
setMode("TEXT");
return false;
}
// Ctrl+4:预览
if (key=="4"){
setMode("VIEW");
return false;
}
}
switch(sCurrMode){
case "VIEW":
return true;
break;
case "EDIT":
if (event.ctrlKey){
// Ctrl+D:从Word粘贴
if (key == "D"){
insert('word');
return false;
}
// Ctrl+R:查找替换
if (key == "R"){
findstr();
return false;
}
// Ctrl+Z:Undo
if (key == "Z"){
format('undo');
return false;
}
// Ctrl+Y:Redo
if (key == "Y"){
format('redo');
return false;
}
}
if(!event.ctrlKey && event.keyCode != 90 && event.keyCode != 89) {
if (event.keyCode == 32 || event.keyCode == 13){
saveHistory()
}
}
return true;
break;
default:
if (event.keyCode==13){
var sel = HtmlEdit.document.selection.createRange();
sel.pasteHTML(" ");
event.cancelBubble = true;
event.returnValue = false;
sel.select();
sel.moveEnd("character", 1);
sel.moveStart("character", 1);
sel.collapse(false);
return false;
}
// 屏蔽事件
if (event.ctrlKey){
// Ctrl+B,I,U
if ((key == "B")||(key == "I")||(key == "U")){
return false;
}
}
}
}
//触发焦点事件
function onMouseUp(event,TemplateType){
}
//Html 标签导航
function UpdateToolbar(){
}
function GetAllAncestors(){
var p = GetParentElement();
var a = [];
while (p && (p.nodeType==1)&&(p.tagName.toLowerCase()!='body'))
{
a.push(p);
p=p.parentNode;
}
a.push(HtmlEdit.document.body);
return a;
}
function GetParentElement(){
var sel=GetSelection();
var range=CreateRange(sel);
switch (sel.type)
{
case "Text":
case "None":
return range.parentElement();
case "Control":
return range.item(0);
default:
return HtmlEdit.document.body;
}
}
function GetSelection(){
return HtmlEdit.document.selection;
}
function CreateRange(sel){
return sel.createRange();
}
function SelectNodeContents(Obj,pos){
var node=Obj.el;
EditControl=node;
for (var i=0;i= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
}
}
// 是否选中指定类型的控件
function isControlSelected(tag){
if (HtmlEdit.document.selection.type == "Control") {
var oControlRange = HtmlEdit.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == tag) {
return true;
}
}
return false;
}
// 判断是否在编辑状态
function validateMode(){
if (EditMode) return true;
alert("请先点编辑器下方的“编辑”按钮,进入“编辑”状态,然后再使用系统编辑功能!");
HtmlEdit.focus();
return false;
}
// 字体处理
function format(what,opt){
if (!validateMode()) return;
if (opt=="removeFormat"){
what=opt;
opt=null;
}
if (opt==null) HtmlEdit.document.execCommand(what);
else HtmlEdit.document.execCommand(what,"",opt);
pureText = false;
HtmlEdit.focus();
}
//暂时解决一下文本源码,复制粘贴的问题。
function format2(what,opt){
if (opt=="removeFormat"){
what=opt;
opt=null;
}
if (opt==null) HtmlEdit.document.execCommand(what);
else HtmlEdit.document.execCommand(what,"",opt);
pureText = false;
HtmlEdit.focus();
}
// 修正Undo/Redo
var history = new Object;
history.data = [];
history.position = 0;
history.bookmark = [];
// 保存历史
function saveHistory() {
if (bEditMode){
if (history.data[history.position] != HtmlEdit.document.body.innerHTML){
var nBeginLen = history.data.length;
var nPopLen = history.data.length - history.position;
for (var i=1; i 0){
HtmlEdit.document.body.innerHTML = history.data[--history.position];
setHistoryCursor();
}
// redo
} else {
if (history.position < history.data.length -1){
HtmlEdit.document.body.innerHTML = history.data[++history.position];
setHistoryCursor();
}
}
}
// 设置当前书签
function setHistoryCursor() {
if (history.bookmark[history.position]){
r = HtmlEdit.document.body.createTextRange()
if (history.bookmark[history.position] != "[object]"){
if (r.moveToBookmark(history.bookmark[history.position])){
r.collapse(false);
r.select();
}
}
}
}
// End Undo / Redo Fix
function setMode(NewMode){
if (!BrowserInfo.IsIE55OrMore){
if ((NewMode=="CODE") || (NewMode=="EDIT") || (NewMode=="VIEW")){
alert("HTML编辑模式需要IE5.5版本以上的支持!");
return false;
}
}
if (NewMode=="TEXT"){
if (sCurrMode==ModeEdit.value){
if (!confirm("警告!切换到纯文本模式会丢失您所有的HTML格式,您确认切换吗?")){
return false;
}
}
}
var sBody = "";
switch(sCurrMode){
case "CODE":
if (NewMode=="TEXT"){
HtmlEdit_Temp_HTML.innerHTML = HtmlEdit.document.body.innerText;
sBody = HtmlEdit_Temp_HTML.innerText;
}else{
sBody = HtmlEdit.document.body.innerText;
}
break;
case "TEXT":
sBody = HtmlEdit.document.body.innerText;
sBody = HTMLEncode(sBody);
break;
case "EDIT":
if (NewMode=="TEXT"){
sBody = HtmlEdit.document.body.innerText;
}else{
sBody = HtmlEdit.document.body.innerHTML;
}
break;
case "VIEW":
if (NewMode=="TEXT"){
sBody = HtmlEdit.document.body.innerText;
}else{
sBody = HtmlEdit.document.body.innerHTML;
}
break;
default:
sBody = ContentEdit.value;;
break;
}
sCurrMode = NewMode;
ModeEdit.value = NewMode;
setHTML(sBody);
}
// 替换特殊字符
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(/\n/g," ");
text = text.replace(/\t/g," ");
return text;
}
// 取编辑器的内容
function getHTML(){
var html;
if((sCurrMode=="EDIT")||(sCurrMode=="VIEW")){
html = HtmlEdit.document.body.innerHTML;
}else{
html = HtmlEdit.document.body.innerText;
}
if (sCurrMode!="TEXT"){
if ((html.toLowerCase()==" ")||(html.toLowerCase()=="")){
html = "";
}
}
return html;
}
// 设置编辑器的内容
function setHTML(html){
ContentEdit.value = html;
switch (sCurrMode){
case "CODE":
setMode0.src="Editor/images/Editor.gif";
setMode1.src="Editor/images/html2.gif";
setMode2.src="Editor/images/browse.gif";
setMode3.src="Editor/images/Text.gif";
HtmlEdit.document.designMode="on";
HtmlEdit.document.open();
HtmlEdit.document.write(edithead);
HtmlEdit.document.write(Resumeblank(html));
HtmlEdit.document.close();
HtmlEdit.document.body.innerText=Resumeblank(html);
HtmlEdit.document.body.contentEditable="true";
CurrentMode=1;
EditMode=false;
SourceMode=true;
PreviewMode=false;
bEditMode=true;
break;
case "EDIT":
setMode0.src="Editor/images/Editor2.gif";
setMode1.src="Editor/images/html.gif";
setMode2.src="Editor/images/browse.gif";
setMode3.src="Editor/images/Text.gif";
HtmlEdit.document.designMode="on";
HtmlEdit.document.open();
HtmlEdit.document.write(edithead);
HtmlEdit.document.write(html);
HtmlEdit.document.close();
doZoom(nCurrZoomSize);
CurrentMode=0;
EditMode=true;
SourceMode=false;
PreviewMode=false;
bEditMode=true;
break;
case "TEXT":
setMode0.src="Editor/images/Editor.gif";
setMode1.src="Editor/images/html.gif";
setMode2.src="Editor/images/browse.gif";
setMode3.src="Editor/images/Text2.gif";
HtmlEdit.document.designMode="on";
HtmlEdit.document.open();
HtmlEdit.document.write(edithead);
HtmlEdit.document.write(Resumeblank(html));
HtmlEdit.document.body.innerText=html;
HtmlEdit.document.body.contentEditable="true";
HtmlEdit.document.close();
CurrentMode=1
EditMode=false;
SourceMode=true;
PreviewMode=false;
bEditMode=true;
borderShown = "0";
break;
case "VIEW":
setMode0.src="Editor/images/Editor.gif";
setMode1.src="Editor/images/html.gif";
setMode2.src="Editor/images/browse2.gif";
setMode3.src="Editor/images/Text.gif";
cleanHtml();
CurrentMode=3;
HtmlEdit.document.designMode="off";
HtmlEdit.document.open();
HtmlEdit.document.write(edithead);
HtmlEdit.document.write(Resumeblank(html));
HtmlEdit.document.body.contentEditable="false";
HtmlEdit.document.close();
EditMode=false;
SourceMode=false;
PreviewMode=false;
bEditMode=false;
break;
default:
alert("错误参数调用!");
break;
}
HtmlEdit.document.onkeydown = new Function("return onKeyDown(HtmlEdit.event);");
HtmlEdit.document.oncontextmenu=new Function("return showContextMenu(HtmlEdit.event);");
HtmlEdit.document.onmouseup = new Function('return onMouseUp(HtmlEdit.event,1);');
if (borderShown != "0" && EditMode) {
borderShown = "0";
showBorders();
}
initHistory();
HtmlEdit.focus();
}
// 显示或隐藏指导方针
var borderShown = 0;
function showBorders() {
if (!document.all){
setTimeout("showBorders()",1000);
return;
}
if (!validateMode()) return;
var allForms = HtmlEdit.document.body.getElementsByTagName("FORM");
var allInputs = HtmlEdit.document.body.getElementsByTagName("INPUT");
var allTables = HtmlEdit.document.body.getElementsByTagName("TABLE");
var allLinks = HtmlEdit.document.body.getElementsByTagName("A");
// 表单
for (a=0; a < allForms.length; a++) {
if (borderShown == "0") {
allForms[a].runtimeStyle.border = "1px dotted #FF0000"
} else {
allForms[a].runtimeStyle.cssText = ""
}
}
// Input Hidden类
for (b=0; b < allInputs.length; b++) {
if (borderShown == "0") {
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 == "0") {
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 == "0") {
allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allCellsInRow[x].runtimeStyle.cssText = ""
}
}
}
}
// 链接 A
for (a=0; a < allLinks.length; a++) {
if (borderShown == "0") {
if (allLinks[a].href.toUpperCase() == "") {
allLinks[a].runtimeStyle.borderBottom = "1px dashed #000000"
}
} else {
allLinks[a].runtimeStyle.cssText = ""
}
}
if (borderShown == "0") {
borderShown = "1"
} else {
borderShown = "0"
}
scrollUp()
}
// 返回页面最上部
function scrollUp() {
HtmlEdit.scrollBy(0,0);
}
// 保存验证
function save()
{
if (CurrentMode==0){
//编辑器嵌入其他网页时使用下面这一句(请将form1改成相应表单名)
parent.myform.Content.value=HtmlEdit.document.body.innerHTML;
//单独打开编辑器时使用下面这一句(请将form1改成相应表单名)
// self.opener.form1.content.value+=HtmlEdit.document.body.innerHTML;
}
else if(CurrentMode==1){
//编辑器嵌入其他网页时使用下面这一句(请将form1改成相应表单名)
parent.myform.Content.value=HtmlEdit.document.body.innerText;
//单独打开编辑器时使用下面这一句(请将form1改成相应表单名)
// self.opener.form1.content.value+=HtmlEdit.document.body.innerText;
}
else{
alert("预览状态不能保存!请先回到编辑状态后再保存");
}
HtmlEdit.focus();
}
// 检测当前是否在预览模式
function isModeView(){
if (sCurrMode=="VIEW"){
alert("预览时不允许设置编辑区内容。");
return true;
}
return false;
}
// 在当前文档位置插入.
function insertHTML(html) {
HtmlEdit.focus();
if (isModeView()) return false;
if (HtmlEdit.document.selection.type.toLowerCase() != "none"){
HtmlEdit.document.selection.clear() ;
}
if (sCurrMode!="EDIT"){
html=HTMLEncode(html);
}
HtmlEdit.document.selection.createRange().pasteHTML(html) ;
}
//新加入功能
//插入表单表单
function Insergongneng(what){
if (! validateMode()) return;
HtmlEdit.focus();
var range = HtmlEdit.document.selection.createRange();
var ran = HtmlEdit.document.selection.createRange("").text;
switch(what){
case "input":
range.pasteHTML('');
break;
case "textarea":
range.pasteHTML('');
break;
case "radio":
range.pasteHTML('');
break;
case "checkbox":
range.pasteHTML('');
break;
case "bottom":
range.pasteHTML('');
break;
}
HtmlEdit.focus();
}
// 插入下拉菜单
function Insermenu(id){
HtmlEdit.focus();
if (! validateMode()) return;
var range = HtmlEdit.document.selection.createRange();
var ran = HtmlEdit.document.selection.createRange("").text;
var arr = showModalDialog("Editor/editor_insmenu.asp?ChannelID=1009&id="+id, "", "dialogWidth:285pt;dialogHeight:186pt;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
}
// 插入特殊符号
function Insertlr(filename,wwid,whei,myid){
if (! validateMode()) return;
HtmlEdit.focus();
var range = HtmlEdit.document.selection.createRange();
var arr = showModalDialog("Editor/"+filename+"?ChannelID=1009&id="+myid, window, "dialogWidth:"+wwid+"pt;dialogHeight:"+whei+"pt;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
}
// 缩放操作
var nCurrZoomSize = 100;
var aZoomSize = new Array(10, 25, 50, 75, 100, 150, 200, 500);
// 显示框架比例
function doZoom(size) {
HtmlEdit.document.body.runtimeStyle.zoom = size + "%";
nCurrZoomSize = size;
}
// 图片属性 上下层
function zIndex(action){
var objReference = null;
var RangeType = HtmlEdit.document.selection.type;
if (RangeType != "Control") return;
var selectedRange = HtmlEdit.document.selection.createRange();
for (var i=0; i ");
break;
case "nowdate": // 插入当前系统日期
var d = new Date();
insertHTML(d.toLocaleDateString());
break;
case "nowtime": // 插入当前系统时间
var d = new Date();
insertHTML(d.toLocaleTimeString());
break;
case "br": // 插入换行符
insertHTML(" ")
break;
case "code": // 代码片段样式
insertHTML('以下是代码片段: '+HTMLEncode(range.text)+' | ');
break;
case "quote": // 引用片段样式
insertHTML('以下是引用片段: '+HTMLEncode(range.text)+' | ');
break;
case "big": // 字体变大
insertHTML("" + range.text + "");
break;
case "small": // 字体变小
insertHTML("" + range.text + "");
break;
case "fgcolor": //字体颜色
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
var arr = showModalDialog("Editor/editor_selcolor.asp?ChannelID=1009", "", "dialogWidth:18.5em; dialogHeight:17.5em; help: no; scroll: no; status: no");
if (arr != null) format('forecolor', arr);
else HtmlEdit.focus();
break;
case "fgbgcolor": //字体背景色
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
var arr = showModalDialog("Editor/editor_selcolor.asp?ChannelID=1009", "", "dialogWidth:18.5em; dialogHeight:17.5em; help: no; scroll: no; status: no");
if (arr != null){
range.pasteHTML(""+range.text+" ");
range.select();
}
HtmlEdit.focus();
break;
case "hr": // 水平线
var arr = showModalDialog("Editor/editor_inserthr.asp?ChannelID=1009", "", "dialogWidth:30em; dialogHeight:12em; help: no; scroll: no; status: no");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "page": //分页
if(range.text!=""){
alert("请不要选择任何文本");
}
else{
range.text="\n\n[NextPage]\n\n";
parent.selectPaginationType();
}
break;
case "word": //word粘贴
HtmlEdit.document.execCommand("Paste",false);
var editBody=HtmlEdit.document.body;
for(var intLoop=0;intLoop <\/o:p>/g,"");
html=html.replace(/o:/g,"");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(//g, "");
html=html.replace(/<\/P>/g, "");
html=html.replace(/<\/SPAN>/g, "");
HtmlEdit.document.body.innerHTML = html;
format('selectall');
format('RemoveFormat');
break;
case "calculator": // 计算器
var arr = showModalDialog("Editor/editor_calculator.asp?ChannelID=1009", "", "dialogWidth:205px; dialogHeight:230px; status:0;help:0");
if (arr != null){
var ss;
ss=arr.split("*")
a=ss[0];
b=ss[1];
var str1;
str1=""+a+""
range.pasteHTML(str1);
}
HtmlEdit.focus();
break;
case "help": //帮助
var arr = showModalDialog("Editor/editor_help.asp?ChannelID=1009", "", "dialogWidth:580px; dialogHeight:460px; help: no; scroll: no; status: no");
break;
case "FIELDSET": // 栏目框
var arr = showModalDialog("Editor/editor_fieldset.asp?ChannelID=1009", "", "dialogWidth:25em; dialogHeight:12.5em; help: no; scroll: no; status: no");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "iframe": //内联页
var arr = showModalDialog("Editor/editor_insertiframe.asp?ChannelID=1009", "", "dialogWidth:30em; dialogHeight:12em; help: no; scroll: no; status: no");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "insermarquee": // 滚动文本
var arr = showModalDialog("Editor/editor_marquee.asp?ChannelID=1009", "", "dialogWidth:275pt;dialogHeight:100pt;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "inseremot": // 插入表情
var arr = showModalDialog("Editor/editor_emot.asp?ChannelID=1009", "", "dialogWidth:400px;dialogHeight:400px;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "calljsad": // 插入JS标签
var arr = showModalDialog("Editor/editor_ad.asp?ChannelID=1009", "", "dialogWidth:200px;dialogHeight:200px;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "Label": // 插入标签
var arr = showModalDialog("Editor/editor_tree.asp?ChannelID=1009", "", "dialogWidth:230pt;dialogHeight:500px;help:0;status:0");
if (arr != null){
range.pasteHTML(arr);
}
HtmlEdit.focus();
break;
case "editLabel": // 编辑标签
var oControl;
var oSeletion;
var sRangeType;
var zzz="";
oSelection = HtmlEdit.document.selection.createRange();
sRangeType = HtmlEdit.document.selection.type;
if (sRangeType == "Control") {
if (oSelection.item(0).tagName == "IMG"){
oControl = oSelection.item(0);
zzz= oControl.zzz;
}
var arr = showModalDialog("Editor/editor_label.asp?ChannelID=1009&Action=Modify&Title=修改标签&editLabel="+zzz+"", window, "dialogWidth:" + 800 + "px;dialogHeight:" + 600 + "px;help:no;scroll:yes;status:no");
if (arr != null){
oControl.zzz=arr
}
}else{
alert("不能获取到html对象!");
}
HtmlEdit.focus();
break;
case "InsertEQ": // 公式
var arr = showModalDialog("Editor/editor_inserteq.asp?ChannelID=1009", "", "dialogWidth:40em; dialogHeight:20em; status:0;help:0");
if (arr != null){
var ss;
ss=arr.split("*")
a=ss[0];
b=ss[1];
var str1;
str1=""
range.pasteHTML(str1);
}
HtmlEdit.focus();
break;
case "InstallEQ": // 安装公式
window.open ("Editor/editor_inserteq.asp?ChannelID=1009&Action=Install", "", "height=200, width=300,left="+(screen.AvailWidth-300)/2+",top="+(screen.AvailHeight-200)/2+", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
break;
case "batchpic": //批量上传图片
var arr = showModalDialog("Editor/editor_insertpic.asp?ChannelID=1009&ShowType=2", "", "dialogWidth:800px; dialogHeight:470px; help: no; scroll: yes; status: no");
if (arr != null){
var ss=arr.split("$$$");
range.pasteHTML(ss[0]);
for(var i=1;i<=ss[1];i++){
if (ss[i+1]!="None"){
parent.AddItem(ss[i+1]);
}
}
}
HtmlEdit.focus();
break;
case "pic": //上传图片
var arr = showModalDialog("Editor/editor_Modifypic.asp?ChannelID=1009&ShowType=2", window, "dialogWidth:" + 500 + "px;dialogHeight:" + 540 + "px;help:no;scroll:yes;status:no");
if (arr != null){
var ss=arr.split("$$$");
for(var i=1;i<=ss[0];i++){
if (ss[i]!=""){
parent.AddItem(ss[i]);
}
}
}
HtmlEdit.focus();
break;
case "swf": //上传swf
var arr = showModalDialog("Editor/editor_insertflash.asp?ChannelID=1009&ShowType=2", "", "dialogWidth:530px; dialogHeight:400px; help: no; scroll: yes; status: no");
if (arr != null){
var ss=arr.split("$$$");
range.pasteHTML(ss[0]);
if (ss[1]!="None"){
parent.AddItem(ss[1]);
}
}
HtmlEdit.focus();
break;
case "wmv": //上传 wmv
var arr = showModalDialog("Editor/editor_insertmedia.asp?ChannelID=1009&ShowType=2", "", "dialogWidth:530px; dialogHeight:500px; help: no; scroll: yes; status: no");
if (arr != null){
var ss=arr.split("$$$");
range.pasteHTML(ss[0]);
if (ss[1]!="None"){
parent.AddItem(ss[1]);
}
}
HtmlEdit.focus();
break;
case "Attribute": //代码框编辑
var arr = showModalDialog("Editor/editor_Attribute.asp?ChannelID=1009", window, "dialogWidth:" + 600 + "px;dialogHeight:" + 270 + "px;help:no;scroll:yes;status:no");
showBorders();
showBorders();
HtmlEdit.focus();
break;
case "rm": //上传 rm
var arr = showModalDialog("Editor/editor_insertrm.asp?ChannelID=1009&ShowType=2", "", "dialogWidth:500px; dialogHeight:500px; help: no; scroll: yes; status: no");
if (arr != null){
var ss=arr.split("$$$");
range.pasteHTML(ss[0]);
if (ss[1]!="None"){
parent.AddItem(ss[1]);
}
}
HtmlEdit.focus();
break;
case "fujian": //上传附件
var arr = showModalDialog("Editor/editor_insertfujian.asp?ChannelID=1009&ShowType=2", "", "dialogWidth:31em; dialogHeight:12em; help: no; scroll: no; status: no");
if (arr != null){
var ss=arr.split("$$$");
range.pasteHTML(ss[0]);
if (ss[1]!="None"){
parent.AddItem(ss[1]);
}
}
HtmlEdit.focus();
break;
case "title": // 设置标题
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
parent.document.myform.Title.value=range.text;
break;
case "keyword" :// 设置关键字
if (RangeType != "Text"){
alert("请先选择一段文字!");
}
if (parent.document.myform.Keyword.value==""){
parent.document.myform.Keyword.value=range.text;
}
else{
parent.document.myform.Keyword.value+="|"+range.text;
}
break;
case "ProductName":
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
parent.document.myform.ProductName.value=range.text;
break;
case "Intro":
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
parent.document.myform.Intro.value=range.text;
break;
case "ProductIntro":
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}
parent.document.myform.ProductIntro.value=range.text;
break;
case "ReplaceLabel":
var oControl;
var oSeletion;
var sRangeType;
oSelection = HtmlEdit.document.selection.createRange();
sRangeType = HtmlEdit.document.selection.type;
if (sRangeType == "Control") {
oControl = oSelection.item(0);
var arr = showModalDialog("Editor/editor_tree.asp?ChannelID=1009", "", "dialogWidth:230pt;dialogHeight:500px;help:0;status:0");
if (arr != null){
oControl.outerHTML=arr
}
}else{
alert("不能获取到html对象!");
}
HtmlEdit.focus();
break;
case "CreateLink"://链接字体
var arr = showModalDialog("Editor/editor_CreateLink.asp?ChannelID=1009&LinkName="+range.text+"", window, "dialogWidth:450px; dialogHeight:450px; help: no; scroll: no; status: no");
if (arr != null){
insertHTML(arr);
}
HtmlEdit.focus();
break;
case "pagetitle": //内容页的分页标签
var arr=showModalDialog("Editor/editor_Pagetitle.asp?ChannelID=1009","","dialogWidth:400pt;dialogHeight:80px;help:0;status:0");
if(arr!=null){
range.pasteHTML(arr);
parent.selectPaginationType();
}
HtmlEdit.focus();
break;
case "copypagetitle":
if (RangeType != "Text"){
alert("请先选择一段文字!");
return;
}else{
range.text="[NextPage" + range.text + "]\n\n" + range.text + "";
parent.selectPaginationType();
}
break;
case "FilterCode":
var arr=showModalDialog("Editor/editor_FilterCode.asp?ChannelID=1009","","dialogWidth:400pt;dialogHeight:340px;help:0;status:0");
if(arr!=null){
var ss=arr.split(",");
var strhtml=HtmlEdit.document.body.innerHTML
if (ss[0] == "true"){
strhtml = ScriptHtml(strhtml, "Iframe", 2,"")
}
if (ss[1] == "true"){
strhtml = ScriptHtml(strhtml, "Object", 2,"")
}
if (ss[2] == "true"){
strhtml = ScriptHtml(strhtml, "Script", 2,"")
}
if (ss[3] == "true"){
strhtml = ScriptHtml(strhtml, "Style", 2,"")
}
if (ss[4] == "true"){
strhtml = ScriptHtml(strhtml, "Div", 2,"")
}
if (ss[5] == "true"){
strhtml = ScriptHtml(strhtml, "Span", 2,"")
}
if (ss[6] == "true"){
strhtml = ScriptHtml(strhtml, "Table", 2,"")
}
if (ss[7] == "true"){
strhtml = ScriptHtml(strhtml, "Table", 3,"")
strhtml = ScriptHtml(strhtml, "Tbody", 3,"")
strhtml = ScriptHtml(strhtml, "Tr", 3,"")
strhtml = ScriptHtml(strhtml, "Td", 3,"")
strhtml = ScriptHtml(strhtml, "Th", 3,"")
}
if (ss[8] == "true"){
strhtml = ScriptHtml(strhtml, "IMG", 1,"")
}
if (ss[9] == "true"){
strhtml = ScriptHtml(strhtml, "Font", 3,"")
}
if (ss[10] == "true"){
strhtml = ScriptHtml(strhtml, "A", 3,"")
}
if (ss[11] == "true"){
strhtml = ScriptHtml(strhtml, "Font", 4,ss[12])
}
HtmlEdit.document.designMode="on";
HtmlEdit.document.open();
HtmlEdit.document.write(edithead);
HtmlEdit.document.write(strhtml);
HtmlEdit.document.close();
doZoom(nCurrZoomSize);
CurrentMode=0;
EditMode=true;
SourceMode=false;
PreviewMode=false;
bEditMode=true;
}
break;
default:
alert("错误参数调用!");
break;
}
range=null;
}
// 暂时解决一下通用性问题 查找
function findstr(){
var arr = showModalDialog("Editor/editor_find.asp?ChannelID=1009", window, "dialogWidth:320px; dialogHeight:170px; help: no; scroll: no; status: no");
}
// 插入文件函数组 函数组结速
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|