📄 core2.js
字号:
var _sContent=this._getPrimitiveData();var _sContent=this._stripData(_sContent);this.bExceedMaxLen=this._exceedMaxLen(_sContent);if(this.bHarm){this.setData(_sContent);}this._saveDataForSubmit(_sContent);return _sContent;},getPrevContent:function(){var _sContent=this._getPrimitiveData();var _sContent=this._stripData(_sContent);return _sContent;},getTitle:function(){if(this.oTitle){if(this.oTitle.value==this.titleHint)return"";elsereturn this.oTitle.value;}return null;},setTitle:function(sTitle){if(this.oTitle)this.oTitle.value=sTitle;},_getPrimitiveData:function(){var _sContent;if(this.currMode=="Design"){_sContent=this.oFrameBody.innerHTML;}else{_sContent=this.sourceEditor.value;}if(_sContent==this.editorHint)_sContent='';_sContent=_sContent.replace(/<\\?\?xml[^>]*>/ig,"");_sContent=_sContent.replace(/<\/?\w+:[^>]*>/ig,"");return _sContent;},_stripData:function(sContent){var _oResult;if(this.options.bSimpleEditor){_oResult=stripData(sContent,"");}else{_oResult=stripData(sContent,["embed","style"]);}this.bHarm=_oResult.isHarm;var _sContent=_oResult.content;return _sContent;},setData:function(sContent){if(this.currMode=="Design"){this.oFrameBody.innerHTML=sContent;}else{this.sourceEditor.value=sContent;}},emptyContent:function(){this.oFrameBody.innerHTML="";},_saveDataForSubmit:function(sContent){$("HEContent"+this.parentId).value=sContent;},_exceedMaxLen:function(sContent){var pureText=this.clearAllTag(sContent);if(pureText.length>this.options.iMaxLen||sContent.length>this.options.iMaxLen*5){return true;}elsereturn false;},hasHarmCode:function(){return this.bHarm;},IsExceedMaxLen:function(){return this.bExceedMaxLen;},goPreview:function(){var _htmlData=this.getPrevContent();if(this.options.fnPreview!=null)this.options.fnPreview(_htmlData);},focus:function(){this.designEditor.focus();},setEditorWidth:function(iWidth){this.oFrame.width=iWidth+"px";$("editorWrap"+this.parentId).style.width=iWidth+"px";},clearAllTag:function(sContent){return sContent.replace(/<\/?.*?>/ig,"");},_clearAllFormat:function(sTxt){try{var c=sTxt.replace(/\n/ig,"");c=c.replace(/<script.*?>.*?<\/scrip[^>]*>/ig,"");c=c.replace(/<[^>]*?javascript:[^>]*>/ig,"");c=c.replace(/<style.*?>.*?<\/styl[^>]*>/ig,"");c=c.replace(/<\/?(font|span|center|sohu|form|input|select|textarea|iframe|strong|b|EM|U|SUB|SUP)(\s[^>]*)?>/ig,"");c=c.replace(/<\/?(div|code|h\d)[^>]*>/ig,'<br>');c=c.replace(/<\?xml[^>]*>/ig,'');c=c.replace(/<\!--.*?-->/ig,'');c=c.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/ig,"<$1$3");c=c.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/ig,"<$1$3");c=c.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/ig,"<$1$3");c=c.replace(/<\\?\?xml[^>]*>/ig,"");c=c.replace(/<\/?\w+:[^>]*>/ig,"");c=c.replace(/<img.*?src=([^ |>]*)[^>]*>/ig,"<img src=$1 border=0>");c=c.replace(/<a.*?href="([^"]*)"[^>]*>/ig,"<a href=\"$1\">");c="MM163brMM"+c;c=c.replace(/<br>\s*<br>/ig,'MM163brMM');c=c.replace(/<center>\s*<center>/ig,'<center>');c=c.replace(/<\/center>\s*<\/center>/ig,'</center>');c=c.replace(/<center>/ig,'MM163brMM<center>');c=c.replace(/<\/center>/ig,'</center>MM163brMM');c=c.replace(/<br>/ig,'MM163brMM');c=c.replace(/<p[^>]*>/ig,'MM163brMM');c=c.replace(/<\/p[^>]*>/ig,'');c=c.replace(/(\r|\n)/ig,'');c=c.replace(/MM163brMM\s*MM163brMM/ig,'MM163brMM');c=c.replace(/MM163brMM/ig,'</P><P style="TEXT-INDENT: 2em">');c=c.replace("</P>","");return c;}catch(e){}},_clearHTMLFormat:function(){if(confirm('"清除格式"将修改文章的格式,确定清除? ')){var bSelected=true;if(this.isIE){var rng=this.designEditorDoc.selection.createRange();if(rng.text=="")bSelected=false;}else{var rng=this.designEditor.getSelection().getRangeAt(0);if(rng.collapsed)bSelected=false;}if(bSelected){this.format("removeformat");}else{var _sValue=this.oFrameBody.innerHTML;try{this.oFrameBody.innerHTML=this._clearAllFormat(_sValue);}catch(e){}}}return;},_checkIfHTMLTxt:function(sTxt){var r=/<\/?(span|div|h2|h3|code|center|form|input|select|textarea|iframe|img|a).*?>/ig;if(r.test(sTxt))return true;elsereturn false;},_paraFormating:function(){var _sValue=this.oFrameBody.innerHTML;var _reg=/<P>(.*)<\/P>/g;var _sResult=_sValue.replace(_reg,'<P style="TEXT-INDENT: 2em">$1</P>');this.oFrameBody.innerHTML=_sResult;return;}}if(NECtrl==undefined){var NECtrl={};}NECtrl.ColorPanel=Class.create();NECtrl.ColorPanel._ColorHex=['00','33','66','99','CC','FF'];NECtrl.ColorPanel._SpColorHex=['FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF'];NECtrl.ColorPanel._picSrc="http://st.blog.163.com/style/common/htmlEditor/place.gif";NECtrl.ColorPanel.prototype={initialize:function(sParentId,oHtmlEditor,sObjName){this._sParentId=sParentId;this._oHtmlEditor=oHtmlEditor;this._sObjName=sObjName;this._oCurrentColor=null;this.simpleHTML=null;this.fullHTML=null;if(document.all)this.isIE=true;else this.isIE=false;},display:function(oColorDiv,sColorType){this._displaySimpleColorBoard(oColorDiv,sColorType);},colorTxtOvr:function(event){var e=Event.element(event);e.style.border="1px #000080 solid";e.style.backgroundColor="#FFEEC2";},colorTxtOut:function(event){var e=Event.element(event);e.style.border="1px white solid";e.style.backgroundColor="white";},_drawSimpleColorPanel:function(){var a=[];a.push('<div style="border:1px #9FAC87 solid; width:158px;background-color:white;">');a.push('<div style="position:relative;margin-left:2px; margin-top:3px; margin-bottom:0px;height:19px">');a.push('<img id="colorClear'+this._sParentId+'" src="http://st.blog.163.com/style/common/htmlEditor/simple_colr_remove.gif" style="width:150px;height:17px;background-color:white;border:1px solid #FFFFFF;cursor:pointer;" />');a.push('<div id="colorPrez'+this._sParentId+'" style="position:absolute;top:3px;left:4px;border:1px solid #ACA899;font-size:1px;width:28px;height:11px;"> </div>');a.push('</div>');a.push('<div>');a.push('<table class="g_c_clrpd" id="colorSelectPanel'+this._sParentId+'" cellspacing="6" cellpadding="0" style="border-collapse:separate;">');a.push('<tr>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#000000; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="黑色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#993300; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="褐色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#333300; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="橄榄色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#003300; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="深绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#003366; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="深青"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#000080; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="深蓝"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#333399; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="靛蓝"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#333333; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="灰色-80%"></img></td>');a.push('</tr><tr>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#800000; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="深红"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FF6600; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="橙色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#808000; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="深黄"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#008000; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="绿色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#008080; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="青色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#0000FF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="蓝色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#666699; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="蓝-灰"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#808080; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="灰色-50%"></img></td>');a.push('</tr><tr>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FF0000; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="红色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FF9900; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="浅橙色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#99CC00; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="酸橙色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#339966; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="海绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#33CCCC; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="水绿色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#3366FF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="浅蓝"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#800080; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="紫罗兰"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#999999; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="灰色-40%"></img></td>');a.push('</tr><tr>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FF00FF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="粉红"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FFCC00; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="金色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FFFF00; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="黄色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#00FF00; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="鲜绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#00FFFF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="青绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#00CCFF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="天蓝"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#993366; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="梅红"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#C0C0C0; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="灰色-25%"></img></td>');a.push('</tr><tr>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FF99CC; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="玫瑰红"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FFCC99; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="茶色"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FFFF99; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="浅黄"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#CCFFCC; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="浅绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#CCFFFF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="浅青绿"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#99CCFF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="淡蓝"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#CC99FF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="淡紫"></img></td>');a.push('<td><img src="'+NECtrl.ColorPanel._picSrc+'" style="background-color:#FFFFFF; border:1px solid #ACA899;font-size:1px;width:11px;height:11px; cursor:pointer" title="白色"></img></td>');a.push('</tr>');a.push('</table>');a.push('</div>');a.push('<img id="moreColor'+this._sParentId+'" src="http://st.blog.163.com/style/common/htmlEditor/more_colr.gif" style="border:1px solid white; margin-left:3px; margin-top:0px; margin-bottom:3px; height:16px; width:150px; cursor:pointer;"/>');a.push('</div>');return a.join("");},_drawFullColorPanel:function(){var a=[];a.push('<div style="width:203px; border:1px #4e6e89 solid;background-color:#FFFFFF">');a.push('<div style="position:relative;margin:1px 1px 1px 1px;height:19px">');a.push('<img id="colorClear'+this._sParentId+'" src="http://st.blog.163.com/style/common/htmlEditor/full_colr_remove.gif" style="width:199px;height:17px;background-color:white;border:1px solid white;cursor:pointer;" />');a.push('<div id="colorPrez'+this._sParentId+'" style="position:absolute;top:3px;left:3px;border:1px solid #ACA899;font-size:1px;width:28px;height:11px;"> </div>');a.push('</div>');a.push('<div style="margin-left:2px!important;margin-left:1px;margin-top:2px!important;margin-top:1px; margin-bottom:1px;width:201px;">');a.push('<table id="fullColorSelect'+this._sParentId+'" border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;cursor:pointer; border:1px solid #000000" bordercolor="#000000" >');for(i=0;i<2;i++){for(j=0;j<6;j++){a.push('<tr height=10>');if(i==0){a.push('<td style="padding:0px;font-size:0px;border:1px #000000 solid"><img '+((this.isIE)?"":"src="+NECtrl.ColorPanel._picSrc)+' width=9 style="font-size:1px;background-color:#'+NECtrl.ColorPanel._ColorHex[j]+NECtrl.ColorPanel._ColorHex[j]+NECtrl.ColorPanel._ColorHex[j]+'"></img></td>');}else{a.push('<td style="padding:0px;font-size:0px;border:1px #000000 solid"><img '+((this.isIE)?"":"src="+NECtrl.ColorPanel._picSrc)+' width=9 style="font-size:1px;background-color:#'+NECtrl.ColorPanel._SpColorHex[j]+'"></img></td>');}a.push('<td style="padding:0px;font-size:0px;border:1px #000000 solid"><img '+((this.isIE)?"":"src="+NECtrl.ColorPanel._picSrc)+' width=9 style="font-size:1px;background-color:#000000"></img></td>');for(k=0;k<3;k++){for(l=0;l<6;l++){a.push('<td style="padding:0px;font-size:0px;border:1px #000000 solid"><img '+((this.isIE)?"":"src="+NECtrl.ColorPanel._picSrc)+' width=9 style="font-size:1px;background-color:#'+NECtrl.ColorPanel._ColorHex[k+i*3]+NECtrl.ColorPanel._ColorHex[l]+NECtrl.ColorPanel._ColorHex[j]+'"></img></td>');}}a.push('</tr>');}}a.push('</table>');a.push('</div>');a.push('</div>');return a.join("");},_onMoreColor:function(oColorDiv,sColorType){this._displayFullColorBoard(oColorDiv,sColorType);},_onColorClear:function(sColorType){var color;if(sColorType=="ForeColor"){color="black";}else if(sColorType=="BackColor"){color="white";}try{if(this._oCurrentColor!=null){this._oCurrentColor_savedColor=color;this._oHtmlEditor.format(sColorType,color);}this._oHtmlEditor.hiddenAllMenu();return;}catch(e){}},_onColorOvr:function(oEvent){var _oNode;if(this.isIE)_oNode=event.srcElement;else_oNode=oEvent.target;if(_oNode.tagName=="IMG"){if(this._oCurrentColor!=null){this._oCurrentColor.style.backgroundColor=this._oCurrentColor._background;}_oNode._background=_oNode.style.backgroundColor;$("colorPrez"+this._sParentId).style.backgroundColor=_oNode.style.backgroundColor;this._oCurrentColor=_oNode;}},_onColorOut:function(sColorType){if(this._oCurrentColor!=null){if(this._oCurrentColor_savedColor!=null){$("colorPrez"+this._sParentId).style.backgroundColor=this._oCurrentColor_savedColor;}else{if(sColorType=="ForeColor"){$("colorPrez"+this._sParentId).style.backgroundColor="black";}else if(sColorType=="BackColor"){$("colorPrez"+this._sParentId).style.backgroundColor="white";}}}},_onColorClick:function(sColorType,oEvent){var _oNode;if(this.isIE)_oNode=event.srcElement;else_oNode=oEvent.target;if(_oNode.tagName=="IMG"){try{if(this._oCurrentColor!=null){this._oCurrentColor_savedColor=_oNode.style.backgroundColor;this._oHtmlEditor.format(sColorType,_oNode.style.backgroundColor);}this._oHtmlEditor.hiddenAllMenu();}catch(e){}}return false;},_displaySimpleColorBoard:function(oColorDiv,sColorType){if(this.simpleHTML==null)this.simpleHTML=this._drawSimpleColorPanel();oColorDiv.innerHTML=this.simpleHTML;if(this._oCurrentColor!=null){$("colorPrez"+this._sParentId).style.backgroundColor=this._oCurrentColor_savedColor;}else{if(sColorType=="ForeColor"){$("colorPrez"+this._sParentId).style.backgroundColor="black";}else if(sColorType=="BackColor"){$("colorPrez"+this._sParentId).style.backgroundColor="white";}}var _oColorSelect=$("colorSelectPanel"+this._sParentId);_oColorSelect.onmouseover=this._onColorOvr.bind(this);_oColorSelect.onmouseout=this._onColorOut.bind(this,sColorType);_oColorSelect.onclick=this._onColorClick.bind(this,sColorType);var _oColorClear=$("colorClear"+this._sParentId);_oColorClear.onclick=this._onColorClear.bind(this,sColorType);_oColorClear.onmouseover=this.colorTxtOvr.bindAsEventListener(this);_oColorClear.onmouseout=this.colorTxtOut.bindAsEventListener(this);var _oMoreClear=$("moreColor"+this._sParentId);_oMoreClear.onclick=this._onMoreColor.bind(this,oColorDiv,sColorType);_oMoreClear.onmouseover=this.colorTxtOvr.bindAsEventListener(this);_oMoreClear.onmouseout=this.colorTxtOut.bindAsEventListener(this);return true;},_displayFullColorBoard:function(oColorDiv,sColorType){if(this.fullHTML==null)this.fullHTML=this._drawFullColorPanel();oColorDiv.innerHTML=this.fullHTML;var _oColorSelectPanel=$("fullColorSelect"+this._sParentId);if(this._oCurrentColor!=null){$("colorPrez"+this._sParentId).style.backgroundColor=this._oCurrentColor_savedColor;}else{if(sColorType=="ForeColor"){$("colorPrez"+this._sParentId).style.backgroundColor="black";}else if(sColorType=="BackColor"){$("colorPrez"+this._sParentId).style.backgroundColor="white";}}_oColorSelectPanel.onclick=this._onColorClick.bind(this,sColorType);_oColorSelectPanel.onmouseover=this._onColorOvr.bind(this);_oColorSelectPanel.onmouseout=this._onColorOut.bind(this,sColorType);var _oColorClear=$("colorClear"+this._sParentId);_oColorClear.onclick=this._onColorClear.bind(this,sColorType);_oColorClear.onmouseover=this.colorTxtOvr.bindAsEventListener(this);_oColorClear.onmouseout=this.colorTxtOut.bindAsEventListener(this);return true;}}if(NECtrl==undefined){var NECtrl={};}NECtrl.InsertAnything=Class.create();NECtrl.InsertAnything.prototype={initialize:function(sParentId,oEditor){this.options=Object.extend({sObjName:null},arguments[2]||{});this.parentId=sParent
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -