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

📄 editor.js

📁 博客系统 博客系统 博客系统 博客系统 博客系统 博客系统
💻 JS
📖 第 1 页 / 共 5 页
字号:

var iconHeight;//icons related
function RENDER(sPreloadHTML)
  {
  iconHeight=this.iconHeight;//icons related

  /*** Tetap Ada (For downgrade compatibility) ***/
  if(sPreloadHTML.substring(0,4)=="<!--" &&
    sPreloadHTML.substring(sPreloadHTML.length-3)=="-->")
    sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-3);

  if(sPreloadHTML.substring(0,4)=="<!--" &&
    sPreloadHTML.substring(sPreloadHTML.length-6)=="--&gt;")
    sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-6);

  /*** Converting back HTML-encoded content (kalau tdk encoded tdk masalah) ***/
  sPreloadHTML=sPreloadHTML.replace(/&lt;/g,"<");
  sPreloadHTML=sPreloadHTML.replace(/&gt;/g,">");
  sPreloadHTML=sPreloadHTML.replace(/&amp;/g,"&");

  /*** enable required buttons ***/
  if(this.cmdContentBlock!=";")this.btnContentBlock=true;
  if(this.cmdInternalLink!=";")this.btnInternalLink=true;
  if(this.cmdInternalImage!=";")this.btnInternalImage=true;
  if(this.cmdCustomObject!=";")this.btnCustomObject=true;
  if(this.arrCustomTag.length>0)this.btnCustomTag=true;
  if(this.mode=="HTMLBody"){this.btnXHTMLSource=false;this.btnXHTMLFullSource=false;}
  if(this.mode=="HTML"){this.btnXHTMLFullSource=false;this.btnXHTMLSource=false;}
  if(this.mode=="XHTMLBody"){this.btnXHTMLSource=true;this.btnXHTMLFullSource=false;}
  if(this.mode=="XHTML"){this.btnXHTMLFullSource=true;this.btnXHTMLSource=false;}
  
  /*** features ***/
  var bUseFeature=false;
  if(this.features.length>0)
    {
    bUseFeature=true;
    for(var i=0;i<this.buttonMap.length;i++)
      eval(this.oName+".btn"+this.buttonMap[i]+"=true");//ex: oEdit1.btnStyleAndFormatting=true (no problem), oEdit1.btn|=true (no problem), oEdit1.btnBRK=true (no problem)

    this.btnTextFormatting=false;this.btnListFormatting=false;
    this.btnBoxFormatting=false;this.btnParagraphFormatting=false;
    this.btnCssText=false;this.btnCssBuilder=false;
    for(var j=0;j<this.features.length;j++)
      eval(this.oName+".btn"+this.features[j]+"=true");//ex: oEdit1.btnTextFormatting=true

    for(var i=0;i<this.buttonMap.length;i++)
      {
      sButtonName=this.buttonMap[i];
      bBtnExists=false;
      for(var j=0;j<this.features.length;j++)
        if(sButtonName==this.features[j])bBtnExists=true;//ada;

      if(!bBtnExists)//tdk ada; set false
        eval(this.oName+".btn"+sButtonName+"=false");//ex: oEdit1.btnBold=false, oEdit1.btn|=false (no problem), oEdit1.btnBRK=false (no problem)
      }
    //Remove:"TextFormatting","ListFormatting",dst.=>tdk perlu(krn diabaikan)
    this.buttonMap=this.features;
    }
  /*** /features ***/

  this.preloadHTML=sPreloadHTML;
  var sHTMLDropMenus="";
  var sHTMLIcons="";
  var sTmp="";

  for(var i=0;i<this.buttonMap.length;i++)
    {
    sButtonName=this.buttonMap[i];
    switch(sButtonName)
      {
      case "|":
        sHTMLIcons+=this.writeBreakSpace();
        break;
      case "BRK":
        sHTMLIcons+="</td></tr></table><table cellpadding=0 cellspacing=0><tr><td dir=ltr style='padding:0px'>";
        break;
      case "Save":
        if(this.btnSave)sHTMLIcons+=this.writeIconStandard("btnSave"+this.oName,this.oName+".onSave()","btnSave.gif",getTxt("Save"));
        break;
      case "Preview":
        if(this.btnPreview)
          {
          sHTMLIcons+=this.writeIconStandard("btnPreview"+this.oName,this.oName+".dropShow(this,dropPreview"+this.oName+")","btnPreview.gif",getTxt("Preview"));
          var arrPreviewSize=[[640,480],[800,600],[1024,768]];
          sTmp="";
          for(var j=0;j<arrPreviewSize.length;j++)
            {
            sTmp+= "<tr><td onclick=\"dropPreview"+this.oName+".style.display='none';setActiveEditor('"+this.oName+"');modalDialogShow('preview.htm',"+arrPreviewSize[j][0]+","+arrPreviewSize[j][1]+");\" "+
              "style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
              "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
              "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+arrPreviewSize[j][0]+"x"+arrPreviewSize[j][1]+"</td></tr>";
            }
          sHTMLDropMenus+="<table id=dropPreview"+this.oName+" cellpadding=0 cellspacing=0 "+
            "style='line-height:normal;z-index:1;display:none;position:absolute;border:#80788D 1px solid;"+
            "cursor:default;background-color:#fbfbfd;' unselectable=on>"+
            sTmp+"</table>";
          }
        break;
      case "FullScreen":
        if(this.btnFullScreen)sHTMLIcons+=this.writeIconStandard("btnFullScreen"+this.oName,this.oName+".fullScreen()","btnFullScreen.gif",getTxt("Full Screen"));
        break;
      case "Print":
        if(this.btnPrint)sHTMLIcons+=this.writeIconStandard("btnPrint"+this.oName,this.oName+".focus();"+this.oName+".doCmd('Print')","btnPrint.gif",getTxt("Print"));
        break;
      case "Search":
        if(this.btnSearch)sHTMLIcons+=this.writeIconStandard("btnSearch"+this.oName,this.oName+".hide();modelessDialogShow('"+this.scriptPath+"search.htm',375,163)","btnSearch.gif",getTxt("Search"));
        break;
      case "SpellCheck":
        if(this.btnSpellCheck)
          {
          if(this.spellCheckMode=="ieSpell")
            sHTMLIcons+=this.writeIconStandard("btnSpellCheck"+this.oName,this.oName+".hide();windowOpen('"+this.scriptPath+"spellcheck.htm',500,222)","btnSpellCheck.gif",getTxt("Check Spelling"));
          if(this.spellCheckMode=="NetSpell")         
            sHTMLIcons+=this.writeIconStandard("btnSpellCheck"+this.oName,this.oName+".hide();checkSpellingById('idContent"+this.oName+"');","btnSpellCheck.gif",getTxt("Check Spelling"));
            //sHTMLIcons+=this.writeIconStandard("btnSpellCheck"+this.oName,this.oName+".hide();windowOpen('"+this.scriptPath+"spellcheck2.htm',500,500)","btnSpellCheck.gif",getTxt("Check Spelling"));
          }
        break;
      case "StyleAndFormatting":
        sTmp="";
        if(this.btnTextFormatting)
          sTmp+="<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"text1.htm',511,465);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("Text Formatting")+"</td></tr>";
        if(this.btnParagraphFormatting)
          sTmp+="<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"paragraph.htm',440,284);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("Paragraph Formatting")+"</td></tr>";
        if(this.btnListFormatting)
          sTmp+="<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"list.htm',270,335);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("List Formatting")+"</td></tr>";
        if(this.btnBoxFormatting)
          sTmp+="<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"box.htm',438,380);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("Box Formatting")+"</td></tr>";
        if(this.btnCssText)
          sTmp+= "<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"styles_cssText.htm',360,332);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("Custom CSS")+"</td></tr>";
        if(this.btnCssBuilder) 
          sTmp+= "<tr><td onclick=\"modelessDialogShow('"+this.scriptPath+"styles_cssText2.htm',430,445);"+
            "dropStyle"+this.oName+".style.display='none'\""+
            " style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;color:black;\" "+
            "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
            "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>"+getTxt("CSS Builder")+"</td></tr>";
        if(this.btnTextFormatting||this.btnParagraphFormatting||this.btnListFormatting||this.btnBoxFormatting||this.btnCssText||this.btnCssBuilder)
          {
          sHTMLIcons+=this.writeIconStandard("btnStyleAndFormat"+this.oName,this.oName+".dropShow(this,dropStyle"+this.oName+")","btnStyle.gif",getTxt("Styles & Formatting"));
          sHTMLDropMenus+="<table id=dropStyle"+this.oName+" cellpadding=0 cellspacing=0 "+
            "style='line-height:normal;z-index:1;display:none;position:absolute;border:#80788D 1px solid;"+
            "cursor:default;background-color:#fbfbfd;' unselectable=on>"+
            sTmp+"</table>";
          }
        break;
      case "Styles":
        if(this.btnStyles)sHTMLIcons+=this.writeIconStandard("btnStyles"+this.oName,this.oName+".hide();"+this.oName+".openStyleSelect()","btnStyleSelect.gif",getTxt("Style Selection"));
        break;
      case "Paragraph":
        if(this.btnParagraph)
          {
          sHTMLDropMenus+="<table id=dropParagraph"+this.oName+" cellpadding=0 cellspacing=0 "+
            "style='line-height:normal;z-index:1;display:none;position:absolute;border:#80788D 1px solid;"+
            "cursor:default;background-color:#fbfbfd;' unselectable=on>";
          for(var j=0;j<this.arrParagraph.length;j++)
            {
            sHTMLDropMenus+="<tr><td onclick=\""+this.oName+".applyParagraph('<"+this.arrParagraph[j][1]+">')\" "+
              "style=\"padding:0;padding-left:5px;padding-right:5px;font-family:tahoma;color:black;\" "+
              "onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
              "onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on align=center>"+
              "<"+this.arrParagraph[j][1]+" style=\"\margin-bottom:4px\"  unselectable=on> "+
              this.arrParagraph[j][0]+"</"+this.arrParagraph[j][1]+"></td></tr>";
            }
          sHTMLDropMenus+="</table>";
          sHTMLIcons+=this.writeDropDown("btnParagraph"+this.oName,this.oName+".selectParagraph();"+this.oName+".dropShow(this,dropParagraph"+this.oName+")","btnParagraph.gif",getTxt("Paragraph"),77);
          }
        break;
      case "FontName":
        if(this.btnFontName)
          {
          sHTMLDropMenus+="<table id=dropFontName"+this.oName+" cellpadding=0 cellspacing=0 "+
            "style='line-height:normal;z-index:1;display:none;position:absolute;border:#80788D 1px solid;"+
            "cursor:default;background-color:#fbfbfd;' unselectable=on><tr><td style='padding:0px;'>";

          //~~~~ up to 120 fonts
          var numOfFonts=0;
          for(var j=0;j<this.arrFontName.length;j++)
            {
            //if(this.arrFontName[j].length==1)
            if(this.arrFontName[j].toString().indexOf(",")==-1)
              {
              if(this.arrFontName[j]!="serif" &&
                this.arrFontName[j]!="sans-serif" &&
                this.arrFontName[j]!="cursive" &&
                this.arrFontName[j]!="fantasy" &&
                this.arrFontName[j]!="monoscape")numOfFonts++;
              }
            else numOfFonts++;
            }
          sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
          for(var j=0;j<this.arrFontName.length;j++)
            {
            //if(this.arrFontName[j].length==1)
            if(this.arrFontName[j].toString().indexOf(",")==-1)           
              {
              if(this.arrFontName[j]!="serif" &&
                this.arrFontName[j]!="sans-serif" &&
                this.arrFontName[j]!="cursive" &&
                this.arrFontName[j]!="fantasy" &&
                this.arrFontName[j]!="monoscape")
                sHTMLDropMenus+="<tr><td onclick=\""+this.oName+".applyFontName('"+this.arrFontName[j]+"')\" "+
                  "style=\"padding:2px;padding-top:1px;font-family:"+ this.arrFontName[j] +";font-size:12px;color:black;\" "+
                  "onmouseover=\"if(this.style.backgroundColor=='#708090')this.sel='true';this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
                  "onmouseout=\"if(this.sel=='true'){this.sel='false'}else{this.style.backgroundColor='';this.style.color='#000000';}\" unselectable=on>"+
                  this.arrFontName[j]+" <span unselectable=on style='font-family:tahoma'>("+ this.arrFontName[j] +")</span></td></tr>";
              }
            else
              {
              sHTMLDropMenus+="<tr><td onclick=\""+this.oName+".applyFontName('"+this.arrFontName[j][0]+"')\" "+
                "style=\"padding:2px;padding-top:1px;font-family:"+ this.arrFontName[j][0] +";font-size:11px;color:black;\" "+
                "onmouseover=\"if(this.style.backgroundColor=='#708090')this.sel='true';this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" "+
                "onmouseout=\"if(this.sel=='true'){this.sel='false'}else{this.style.backgroundColor='';this.style.color='#000000';}\" unselectable=on>"+
                this.arrFontName[j][1]+" <span unselectable=on style='font-family:tahoma'>("+ this.arrFontName[j][1] +")</span></td></tr>";
              }
            if(j==14||j==29||j==44||j==59||j==74||j==89||j==104)
              {
              if(j!=numOfFonts-1)
                {
                sHTMLDropMenus+="</table>";
                sHTMLDropMenus+="</td><td valign=top style='padding:0px;border-left:#80788D 1 solid'>";//main
                sHTMLDropMenus+="<table cellpadding=0 cellspacing=0>";
                }
              }
            }
          sHTMLDropMenus+="</table>";
          //~~~~

          sHTMLDropMenus+="</td></tr></table>";
          sHTMLIcons+=this.writeDropDown("btnFontName"+this.oName,this.oName+".expandSelection();"+this.oName+".dropShow(this,dropFontName"+this.oName+");realtimeFontSelect('"+this.oName+"')","btnFontName.gif",getTxt("Font Name"),77);
          }
        break;
      case "FontSize":
        if(this.btnFontSize)
          {
          sHTMLDropMenus+="<table id=dropFontSize"+this.oName+" cellpadding=0 cellspacing=0 "+
            "style='line-height:normal;z-index:1;display:none;position:absolute;border:#80788D 1px solid;"+
            "cursor:default;background-color:#fbfbfd;' unselectable=on>";
          for(var j=0;j<this.arrFontSize.length;j++)
            {

⌨️ 快捷键说明

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