editor.asp

来自「1.理解Winsock编程模型; 2.掌握Winsock编程的基本方法」· ASP 代码 · 共 1,656 行 · 第 1/5 页

ASP
1,656
字号

  if (element.YUSERONCLICK) eval(element.YUSERONCLICK +	"anonymous()");

  element.className = "BtnMenuMouseOverUp";
  image.className = "Ico";

  event.cancelBubble = true;
  return false;
}

function cleanHtml()
{
  var fonts = HtmlEdit.document.body.all.tags("FONT");
  var curr;
  for (var i = fonts.length - 1; i >= 0; i--) {
    curr = fonts[i];
    if (curr.style.backgroundColor == "#ffffff") curr.outerHTML	= curr.innerHTML;
  }
}

function validateMode()
{
  if (EditMode) return true;
  alert("请先点编辑器下方的“编辑”按钮,进入“编辑”状态,然后再使用系统编辑功能!");
  HtmlEdit.focus();
  return false;
}

function UserDialog(what)
{
  if (!validateMode()) return;

  HtmlEdit.document.execCommand(what, true);

  pureText = false;
  HtmlEdit.focus();
}

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 setMode(newMode)
{
  var cont;
  if (CurrentMode==newMode){
    return false;
  }
  
  if (newMode==0)
  {
	setMode0.src="Images/Editor/Editor2.gif";
	setMode1.src="Images/Editor/html.gif";
	setMode2.src="Images/Editor/browse.gif";
	if (PreviewMode){
	  document.all.HtmlEdit.style.display="";
	  document.all.HtmlPreview.style.display="none";
	}
	if(SourceMode){
	  cont=HtmlEdit.document.body.innerText;
	
	HtmlEdit.document.designMode="On";
      HtmlEdit.document.body.innerHTML=cont;
	HtmlEdit.document.body.contentEditable="true";
	HtmlEdit.document.oncontextmenu=new Function("return showContextMenu(eWebEditor.event);");
	HtmlEdit.document.execCommand("2D-Position",true,true);
	HtmlEdit.document.execCommand("MultipleSelection", true, true);
	}
    EditMode=true;
	SourceMode=false;
	PreviewMode=false;
  }
  else if (newMode==1)
  {
	setMode0.src="Images/Editor/Editor.gif";
	setMode1.src="Images/Editor/html2.gif";
	setMode2.src="Images/Editor/browse.gif";
	if (PreviewMode){
	  document.all.HtmlEdit.style.display="";
	  document.all.HtmlPreview.style.display="none";
	}
	if(EditMode){
	  cleanHtml();
      cleanHtml();
      cont=HtmlEdit.document.body.innerHTML;
      HtmlEdit.document.body.innerText=cont;
	}
    EditMode=false;
	SourceMode=true;
	PreviewMode=false;
  }
  else if (newMode==2)
  {
	setMode0.src="Images/Editor/Editor.gif";
	setMode1.src="Images/Editor/html.gif";
	setMode2.src="Images/Editor/browse2.gif";
	var str1="<head><style type=\"text/css\">body {font-size:	9pt}</style><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#F6F6F6\" MONOSPACE>";
	if(CurrentMode==0){
	  str1=str1+HtmlEdit.document.body.innerHTML;
	}
	else{
	  str1=str1+HtmlEdit.document.body.innerText;
	}
    HtmlPreview.document.open();
	HtmlPreview.document.write(str1);
    HtmlPreview.document.close();
    document.all.HtmlEdit.style.display="none";
	document.all.HtmlPreview.style.display="";
	PreviewMode=true;
  }
  CurrentMode=newMode;
  HtmlEdit.focus();
}

function foreColor()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var RangeType = HtmlEdit.document.selection.type;
  if (RangeType != "Text"){
    alert("请先选择一段文字!");
    return;
  }
  var arr = showModalDialog("editor_selcolor.asp", "", "dialogWidth:18.5em; dialogHeight:17.5em; help: no; scroll: no; status: no");
  if (arr != null) format('forecolor', arr);
  else HtmlEdit.focus();
}

function backColor()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var RangeType = HtmlEdit.document.selection.type;
  if (RangeType != "Text"){
    alert("请先选择一段文字!");
    return;
  }
  var arr = showModalDialog("editor_selcolor.asp", "", "dialogWidth:18.5em; dialogHeight:17.5em; help: no; scroll: no; status: no");
  if (arr != null){
    range.pasteHTML("<span style='background-color:"+arr+"'>"+range.text+"</span> ");
	range.select();
  }
  HtmlEdit.focus();
}
function page()
{
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  if(range.text!=""){
    alert("请不要选择任何文本");
  }
  else{
    range.text="\n\n[NextPage]\n\n";
	parent.selectPaginationType()
  }
}

function InsertTable()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_inserttable.asp", "", "dialogWidth:450px;dialogHeight:200px;help: no; scroll: no; status: no");

  if (arr != null){
	range.pasteHTML(arr);
  }
  HtmlEdit.focus();
}

function FIELDSET()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_fieldset.asp", "", "dialogWidth:25em; dialogHeight:12.5em; help: no; scroll: no; status: no");
  if (arr != null){
    range.pasteHTML(arr);
  }
  HtmlEdit.focus();
}

function iframe()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_insertiframe.asp", "", "dialogWidth:30em; dialogHeight:12em; help: no; scroll: no; status: no");  
  if (arr != null){
    range.pasteHTML(arr);
  }
  HtmlEdit.focus();
}

function hr()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_inserthr.asp", "", "dialogWidth:30em; dialogHeight:12em; help: no; scroll: no; status: no"); 
  if (arr != null){
    range.pasteHTML(arr);
  }
  HtmlEdit.focus();
}

function pic()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_insertpic.asp", "", "dialogWidth:31em; dialogHeight:17em; help: no; scroll: no; status: no");  
  if (arr != null){
    var ss=arr.split("$$$");
    range.pasteHTML(ss[0]);
    parent.myform.IncludePic.checked=true;
	if (ss[1]!="None")
	{
	  parent.AddItem(ss[1]);
	}
  }
  HtmlEdit.focus();
}

function swf()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_insertflash.asp", "", "dialogWidth:31em; dialogHeight:12em; help: no; scroll: no; status: no"); 
  if (arr != null){
    var ss=arr.split("$$$");
    range.pasteHTML(ss[0]);
    parent.myform.IncludePic.checked=true;
	if (ss[1]!="None")
	{
	  parent.AddItem(ss[1]);
	}
  }
  HtmlEdit.focus();
}

function wmv()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_insertmedia.asp", "", "dialogWidth:31em; dialogHeight:12em; help: no; scroll: no; status: no");
  if (arr != null){
    var ss=arr.split("$$$");
    range.pasteHTML(ss[0]);
    parent.myform.IncludePic.checked=true;
	if (ss[1]!="None")
	{
	  parent.AddItem(ss[1]);
	}
  }
  HtmlEdit.focus();
}


function rm()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("editor_insertrm.asp", "", "dialogWidth:31em; dialogHeight:12em; help: no; scroll: no; status: no");  
  if (arr != null){
    var ss=arr.split("$$$");
    range.pasteHTML(ss[0]);
    parent.myform.IncludePic.checked=true;
	if (ss[1]!="None")
	{
	  parent.AddItem(ss[1]);
	}
  }
  HtmlEdit.focus();
}

function excel()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range =HtmlEdit.document.selection.createRange();
  var str1="<object classid='clsid:0002E510-0000-0000-C000-000000000046' id='Spreadsheet1' codebase='file:\\Bob\software\office2000\msowc.cab' width='100%' height='250'><param name='EnableAutoCalculate' value='-1'><param name='DisplayTitleBar' value='0'><param name='DisplayToolbar' value='-1'><param name='ViewableRange' value='1:65536'></object>";
  range.pasteHTML(str1);
  HtmlEdit.focus();
}

//  雪冰+ save()
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 nowdate()
{
  if (!	validateMode())	return;
  HtmlEdit.focus();
  var range =HtmlEdit.document.selection.createRange();
  var d = new Date();
  var str1=d.getYear()+"年"+(d.getMonth() + 1)+"月"+d.getDate() +"日";

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?