home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / komunik / ie40 / ie4nt_s2.cab / IE4NT_2.CAB / MSHTML.DLL / 2110 / EDLINK.DLG < prev    next >
Encoding:
Text File  |  1997-07-12  |  7.0 KB  |  264 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
  2. <HTML id=dlgLink style="font-family: ms sans serif; font-size: 8pt;
  3. width: 36.7em; height: 12.3em; ">
  4. <HEAD>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <TITLE>Hyperlink</TITLE>
  7. <SCRIPT>
  8. function callHelp(elm)
  9. {
  10. if (null != elm.helpid)
  11. {
  12.  window.showHelp(elm.helpfile, "" + parseInt(elm.helpid));
  13. }
  14. else
  15. {
  16.  if ("BODY" != elm.tagName)
  17.  {
  18.   callHelp(elm.parentElement);
  19.  }
  20. }
  21. function btnCancelClick()
  22. {
  23. window.close();
  24. function getTextRange(elm)
  25. {
  26. var r = elm.parentTextEdit.createTextRange();
  27. r.moveToElementText(elm);
  28. return r;
  29. function mouseClick()
  30. {
  31. if (window.event.srcElement.id.substring(0,3)
  32.  == "txt")
  33. {
  34.  return;
  35. }
  36. if (window.event.button == 2)
  37. {
  38.  callHelp(window.event.srcElement);
  39. }
  40. function txtDefaultESC()
  41. {
  42. if (event.keyCode == 27)
  43. {
  44.  window.close();
  45.  return;
  46. }
  47. var g_fOKEnabled = false; 
  48. var g_fURLLoaded = false; 
  49. function findAnchor(range)
  50. {
  51.  var rangeWorking;
  52.  var elmWorking;
  53.  var index;
  54.  elmWorking = range.parentElement()
  55.  while ("HTML" != elmWorking.tagName)
  56.  {
  57.   if ("A" == elmWorking.tagName)
  58.   {
  59.    return elmWorking;
  60.   }
  61.   else
  62.   {
  63.    elmWorking = elmWorking.parentElement
  64.   }
  65.  }
  66.  rangeWorking = range.duplicate();
  67.  rangeWorking.collapse(true);
  68.  rangeWorking.moveEnd("character", 1);
  69.  while (rangeWorking.compareEndPoints("EndToEnd", range) < 0)
  70.  {
  71.   rangeWorking.move("Character");
  72.   if (null != findAnchor(rangeWorking))
  73.   {
  74.    return findAnchor(rangeWorking);
  75.   }
  76.  }
  77.  return null;
  78. function getProtocolFromURL(strURL)
  79. {
  80.  var index;
  81.  return strURL.substring(0, strURL.indexOf(":") + 1);
  82. function updateProtocolSel()
  83. {
  84.  var index;
  85.  var strProtocol = getProtocolFromURL(txtURL.value);
  86.  selProtocol.value = strProtocol;
  87.  if (selProtocol.value != strProtocol)
  88.  {
  89.   selProtocol.value = "";
  90.  }
  91. function updateProtocolTxt()
  92. {
  93.  var strSlashProts = " file:ftp:gopher:http:https:";
  94.  var strProtocolTxt = getProtocolFromURL(txtURL.value);
  95.  var strProtocolSel = selProtocol.value;
  96.  var strTempURL;
  97.  if ("//" == (txtURL.value.substring(strProtocolTxt.length,
  98.   strProtocolTxt.length + 2)))
  99.  {
  100.   strProtocolTxt = strProtocolTxt + "//";
  101.  }
  102.  strTempURL = txtURL.value.substring(strProtocolTxt.length);
  103.  if (0 < strSlashProts.indexOf(strProtocolSel))
  104.  {
  105.   strProtocolSel = strProtocolSel + "//";
  106.  }
  107.  txtURL.value = strProtocolSel + strTempURL;
  108. function setOKState(fKeyPress)
  109. {
  110.  var htmlKeyAlt = 18;
  111.  if (!g_fURLLoaded)
  112.  {
  113.   if (!fKeyPress || htmlKeyAlt != event.keyCode)
  114.   {
  115.    if ((("" == txtURL.value) || (txtURL.value == selProtocol.value)
  116.     ||(txtURL.value == selProtocol.value + "//"))
  117.     == g_fOKEnabled)
  118.    {
  119.     btnOK.disabled = g_fOKEnabled
  120.     g_fOKEnabled = !g_fOKEnabled;
  121.    }
  122.   }
  123.   else
  124.   {
  125.    window.setTimeout("setOKState(false)", 10);
  126.   }
  127.  }
  128. function bdyLoad()
  129. {
  130.  var globalDoc = window.dialogArguments.document;
  131.  var rngMaster;
  132.  var rngLink;
  133.  var elmLink;
  134.  document.onhelp  = new 
  135.   Function("callHelp(window.event.srcElement)");
  136.  document.onmouseup = new Function("mouseClick()");
  137.  selProtocol.onchange = new Function("updateProtocolTxt()");
  138.  btnOK.onclick = new Function("btnOKClick()");
  139.  btnCancel.onclick = new Function("btnCancelClick()");
  140.  txtURL.onfocus = new Function("txtURL.select()");
  141.  txtURL.onkeyup = new Function("setOKState(true)");
  142.  txtURL.onkeypress = new Function("txtDefaultESC()");
  143.  if (("Text" == globalDoc.selection.type) ||
  144.   ("None" == globalDoc.selection.type))
  145.  {
  146.   rngMaster = globalDoc.selection.createRange();
  147.   elmLink = findAnchor(rngMaster);
  148.   if (null != elmLink)
  149.   {
  150.    rngLink = getTextRange(elmLink);
  151.    if (rngLink.compareEndPoints("StartToStart", rngMaster) < 0)
  152.    {
  153.     rngMaster.setEndPoint("StartToStart", rngLink);
  154.    }
  155.    if (rngLink.compareEndPoints("EndToEnd", rngMaster) > 0)
  156.    {
  157.     rngMaster.setEndPoint("EndToEnd", rngLink);
  158.    }
  159.    rngMaster.select();
  160.    if ("" != elmLink.href)
  161.    {
  162.     txtURL.value = elmLink.href;
  163.     txtURL.href = elmLink.href;
  164.     g_fURLLoaded = true;
  165.     btnOK.disabled = false;
  166.    }
  167.    updateProtocolSel();
  168.   }
  169.  txtURL.select();
  170.  setOKState(false);
  171.  }
  172. function btnOKClick()
  173. {
  174.  var globalDoc = window.dialogArguments.document;
  175.  var cmdCreateLink = "CreateLink";
  176.  var cmdUnlink  = "Unlink";
  177.  var range = globalDoc.selection.createRange();
  178.  var strSlashProts = " file:ftp:gopher:http:https:";
  179.  var strProtocol = selProtocol.value; 
  180.  if ("" == txtURL.value)
  181.  {
  182.   range.execCommand(cmdUnlink, false);
  183.   window.close();
  184.   return;
  185.  }
  186.  if (g_fURLLoaded && (txtURL.value == txtURL.href))
  187.  {
  188.   window.close();
  189.   return;
  190.  }
  191.  updateProtocolSel();
  192.  if (0 < strSlashProts.indexOf(strProtocol))
  193.  {
  194.   strProtocol = strProtocol + "//";
  195.  }
  196.  range.execCommand(cmdCreateLink, false, txtURL.value);
  197.  window.close();
  198. </SCRIPT>
  199. </HEAD>
  200. <BODY style="font-family: ms sans serif; font-size: 8pt;
  201. background: threedface;" onLoad="bdyLoad()">
  202. <FIELDSET id=fldLink style="font-family: ms sans serif; font-size: 8pt; 
  203. position: absolute; left: 0.98em; top: .8em; width: 25.76em; 
  204. height: 7.9em;">
  205. <LEGEND>
  206. Hyperlink Information
  207. </LEGEND>
  208. </FIELDSET>
  209. <DIV style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  210. left: 1.82em; top: 2.8899em; width: 2.66em; height: 1.2168em; " id=div2>
  211. <LABEL FOR=selProtocol tabIndex=-1 helpid="35550" helpfile="msimn.hlp">
  212. <u>T</u>ype:
  213. </LABEL>
  214. </DIV>
  215. <select id=selProtocol size=1 ACCESSKEY=t tabIndex=50
  216. style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  217. left: 5.04em; top: 2.7378em; width: 6.44em; height: 2.1294em; "
  218. helpid="35550" helpfile="msimn.hlp">
  219. <OPTION value="">     (other) </OPTION>
  220. <OPTION value="file:">   file: </OPTION>
  221. <OPTION value="ftp:">    ftp: </OPTION>
  222. <OPTION value="gopher:">   gopher: </OPTION>
  223. <OPTION value="http:" SELECTED> http: </OPTION>
  224. <OPTION value="https:">   https: </OPTION>
  225. <OPTION value="mailto:">   mailto: </OPTION>
  226. <OPTION value="news:">   news: </OPTION>
  227. <OPTION value="telnet:">   telnet: </OPTION>
  228. <OPTION value="wais:">   wais: </OPTION>
  229. </select>
  230. <DIV style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  231. left: 1.82em; top: 5.9319em; width: 2.52em; height: 1.2168em; " id=div3>
  232. <LABEL FOR=txtURL tabIndex=-1 helpid="35550" helpfile="msimn.hlp">
  233. <u>U</u>RL:
  234. </LABEL>
  235. </DIV>
  236. <input accesskey=u ID="txtURL" value="http://" type=text size=35
  237. maxlength=256 tabIndex=15 helpid="35550" helpfile="msimn.hlp"
  238. style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  239. left: 5.04em; top: 5.6277em; width: 20.72em; height: 2.1294em; ">
  240. <BUTTON id=btnOK tabIndex=35 DISABLED=1 helpid="28443" helpfile="windows.hlp"
  241. style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  242. left: 28em; top: 1.521em; width: 7em; height: 2.1294em; " type=submit>
  243. OK
  244. </BUTTON>
  245. <BUTTON id=btnCancel tabIndex=40 helpid="28444" helpfile="windows.hlp"
  246. style="font-family: ms sans serif; font-size: 8pt; position: absolute;
  247. left: 28em; top: 4.1067em; width: 7em; height: 2.1294em; " type=reset>
  248. Cancel
  249. </BUTTON>
  250. </BODY>
  251. </HTML>
  252.