⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etsooeditor.js

📁 TurboCWCShop v1.6.7 is make in the Utility-LAYer Framework.
💻 JS
📖 第 1 页 / 共 5 页
字号:
		arrItems=arrItems.concat("NewLine","");
		arrItems=arrItems.concat(arrAdd);
	}
	if(objE.nodeName!="BODY"){
		if(numLen==0)arrItems=arrItems.concat("NewLine","");
		arrItems=arrItems.concat("ControlProperty",this.OtherLangs[4],"CssProperty",this.OtherLangs[5]);
	}
	return arrItems;
}
//编辑域粘贴
ETSOOEditor._DocOnPaste=function(){
	if(ETSOOEditor.AutoClearWord){
		var strHtml=ETSOOEditor._GetSavedHTML();
		var regWord=/<\w[^>]* class="?MsoNormal"?/gi;
		if(regWord.test(strHtml)){
			ETSOOEditor._ClearAndInsertWordHtml(strHtml);
			return false;
		}
	}
}
//编辑域Word文件信息
ETSOOEditor._GetSavedHTML=function(){
	var strHtml;
	if(ETSOOEditor.Browser>=105.5){
		var objDiv=document.getElementById("ETSOOEditorTempleData");
		objDiv.innerHTML="";
		var objRange=document.body.createTextRange();
		objRange.moveToElementText(objDiv);
		objRange.execCommand("Paste");
		strHtml=objDiv.innerHTML;
		objDiv.innerHTML="";
	}else if(window.clipboardData){
		strHtml=window.clipboardData.getData("Text");
		if(strHtml==null)strHtml="";
		strHtml=strHtml.replace(/\n\n/gi,"<p>");
		strHtml=strHtml.replace(/\n/gi,"<br>");
		strHtml=strHtml.replace(/(  ){2}/gi,"&nbsp;&nbsp;&nbsp;&nbsp;");
		strHtml=strHtml.replace(/(&nbsp;){5,}/gi," " );
	}
	return strHtml;
}
//去除多余字符
ETSOOEditor._ClearAndInsertWordHtml=function(strHtml){
	strHtml=strHtml.replace(/<\/?SPAN[^>]*>/gi,"");
	strHtml=strHtml.replace(/<(\w[^>]*)\s+class=([^ |>]*)([^>]*)/gi,"<$1$3");
	strHtml=strHtml.replace(/<(\w[^>]*)\s+style="([^"]*)"([^>]*)/gi,"<$1$3");
	strHtml=strHtml.replace(/<(\w[^>]*)\s+lang=([^ |>]*)([^>]*)/gi,"<$1$3");
	strHtml=strHtml.replace(/<\\?\?xml[^>]*>/gi,"");
	strHtml=strHtml.replace(/<\/?\w+:[^>]*>/gi,"");
	strHtml=strHtml.replace(/(&nbsp;){5,}/gi," " );
	this.InsertHTML(strHtml);
}
//选择域发生变化
ETSOOEditor._DocOnSelectionChange=function(strAction,strAdd){
	if(ETSOOEditor.ReadyState==0)return;
	if(!ETSOOEditor.ActiveStatus)return;
	var arrObj=ETSOOEditor.GetRange();
	if(arrObj==null)return false;
	var objBody=arrObj[1];
	var objSelection=arrObj[2];
	var objRange=arrObj[3];
	var objTarget,numType=0;
	var numAbsPos=0,numCut=0;
	var numBrowser=ETSOOEditor.Browser;
	if(objRange){
		if(objRange.length==null){
			objTarget=objRange.parentElement();
			if(objTarget){
				var numNodeType=objTarget.nodeType;
				var strText=objRange.text;
				if(numNodeType==1||numNodeType==3){
					if(objTarget.nodeName=="BODY"||objTarget.nodeName=="BR")numCut=-1;
					if(objTarget.nodeName=="BODY"&&strText!="")numCut=0;
					if(numNodeType==3||numBrowser>100)numCut=(strText=="")?-1:0;
				}else{
					numCut=-1;
				}
			}
		}else{
			objTarget=objRange(0);
		}
		if(objTarget&&objTarget.style&&objTarget.style.position=="absolute")numAbsPos=1;
	}
	ETSOOEditor.ActiveTarget=objTarget;
	ETSOOEditor._SetButton("AbsolutePos",numAbsPos);
	if(numCut==-1)ETSOOEditor.SetDefault("EELink");
	ETSOOEditor._SetButton("Cut",numCut);
	ETSOOEditor._SetButton("Copy",numCut);
	ETSOOEditor._SetButton("Delete",numCut);
	ETSOOEditor._SetButton("Link",numCut);
	var strFont=ETSOOEditor._GetValue(objTarget,"FONT;","face",null,0);
	if(numBrowser<100&&!strFont)strFont=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontFamily",null,1);
	ETSOOEditor._SetButton("FontSet",strFont);
	var strSize=strSize=ETSOOEditor._GetValue(objTarget,"FONT;","size",null,0);
	if(numBrowser<100&&!strSize)strSize=ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontSize",null,1);
	ETSOOEditor._SetButton("FontSize",strSize);
	if(ETSOOEditor.GetTarget(objTarget,"B")!=null||ETSOOEditor.GetTarget(objTarget,"STRONG")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontWeight","bold",1))numType=1;
	ETSOOEditor._SetButton("Bold",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"I")!=null||ETSOOEditor.GetTarget(objTarget,"EM")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","fontStyle","italic",1))numType=1;
	ETSOOEditor._SetButton("Italic",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"U")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","underline",1))numType=1;
	ETSOOEditor._SetButton("Underline",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"STRIKE")!=null||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textDecoration","line-through",1))numType=1;
	ETSOOEditor._SetButton("StrikeThrough",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","left",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","left",1))numType=1;
	ETSOOEditor._SetButton("Left",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","center",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","center",1))numType=1;
	ETSOOEditor._SetButton("Center",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","right",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","right",1))numType=1;
	ETSOOEditor._SetButton("Right",numType);numType=0;
	if(ETSOOEditor._GetValue(objTarget,"P;","align","justify",0)||ETSOOEditor._GetValue(objTarget,"P;DIV;SPAN;","textAlign","jusfity",1))numType=1;
	ETSOOEditor._SetButton("Full",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"OL")!=null)numType=1;
	ETSOOEditor._SetButton("OrderList",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"UL")!=null)numType=1;
	ETSOOEditor._SetButton("UnorderList",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"SUP")!=null)numType=1;
	ETSOOEditor._SetButton("SuperScript",numType);numType=0;
	if(ETSOOEditor.GetTarget(objTarget,"SUB")!=null)numType=1;
	ETSOOEditor._SetButton("SubScript",numType);numType=0;
	var objTable=ETSOOEditor.GetTarget(this.ActiveTarget,"TABLE");
	if(objTable==null)ETSOOEditor.SetDefault("EETable");
	var objForm=ETSOOEditor.GetTarget(this.ActiveTarget,"FORM");
	if(objForm==null)ETSOOEditor.SetDefault("EEForm");
}
//恢复默认图标
ETSOOEditor.SetDefault=function(strId){
	var objDiv=this.MenuBar;
	if(objDiv==null)return false;
	var arrImages=objDiv.getElementsByTagName("IMG");
	var numLen=arrImages.length;
	for(var numI=0;numI<numLen;numI++){
		var objOne=arrImages[numI];
		if(objOne.id=="EEMore"&&objOne.getAttribute("menutarget")==strId){
			var objNext=objOne.previousSibling;
			if(objNext.id!=strId){
				objNext.id=strId;
				objNext.title=objNext.getAttribute("basetitle");
				objNext.src=this.GetImgSrc(strId.substr(2).toUpperCase());
				objOne.setAttribute("target",strId);
			}
			break;
		}
	}
}
//获得指定值
ETSOOEditor._GetValue=function(objTarget,strTagName,strProperty,strValue,numType){
	blnFind=false;
	var strOK='';
	while(objTarget){
		var strNodeName=objTarget.nodeName.toUpperCase();
		if(strNodeName=="BODY")break;
		if(strTagName.indexOf(strNodeName+";")!=-1){
			var strBaseValue;
			strOK+=strValue;
			if(numType==0)strBaseValue=objTarget.getAttribute(strProperty);
			else if(objTarget.style)strBaseValue=eval("objTarget.style."+strProperty);
			if(strBaseValue==null)strBaseValue="";
			strBaseValue=strBaseValue.toLowerCase();
			if(strValue==null){
				if(strBaseValue!=""){
					return strBaseValue;break;
				}
			}else if(strBaseValue.indexOf(strValue)!=-1){
				blnFind=true;break;
			}
		}
		objTarget=objTarget.parentNode;
	}
	return blnFind;
}
//设置图标
ETSOOEditor._SetButton=function(strId,numType){
	var objE=this.GetObj("EE"+strId);
	if(objE){
		if(strId=="FontSet"||strId=="FontSize"){
			var numLen=objE.length,blnSet=false;
			for(var numI=0;numI<numLen;numI++){
				var objOne=objE.options[numI];
				if(objOne.value==numType){
					objOne.selected=true;
					blnSet=true;
					break;
				}
			}
			if(!blnSet)objE.options[0].selected=true;
		}else{
			strId=strId.toUpperCase();
			this._SetButtonAdd(objE,strId,numType);
			var objNext=objE.nextSibling;
			if(objNext!=null&&objNext.id!="EEMore")objNext=null;
			if(objNext)this._SetButtonAdd(objNext,"MORE",numType);
		}
	}
}
//补充
ETSOOEditor._SetButtonAdd=function(objE,strId,numType){
	var strSrc=objE.src;
	objE.className="";
	if(numType>=0){
		if(strSrc.indexOf("disabled.gif")!=-1)objE.src=this.GetImgSrc(strId);
		if(numType==0)this.MouseOut(objE);
		else{
			if(strId!="MORE"){
				this.MouseDown(objE);
				objE.className="Keep";
			}
		}
	}else if(numType==-1){
		if(strSrc.indexOf("disabled.gif")==-1)objE.src=this.GetImgSrc(strId+"DISABLED");
		this.MouseOut(objE);
		objE.className="Disabled";
	}
}
//获得目标
ETSOOEditor.GetTarget=function(objE,strTagName){
	while(objE&&(objE.nodeName.toUpperCase()!=strTagName))objE=objE.parentNode;
	return objE;
}
//模式切换
ETSOOEditor._SetMode=function(objDocument,strValue){
	var blnIE5=(objDocument.body.contentEditable==null);
	var blnValue=(strValue=="on")?true:false;
	if(blnIE5)objDocument.designMode=strValue;
	else objDocument.body.contentEditable=blnValue;
	return blnIE5;
}
//获得字符集
ETSOOEditor._GetCharset=function(){
	return (this.Browser>100)?document.defaultCharset:document.characterSet;
}
//设置颜色提示显示
ETSOOEditor._SetShow=function(strId){
	var objShow=this.GetObj(strId+"_Show");
	if(objShow==null)return false;
	var objImg=this.GetObj(strId);
	var arrPos=ETSOOGetPos(objImg);
	var numLeft=arrPos[0]+4;
	var numTop=arrPos[1]+16;
	if(window.Node){
		numLeft-=1;
		numTop-=1;
	}
	var strBgColor=(strId=="EEForeColor")?"#000000":"#FFFFFF";
	with(objShow.style){
		backgroundColor=strBgColor;
		left=numLeft+"px";
		top=numTop+"px";
		display="block";
	}
}
//初始化设置编辑域
ETSOOEditor._SetFieldContent=function(){
	var blnIE=(this.Browser>100);
	var blnIE5=(this.Browser==105);
	var blnHave=false;
	var blnActiveStatus=this.ActiveStatus;
	for(strField in this.Fields){
		if(!blnHave)blnHave=true;
		var objField=this.Fields[strField];
		if(this.ActiveField==null)this.ActiveField=objField;
		var strBaseContent=objField.Content;
		var objTextArea=objField.TextArea;
		if(objTextArea.value!="")strBaseContent=objTextArea.value;
		else objTextArea.value=strBaseContent;
		var objDiv=objField.Div;
		var numShowMode=objDiv.getAttribute("ShowMode");
		var objDocument=objField.FrameWindow.document;
		var numShowMargin=objField.Div.getAttribute("ShowMargin");
		var strPath=this.Path;
		if(blnIE)
		{
			objField.History=new this.History(objField);
			objField.History.Data[0]=strBaseContent;
			window.attachEvent("onbeforeunload",this._FrameOnBlur);
			objField.FrameDocument.attachEvent("onfocus",this._FrameOnFocus);
			var strCharset=this._GetCharset();
			var strBody='<html><head>';
			strBody+='<meta http-equiv="Content-Type" content="text/html; charset='+strCharset+'">';
			strBody+='<style>TD,OBJECT,EMBED,FORM{border:1px dotted #111111}';
			strBody+='A{padding-left:12px;background-image:url('+strPath+'Images/anchor_show.gif);background-repeat:no-repeat}</style>\n';
			if(!blnIE5){
				objField.FrameDocument.attachEvent("onblur",this._FrameOnBlur);
			}
			else{
				document.attachEvent("onmousedown",this._FrameOnBlur);
				window.attachEvent("onblur",this._FrameOnBlur);
			}
			strBody+='<style>\n';
			strBody+='v\\:* {behavior: url(#default#VML);}\n';
			strBody+='o\\:* {behavior: url(#default#VML);}\n';
			strBody+='.shape{behavior: url(#default#VML);}\n';
			strBody+='body,td{font-size:9pt}\n';
			strBody+='</style>\n';
			strBody+='<XML:NAMESPACE NS="urn:schemas-microsoft-com:vml" PREFIX="v"/>\n';
			strBody+='<base target="_blank"></head>\n';
			strBody+='<body onmousedown="return parent.ETSOOEditor._DocOnClick(event)" onkeydown="return parent.ETSOOEditor._DocOnKeyPress(event)"';
			strBody+=' onpaste="return parent.ETSOOEditor._DocOnPaste(event);" style="margin:'+(numShowMargin==0?0:12)+'px"';
			strBody+=' oncontextmenu="return parent.ETSOOEditor._DocOnContextMenu(event)" ondblclick="return parent.ETSOOEditor._DocOnDblClick(event)"';
			strBody+=' onmouseup="return parent.ETSOOEditor._DocMouseUp(event)"';
			if(blnActiveStatus)strBody+=' onkeyup="return parent.ETSOOEditor._DocOnSelectionChange(event)" onselectionchange="return parent.ETSOOEditor._DocOnSelectionChange(event)"';
			strBody+='>'+strBaseContent+'</body></html>';
			objDocument.open();
			objDocument.write(strBody);
			objDocument.close();
			objDocument.execCommand("LiveResize",false,true);
			objDocument.execCommand("2D-Position",false,true);
			objDocument.execCommand("MultipleSelection",false,true);
			this._SetMode(objDocument,"on");
		}else{
			window.addEventListener('unload',this._FrameOnBlur , true);
			objDocument.addEventListener('blur',this._FrameOnBlur , true);
			objDocument.addEventListener('focus',this._FrameOnFocus , true);
			objDocument.addEventListener('mousedown',this._DocOnClick , true);
			objDocument.addEventListener('keydown',this._DocOnKeyPress , true);
			objDocument.addEventListener('contextmenu',this._DocOnContextMenu , true);
			objDocument.addEventListener('dblclick',this._DocOnDblClick , true);
			objDocument.addEventListener('mouseup',this._DocMouseUp, true);
			if(blnActiveStatus)objDocument.addEventListener('keyup',this._DocOnSelectionChange , true);
			var objBody=objDocument.body;
			var objHead=objDocument.createElement("head");
			objHead=objDocument.documentElement.insertBefore(objHead,objBody);
			var objStyle=objDocument.createElement("style");
			objStyle.innerHTML='TD,OBJECT,EMBED,FORM{border:1px dotted #111111};A{padding-left:12px;background-image:url('+strPath+'Images/anchor_show.gif);background-repeat:no-repeat}';
			objHead.appendChild(objStyle);
			objBody.bgColor="#FFFFFF";
			with(objBody.style){
				margin=(numShowMargin==0?0:12)+"px";
				fontSize="9pt";
			}
			objBody.innerHTML=strBaseContent;
			objDocument.id=objField.FrameDocument.id;
			objDocument.designMode="on";
		}
		if(numShowMode==1||numShowMode==2){
			var objOneDiv=objDiv.getElementsByTagName("div")[0];
			ETSOOEditor.MouseDown(objOneDiv);
			this.MouseClick(objOneDiv,true);
		}
		objDiv.style.visibility="visible";
	}
	this._SetShow("EEForeColor");
	this._SetShow("EEBgColor");
	ETSOOPopup._SetAddEvent(window);
	if(blnIE&&!blnIE5){
		var objDiv=document.createElement("div");
		objDiv.id="ETSOOEditorTempleData";
		with(objDiv.style){
			visibility="hidden";
		}
		objDiv.setAttribute("contentEditable",true);
		document.body.insertAdjacentElement("beforeEnd",objDiv);
	}
	if(blnHave){
		this.ReadyState=1;
		if(blnIE){
			if(blnActiveStatus){
				this._SetButton("Redo",-1);
				this._SetButton("Undo",-1);
			}
			var numLen=document.forms.length;
			for(var numI=0;numI<numLen;numI++){
				var objForm=document.forms[numI];
				if(blnIE)objForm.attachEvent("onsubmit",this._FormOnSubmit);
				else objForm.addEventListener('submit',this._FormOnSubmit, true);
			}
		}
		if(!blnIE5&&blnActiveStatus)this._DocOnSelectionChange();
	}
}
if(ETSOOEditor.Browser>100)window.attachEvent("onload",function(){ETSOOEditor._SetFieldContent()});
else window.addEventListener("load",function(){ETSOOEditor._SetFieldContent()},false);
//执行execCommand命令
ETSOOEditor.Command=function(objActive,objE,objEvent){

⌨️ 快捷键说明

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