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

📄 editor.js

📁 使用PHP的建站系统,不需要编码,安装后直接有个页面,通过这个页面可以做后台等
💻 JS
📖 第 1 页 / 共 5 页
字号:
            [getTxt("Normal (DIV)"),"DIV"]];

  this.arrFontName=["Arial","Arial Black","Arial Narrow",
            "Book Antiqua","Bookman Old Style",
            "Century Gothic","Comic Sans MS","Courier New",
            "Franklin Gothic Medium","Garamond","Georgia",
            "Impact","Lucida Console","Lucida Sans","Lucida Unicode",
            "Modern","Monotype Corsiva","Palatino Linotype",
            "Roman","Script","Small Fonts","Symbol",
            "Tahoma","Times New Roman","Trebuchet MS",
            "Verdana","Webdings","Wingdings","Wingdings 2","Wingdings 3",
            "serif","sans-serif","cursive","fantasy","monoscape"];

  this.arrFontSize=[[getTxt("Size 1"),"1"],
            [getTxt("Size 2"),"2"],
            [getTxt("Size 3"),"3"],
            [getTxt("Size 4"),"4"],
            [getTxt("Size 5"),"5"],
            [getTxt("Size 6"),"6"],
            [getTxt("Size 7"),"7"]];

  this.arrCustomTag=[];//eg.[["Full Name","{%full_name%}"],["Email","{%email%}"]];

  this.docType="";
  this.html="<html>";
  this.headContent="";
  this.preloadHTML="";

  this.onSave=function(){document.getElementById("iwe_btnSubmit"+this.oName).click()};
  this.useBR=false;
  this.useDIV=true;

  this.doUndo=doUndo;
  this.doRedo=doRedo;
  this.saveForUndo=saveForUndo;
  this.arrUndoList=[];
  this.arrRedoList=[];

  this.useTagSelector=true;
  this.TagSelectorPosition="bottom";
  this.moveTagSelector=moveTagSelector;
  this.selectElement=selectElement;
  this.removeTag=removeTag;
  this.doClick_TabCreate=doClick_TabCreate;
  this.doRefresh_TabCreate=doRefresh_TabCreate;

  this.arrCustomButtons = [["CustomName1","alert(0)","caption here","btnSave.gif"],
              ["CustomName2","alert(0)","caption here","btnSave.gif"]];

  this.onSelectionChanged=function(){return true;};
  
  this.spellCheckMode="ieSpell";//NetSpell

  this.REPLACE=REPLACE;
  this.idTextArea;
  this.mode="HTMLBody";
  }

/*** UNDO/REDO ***/
function saveForUndo()
  {
  var oEditor=eval("idContent"+this.oName);
  var obj=eval(this.oName);
  if(obj.arrUndoList[0])
    if(oEditor.document.body.innerHTML==obj.arrUndoList[0][0])return;
  for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
  obj.focus();
  var oSel=oEditor.document.selection.createRange();
  var sType=oEditor.document.selection.type;

  if(sType=="None")
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"None"];
  else if(sType=="Text")
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"Text"];
  else if(sType=="Control")
    {
    oSel.item(0).selThis="selThis";
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
    oSel.item(0).removeAttribute("selThis",0);
    }
  this.arrRedoList=[];//clear redo list

  if(this.btnUndo) makeEnableNormal(eval("document.all.btnUndo"+this.oName));
  if(this.btnRedo) makeDisabled(eval("document.all.btnRedo"+this.oName));
  }
function doUndo()
  {
  var oEditor=eval("idContent"+this.oName);
  var obj=eval(this.oName);
  if(!obj.arrUndoList[0])return;
  //~~~~
  for(var i=20;i>1;i--)obj.arrRedoList[i-1]=obj.arrRedoList[i-2];
  var oSel=oEditor.document.selection.createRange();
  var sType=oEditor.document.selection.type;
  if(sType=="None")
    this.arrRedoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"None"];
  else if(sType=="Text")
    this.arrRedoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"Text"];
  else if(sType=="Control")
    {
    oSel.item(0).selThis="selThis";
    this.arrRedoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
    oSel.item(0).removeAttribute("selThis",0);
    }
  //~~~~
  sHTML=obj.arrUndoList[0][0];
  sHTML=fixPathEncode(sHTML);
  oEditor.document.body.innerHTML=sHTML;
  fixPathDecode(oEditor);

  //*** RUNTIME STYLES ***
  this.runtimeBorder(false);
  this.runtimeStyles();
  //***********************
  var oRange=oEditor.document.body.createTextRange();
  if(obj.arrUndoList[0][2]=="None")
    {
    oRange.moveToBookmark(obj.arrUndoList[0][1]);
    oRange.select(); //di-disable, spy tdk select all? tdk perlu utk undo
    }
  else if(obj.arrUndoList[0][2]=="Text")
    {
    oRange.moveToBookmark(obj.arrUndoList[0][1]);
    oRange.select();
    }
  else if(obj.arrUndoList[0][2]=="Control")
    {
    for(var i=0;i<oEditor.document.all.length;i++)
      {
      if(oEditor.document.all[i].selThis=="selThis")
        {
        var oSelRange=oEditor.document.body.createControlRange();
        oSelRange.add(oEditor.document.all[i]);
        oSelRange.select();
        oEditor.document.all[i].removeAttribute("selThis",0);
        }
      }
    }
  //~~~~
  for(var i=0;i<19;i++)obj.arrUndoList[i]=obj.arrUndoList[i+1];
  obj.arrUndoList[19]=null;
  realTime(this.oName);
  }
function doRedo()
  {
  var oEditor=eval("idContent"+this.oName);
  var obj=eval(this.oName);
  if(!obj.arrRedoList[0])return;
  //~~~~
  for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
  var oSel=oEditor.document.selection.createRange();
  var sType=oEditor.document.selection.type;
  if(sType=="None")
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"None"];
  else if(sType=="Text")
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML,
      oEditor.document.selection.createRange().getBookmark(),"Text"];
  else if(sType=="Control")
    {
    oSel.item(0).selThis="selThis";
    this.arrUndoList[0]=[oEditor.document.body.innerHTML,null,"Control"];
    oSel.item(0).removeAttribute("selThis",0);
    }
  //~~~~
  sHTML=obj.arrRedoList[0][0];
  sHTML=fixPathEncode(sHTML);
  oEditor.document.body.innerHTML=sHTML;
  fixPathDecode(oEditor);
  
  //*** RUNTIME STYLES ***
  this.runtimeBorder(false);
  this.runtimeStyles();
  //***********************
  var oRange=oEditor.document.body.createTextRange();
  if(obj.arrRedoList[0][2]=="None")
    {
    oRange.moveToBookmark(obj.arrRedoList[0][1]);
    //oRange.select(); //di-disable, sph tdk select all, utk redo perlu
    }
  else if(obj.arrRedoList[0][2]=="Text")
    {
    oRange.moveToBookmark(obj.arrRedoList[0][1]);
    oRange.select();
    }
  else if(obj.arrRedoList[0][2]=="Control")
    {
    for(var i=0;i<oEditor.document.all.length;i++)
      {
      if(oEditor.document.all[i].selThis=="selThis")
        {
        var oSelRange = oEditor.document.body.createControlRange();
        oSelRange.add(oEditor.document.all[i]);
        oSelRange.select();
        oEditor.document.all[i].removeAttribute("selThis",0);
        }
      }
    }
  //~~~~
  for(var i=0;i<19;i++)obj.arrRedoList[i]=obj.arrRedoList[i+1];
  obj.arrRedoList[19]=null;
  realTime(this.oName);
  }

/*** RENDER ***/
var bOnSubmitOriginalSaved=false;
function REPLACE(idTextArea, sMode)
  {
  this.idTextArea=idTextArea;
  var oTextArea=document.getElementById(idTextArea);
  oTextArea.style.display="none";
  var oForm=GetElement(oTextArea,"FORM");
  if(oForm)
    {
    if(!bOnSubmitOriginalSaved)
      {
      onsubmit_original=oForm.onsubmit;
      
      bOnSubmitOriginalSaved=true;  
      }
    oForm.onsubmit = new Function("return onsubmit_new()");
    }
  
  var sContent=document.getElementById(idTextArea).value;
  sContent=sContent.replace(/&/g,"&amp;");
  sContent=sContent.replace(/</g,"&lt;");
  sContent=sContent.replace(/>/g,"&gt;");
  
  this.RENDER(sContent);
  }
function onsubmit_new()
  {
  var sContent;
  for(var i=0;i<oUtil.arrEditor.length;i++)
    {
    var oEdit=eval(oUtil.arrEditor[i]);
    
    var oEditor=eval("idContent"+oEdit.oName);
    var allSpans = oEditor.document.getElementsByTagName("SPAN");
    for (var j=0; j<allSpans.length; j++)
      {
      if ((allSpans[j].innerHTML=="") && (allSpans[j].parentElement.children.length==1))
        {
        allSpans[j].innerHTML = "&nbsp;";
        }
      }

    if(oEdit.mode=="HTMLBody")sContent=oEdit.getHTMLBody();
    if(oEdit.mode=="HTML")sContent=oEdit.getHTML();
    if(oEdit.mode=="XHTMLBody")sContent=oEdit.getXHTMLBody();
    if(oEdit.mode=="XHTML")sContent=oEdit.getXHTML();

⌨️ 快捷键说明

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