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

📄 html_edit.js

📁 是个不错的文件代码,希望大家好好用,
💻 JS
📖 第 1 页 / 共 3 页
字号:
  replaceFontsWithSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
  condenseSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
}

function jk_edit_quickfontsize(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  oSel=eval('document.all.oQuickFontSize'+num);  
  DHTMLSafe.ExecCommand(5045, 0, oSel.options[oSel.selectedIndex].value);
  DHTMLSafe.focus();
}

function jk_edit_quickformat(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  oSel=eval('document.all.oQuickFormat'+num);  
  DHTMLSafe.ExecCommand(5043, 0, oSel.options[oSel.selectedIndex].name);
  DHTMLSafe.focus();
}

function jk_edit_hyperlinkwin(num)
{
  jk_edit_hot=num;
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.focus();
  if(DHTMLSafe.DOM.selection.type=="Control")
  {
    var el=DHTMLSafe.DOM.selection.createRange().commonParentElement();
    var tr = DHTMLSafe.DOM.body.createTextRange();
    tr.moveToElementText(el);
    tr.select();
  }
  if (typeof(jk_edit_linkwin) == "undefined" || jk_edit_linkwin.closed)
  {
    var szURL=inc + "win_hyperlink.htm";
    jk_edit_linkwin = window.showModalDialog(szURL,window,"dialogHeight: 240px; dialogWidth: 400px; dialogTop: 70px; dialogLeft: 150px; center: Yes; help: No; resizable: No; status: No;");
  }
}

function jk_edit_imagepropertywin(num) { jk_edit_imgpropertywin =window.showModalDialog(inc + "win_img_edit.htm",window,"dialogHeight: 350px; dialogWidth: 490px; dialogTop: 70px; dialogLeft: 150px; center: Yes; help: No; resizable: No; status: No;"); }

function jk_edit_imageproperty(num, aWidth, aHeight, aBorder, aSrc, aAlt, aAlign)
{
  DHTMLSafe=aeObjects[num];
  var oSel=DHTMLSafe.DOM.selection.createRange().commonParentElement();
  var tr = DHTMLSafe.DOM.body.createTextRange();
  hs=oSel.getAttribute("STYLE",0).height;
  ws=oSel.getAttribute("STYLE",0).width;
  if (hs.length) { oSel.getAttribute("STYLE",0).removeAttribute("HEIGHT",0); }
  if (ws.length) { oSel.getAttribute("STYLE",0).removeAttribute("WIDTH",0); }
  oSel.width=aWidth;
  oSel.height=aHeight;
  oSel.border=aBorder;
  oSel.src=aSrc;
  oSel.alt=aAlt;
  oSel.align=aAlign;
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
  tr.moveToElementText(oSel);
  tr.collapse(false);
  tr.select();
}

function jk_edit_hyperlink(num, iHref, iTarget, iStyle, iClass, iName)
{
  DHTMLSafe=aeObjects[num];
  var uid="ae"+Math.random().toString();
  if(iHref=="" && !iName.length)
  { if(DHTMLSafe.QueryStatus(5050)==3) { DHTMLSafe.ExecCommand(5050); } }
  else
  {
    var trSel=DHTMLSafe.DOM.selection.createRange();
    if(trSel.compareEndPoints("StartToEnd",trSel)==0)
    {
      txtHTML="<A href=\""+iHref+"\" ";
      if(iTarget.length) { txtHTML+="target=\""+iTarget+"\" "; }
      if(iStyle.length) { txtHTML+="style=\""+iStyle+"\" "; }
      if(iClass.length) { txtHTML+="class=\""+iClass+"\" "; }
      if(iName.length) { txtHTML+="name=\""+iName+"\" "; }
      txtHTML+=">"+iHref+"</a>";
      trSel.pasteHTML(txtHTML);
    }
    else
    { 
      DHTMLSafe.ExecCommand(5016,2,uid);
      var coll=DHTMLSafe.DOM.all.tags("A");
      for(i=0;i<coll.length;i++)
      {
        if(coll[i].href==uid)
        {
          coll[i].href=iHref;
          if(iTarget.length) coll[i].target=iTarget;
          else coll[i].removeAttribute("TARGET",0);
          if(iStyle.length) { coll[i].style.cssText=iStyle; }
          else { coll[i].style.cssText=""; }
          if(iClass.length) { coll[i].className=iClass; }
          else { coll[i].className=""; }
        }
      }
    }
  }
  DHTMLSafe.focus();
}

function jk_edit_spellcheckwin(num)
{
  if (typeof(jk_edit_spellwin) == "undefined" || jk_edit_spellwin.closed)
  {
    var szURL=inc + "spellchecker/window.cfm?jsvar=aeObjects["+num+"].DOM.body.innerHTML";
    //window.showModalDialog(inc + "editsource.htm",window,"dialogHeight: 490px; dialogWidth: 485px; dialogTop: 70px; dialogLeft: 150px; center: Yes; help: No; resizable: No; status: No;");
    jk_edit_spellwin = window.open(szURL, null, "height=230,width=450,status=no,toolbar=no,menubar=no,location=no");
  }
  jk_edit_spellwin.focus();
}

function ShowMenu(num)
{
  var menuStrings = new Array();
  var menuStates = new Array();
  var state;
  var i;
  var idx = 0;
  jk_edit_hot=num;
  DHTMLSafe=aeObjects[num];
  ContextMenu.length = 0;
  if(alloweditsource[num]) { i=0; }
  else { i=2; }
  for (;i<GeneralContextMenu.length; i++) { ContextMenu[idx++] = GeneralContextMenu[i]; }
  if (DHTMLSafe.QueryStatus(5021) != 1) { for (i=0; i<TableContextMenu.length; i++) { ContextMenu[idx++] = TableContextMenu[i]; } }
  var tr = DHTMLSafe.DOM.selection.createRange();
  if (DHTMLSafe.DOM.selection.type == "Control") { for (i=0; i<ImageContextMenu.length; i++) { ContextMenu[idx++] = ImageContextMenu[i]; } }
  for (i=0; i<ContextMenu.length; i++)
  {
    menuStrings[i] = ContextMenu[i].string;
    if ((menuStrings[i] != MENU_SEPARATOR) && (ContextMenu[i].cmdId < 6000)) { state = DHTMLSafe.QueryStatus(ContextMenu[i].cmdId); }
    else { state = 3; }
    if (state == 1 || state == 0) { menuStates[i] = 2; }
    else if (state == 3 || state == 11) { menuStates[i] = 0; }
    else { menuStates[i] = 1; }
    if (ContextMenu[i].cmdId == 6004)
    {
      if (DHTMLSafe.ShowDetails) { menuStates[i] = 1; }
      else { menuStates[i] = 0; }  
    }
    if(ContextMenu[i].cmdId == 6001)
    {
      if(jk_edit_sourceview) { menuStates[i] = 1; }
      else { menuStates[i] = 0; }  
    }
  }
  DHTMLSafe.SetContextMenu(menuStrings, menuStates);
}

function ContextMenuItem(string, cmdId)
{
  this.string = string;
  this.cmdId = cmdId;
}

function QueryStatusItem(command, element)
{
  this.command = command;
  this.element = element;
}

var MENU_SEPARATOR = "";
var ContextMenu = new Array();
var GeneralContextMenu = new Array();
var TableContextMenu = new Array();
var ImageContextMenu = new Array();
var genId = 0; 
var tblId = 0;
var imgId = 0;

GeneralContextMenu[genId++] = new ContextMenuItem("编辑源代码", 6001);
GeneralContextMenu[genId++] = new ContextMenuItem(MENU_SEPARATOR, 0);

if (!is_ie4)
{
  TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
  TableContextMenu[tblId++] = new ContextMenuItem("表格属性", 6006);
}

TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入行", 5021);
TableContextMenu[tblId++] = new ContextMenuItem("删除行", 5007);
TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入列", 5020);
TableContextMenu[tblId++] = new ContextMenuItem("删除列", 5006);
TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入单元格", 5019);
TableContextMenu[tblId++] = new ContextMenuItem("删除单元格", 5005);
TableContextMenu[tblId++] = new ContextMenuItem("合并单元格", 5029);
TableContextMenu[tblId++] = new ContextMenuItem("拆分单元格", 5047);
ImageContextMenu[imgId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
ImageContextMenu[imgId++] = new ContextMenuItem("图片属性", 6009);
GeneralContextMenu[genId++] = new ContextMenuItem("查找", 5008);
GeneralContextMenu[genId++] = new ContextMenuItem("全部显示", 6004);
GeneralContextMenu[genId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
GeneralContextMenu[genId++] = new ContextMenuItem("关于", 6002);

function jk_edit_m_out(src)
{
  if(src.state==0) return;  
  if(src.state==2) { src.className="latched"; return; }
  if(src.type=="btn")
  {
    window.status="";
    src.className="flat";
  }
}

function jk_edit_m_over(src)
{
  if(src.state==0) return;
  if(src.state==2) return;
  if(src.type=="btn")
  {
    window.status=src.alt;
    src.className="outset";
  }
}

function jk_edit_m_down(src)
{
  if(src.state==0) return;
  if(src.type=="btn") { src.className="inset"; }
}

function jk_edit_m_up(src)
{
  if(src.state==0) return;
  if(src.state==2) { src.className="latched"; return; }
  if(src.type=="btn") { src.className="outset"; }
}

function set_tbstates(num)
{
  var pbtn;
  var cid;
  var state;
  DHTMLSafe=aeObjects[num];
  jk_edit_tbar=eval("jk_edit_tbar"+num);
  if(DHTMLSafe.QueryStatus(5002)!=DHTMLSafe.QueryStatus(5003)) return;
  for(var i=0;i<jk_edit_tbar.all.length;i++)
  {
    pbtn= jk_edit_tbar.all(i);
    cid=pbtn.cid;
    if(cid < 6000&&cid!=5016)
    {
      if (!is_ie4) { pbtn.style.visibility="visible"; }
      state=DHTMLSafe.QueryStatus(cid)
      if(state == 1 || state == 0)
      {
        if(pbtn.state!=0)
        {
          pbtn.className = "disabled";
          pbtn.state = 0;
        }
      }
      else if (state == 3 || state == 11)
      {
        if(pbtn.state!=1)
        {
          pbtn.className = "flat";
          pbtn.state = 1;
        }
      }
      else
      {   
        if(pbtn.state!=2)
        {
          pbtn.className = "latched";
          pbtn.state = 2;
        }
      }
    }
    else if(cid==6004)
    {
      if(DHTMLSafe.ShowDetails)
      {
        if(pbtn.state!=2)
        {
          pbtn.className = "latched";
          pbtn.state = 2;
        }
      }
      else
      {
        if(pbtn.state!=1)
        {
          pbtn.className = "flat";
          pbtn.state = 1;
        }
      }
    }
  }
  if(oSel=eval('document.all.oQuickFont'+num))
  {
    if(DHTMLSafe.QueryStatus(5044)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false;
      fontname=DHTMLSafe.ExecCommand(5013);
      if(fontname!=""&&fontname!=null)
      {
        fCreateNew=true;
        for(i=0;i<oSel.options.length;i++)
        {
          if(oSel.options[i].name==fontname)
          {
            if(!oSel.options[i].selected) { oSel.options[i].selected=true; }
            fCreateNew=false;
          }
        }
        if(fCreateNew)
        {
          var oOption = document.createElement("OPTION");
          oSel.options.add(oOption,0);
          oOption.text = fontname;
          oOption.name = fontname;
          oOption.selected=true;
        }
      }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }
  if(oSel=eval('document.all.oQuickFontSize'+num))
  {
    if(DHTMLSafe.QueryStatus(5045)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false; 
      fs=DHTMLSafe.ExecCommand(5014);
      if(fs!=null&&fs!="")
      {
        for(i=0;i<oSel.options.length;i++)
        {
          if(oSel.options[i].name=="jk_edit_fs"+fs&&!oSel.options[i].selected)
          { oSel.options[i].selected=true; }
        }
      }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }  
  if(oSel=eval('document.all.oQuickFormat'+num))
  {
    if(DHTMLSafe.QueryStatus(5043)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false;
      fmt=DHTMLSafe.ExecCommand(5011);
      if(fmt!=""&&fmt!=null)
      { for(i=0;i<oSel.options.length;i++) { if(oSel.options[i].name==fmt&&!oSel.options[i].selected) { oSel.options[i].selected=true; } } }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }  
}

function aeapi_onLoad(aeObject) { aeObject.ShowBorders = true; }

function aeapi_onBeforeSave(aeObject)
{
  for (var i=0;i<aeObject.DOM.images.length;i++)
  {
    hs=aeObject.DOM.images[i].getAttribute("STYLE",0).height;
    ws=aeObject.DOM.images[i].getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.images[i].removeAttribute("HEIGHT", 0);       
      aeObject.DOM.images[i].setAttribute("HEIGHT", replaceString("px", "", hs),0); 
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.images[i].removeAttribute("WIDTH", 0);  
      aeObject.DOM.images[i].setAttribute("WIDTH", replaceString("px", "", ws),0); 
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  for (var k=0;k<aeObject.DOM.all.tags("TABLE").length;k++)
  {
    hs=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).height;
    ws=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("HEIGHT", 0);       
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("HEIGHT", replaceString("px", "", hs),0); 
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("WIDTH", 0);  
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("WIDTH", replaceString("px", "", ws),0); 
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  var content = aeObject.DOM.body.innerHTML;
  if(content.length) { content = aeObject.FilterSourceCode(content); }
  replaceString("&#65279;", " ", content); 
  return content;
}

function ubbcode()
{
  if (!validateMode()) { return; }
  cont=getPureHtml(Composition.document.body.innerHTML);
  var aryCode0 = new Array("<b>","[b]","</b>","[/b]","<p","[p","</p>","[/p]","<a href=","[url=","</a>","[/url]");
  var aryCode1 = new Array("<EM>","[i]","</EM>","[/i]","<u>","[u]","</u>","[/u]","<ul>","[list]","</ul>","[/list]","<ol>","[list=1]","</ol>","[/list]");
  var aryCode2 = new Array("<li>","[*]","</li>","","<font color=","[color=","<font face=","[face=","<font size=","[size=");
  var aryCode9 = new Array(">","]","<","[","</","[/");
  var aryCode = aryCode0.concat(aryCode1).concat(aryCode2).concat(aryCode9);
  for (var i=0;i<aryCode.length;i+=2) { cont=rCode(cont,aryCode[i],aryCode[i+1]); }
  eval("self.opener."+bodyID+".value=cont;");
  self.close();
}

function ubb2html(str)
{
  if (str=="") { return str; }
  var aryCode0 = new Array("<br>","\n","<b>","\\[b]","</b>","\\[/b]","<p","\\[p","</p>","\\[/p]","<a href=","\\[url=","</a>","\\[/url]");
  var aryCode1 = new Array("<i>","\\[i]","</i>","\\[/i]","<u>","\\[u]","</u>","\\[/u]");
  var aryCode = aryCode0.concat(aryCode1);
  for (var i=0;i<aryCode.length;i+=2) { str=rCode(str,aryCode[i+1],aryCode[i]); }
  return str;
}

function rCode(s,a,b)
{
  var r = new RegExp(a,"gi");
  return s.replace(r,b); 
}

function insertHtml(html)
{
  if (DHTMLSafe.DOM.selection.type.toLowerCase() != "none") { DHTMLSafe.DOM.selection.clear(); }
  DHTMLSafe.DOM.selection.createRange().pasteHTML(html); 
  SetFocus();
}

function SetFocus()
{
  if (BrowserInfo.IsIE55OrMore) { DHTMLSafe.DOM.focus(); }
  else {DHTMLSafe.focus(); }
}

⌨️ 快捷键说明

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