home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 5.10 / 2000-07_Disc_5.10.bin / ELINK / Msie540 / IE_S4.CAB / IE_4.CAB / MSHTMLER.DLL / HTML / EDLINK.DLG < prev    next >
Text File  |  1999-03-18  |  9KB  |  342 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
  2. <HTML id=dlgLink style="font-family: MS Shell Dlg; 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.   "popup");
  14. }
  15. else
  16. {
  17.  if ("BODY" != elm.tagName)
  18.  {
  19.   callHelp(elm.parentElement);
  20.  }
  21. }
  22. function btnCancelClick()
  23. {
  24. window.close();
  25. function getTextRange(elm)
  26. {
  27. var r = elm.parentTextEdit.createTextRange();
  28. r.moveToElementText(elm);
  29. return r;
  30. function mouseClick()
  31. {
  32. if (window.event.srcElement.id.substring(0,3)
  33.  == "txt")
  34. {
  35.  return;
  36. }
  37. if (window.event.button == 2)
  38. {
  39.  callHelp(window.event.srcElement);
  40. }
  41. function txtDefaultESC()
  42. {
  43. if (event.keyCode == 27)
  44. {
  45.  window.close();
  46.  return;
  47. }
  48. window.onerror = HandleError
  49. var L_Dialog_ErrorMessage = "An error has occurred in this dialog.";
  50. var L_ErrorNumber_Text = "Error: ";
  51. function HandleError(message, url, line)
  52. {
  53. var str = L_Dialog_ErrorMessage + "\n\n" 
  54.  + L_ErrorNumber_Text + line + "\n"
  55.  + message;
  56. alert (str);
  57. window.close();
  58. return true;
  59. }
  60. var g_fOKEnabled = false; 
  61. var g_fURLLoaded = false; 
  62. function findAnchor(range)
  63. {
  64.  var rangeWorking;
  65.  var elmWorking;
  66.  var index;
  67.  elmWorking = range.parentElement()
  68.  while ("HTML" != elmWorking.tagName)
  69.  {
  70.   if ("A" == elmWorking.tagName)
  71.   {
  72.    return elmWorking;
  73.   }
  74.   else
  75.   {
  76.    elmWorking = elmWorking.parentElement
  77.   }
  78.  }
  79.  rangeWorking = range.duplicate();
  80.  rangeWorking.collapse(true);
  81.  rangeWorking.moveEnd("character", 1);
  82.  while (rangeWorking.compareEndPoints("EndToEnd", range) < 0)
  83.  {
  84.   rangeWorking.move("Character");
  85.   if (null != findAnchor(rangeWorking))
  86.   {
  87.    return findAnchor(rangeWorking);
  88.   }
  89.  }
  90.  return null;
  91. function getProtocolFromURL(strURL)
  92. {
  93.  var index;
  94.  return strURL.substring(0, strURL.indexOf(":") + 1);
  95. function updateProtocolSel()
  96. {
  97.  var index;
  98.  var strProtocol = getProtocolFromURL(txtURL.value);
  99.  selProtocol.value = strProtocol;
  100.  if (selProtocol.value != strProtocol)
  101.  {
  102.   selProtocol.value = "";
  103.  }
  104. function updateProtocolTxt()
  105. {
  106.  var strSlashProts = " file:ftp:gopher:http:https:";
  107.  var strProtocolTxt = getProtocolFromURL(txtURL.value);
  108.  var strProtocolSel = selProtocol.value;
  109.  var strTempURL;
  110.  if ("//" == (txtURL.value.substring(strProtocolTxt.length,
  111.   strProtocolTxt.length + 2)))
  112.  {
  113.   strProtocolTxt = strProtocolTxt + "//";
  114.  }
  115.  strTempURL = txtURL.value.substring(strProtocolTxt.length);
  116.  if (0 < strSlashProts.indexOf(strProtocolSel))
  117.  {
  118.   strProtocolSel = strProtocolSel + "//";
  119.  }
  120.  txtURL.value = strProtocolSel + strTempURL;
  121. function setOKState(fKeyPress)
  122. {
  123.  var htmlKeyAlt = 18;
  124.  if (!g_fURLLoaded)
  125.  {
  126.   if (!fKeyPress || htmlKeyAlt != event.keyCode)
  127.   {
  128.    if ((("" == txtURL.value) || (txtURL.value == selProtocol.value)
  129.     ||(txtURL.value == selProtocol.value + "//"))
  130.     == g_fOKEnabled)
  131.    {
  132.     btnOK.disabled = g_fOKEnabled
  133.     g_fOKEnabled = !g_fOKEnabled;
  134.    }
  135.   }
  136.   else
  137.   {
  138.    window.setTimeout("setOKState(false)", 10);
  139.   }
  140.  }
  141. function bdyLoad()
  142. {
  143.  var globalDoc = window.dialogArguments;
  144.  var rngMaster;
  145.  var rngLink;
  146.  var elmLink;
  147.  document.onhelp  = new 
  148.   Function("callHelp(window.event.srcElement)");
  149.  document.onmouseup = new Function("mouseClick()");
  150.  selProtocol.onchange = new Function("updateProtocolTxt()");
  151.  btnOK.onclick = new Function("btnOKClick()");
  152.  btnCancel.onclick = new Function("btnCancelClick()");
  153.  txtURL.onfocus = new Function("txtURL.select()");
  154.  txtURL.onkeyup = new Function("setOKState(true)");
  155.  txtURL.onkeypress = new Function("txtDefaultESC()");
  156.  if ("Control" == globalDoc.selection.type)
  157.  {
  158.   rngMaster = globalDoc.selection.createRange();
  159.   if (1 == rngMaster.length)
  160.   {
  161.    rngMaster = getTextRange(rngMaster(0));
  162.    rngMaster.select();
  163.   }
  164.  }
  165.  if (("Text" == globalDoc.selection.type) ||
  166.   ("None" == globalDoc.selection.type))
  167.  {
  168.   rngMaster = globalDoc.selection.createRange();
  169.   elmLink = findAnchor(rngMaster);
  170.   if (null != elmLink)
  171.   {
  172.    rngLink = getTextRange(elmLink);
  173.    if (rngLink.compareEndPoints("StartToStart", rngMaster) < 0)
  174.    {
  175.     rngMaster.setEndPoint("StartToStart", rngLink);
  176.    }
  177.    if (rngLink.compareEndPoints("EndToEnd", rngMaster) > 0)
  178.    {
  179.     rngMaster.setEndPoint("EndToEnd", rngLink);
  180.    }
  181.    rngMaster.select();
  182.    if ("" != elmLink.href)
  183.    {
  184.     txtURL.value = elmLink.href;
  185.     txtURL.href = elmLink.href;
  186.     g_fURLLoaded = true;
  187.     btnOK.disabled = false;
  188.    }
  189.    updateProtocolSel();
  190.   }
  191.  txtURL.focus();
  192.  txtURL.select();
  193.  setOKState(false);
  194.  }
  195. function IsRangeEmpty( range )
  196. {
  197.  var tempRange;
  198.  tempRange = range.duplicate();
  199.  result = tempRange.compareEndPoints( "StartToEnd", range );
  200.  if ( result == 0 )
  201.  {
  202.   return true;
  203.  }
  204.  else
  205.  {
  206.   return false;
  207.  }
  208. }
  209. function btnOKClick()
  210. {
  211.  var globalDoc = window.dialogArguments;
  212.  var cmdCreateLink = "CreateLink";
  213.  var cmdUnlink  = "Unlink";
  214.  var range = globalDoc.selection.createRange();
  215.  var strSlashProts = " file:ftp:gopher:http:https:";
  216.  var strProtocol = selProtocol.value; 
  217.  var dupRange;
  218.  var initialRange;
  219.  var iRight;
  220.  var fUseExecCommand = true;
  221.  if ("" == txtURL.value)
  222.  {
  223.   range.execCommand(cmdUnlink, false);
  224.   window.close();
  225.   return;
  226.  }
  227.  if (g_fURLLoaded && (txtURL.value == txtURL.href))
  228.  {
  229.   window.close();
  230.   return;
  231.  }
  232.  updateProtocolSel();
  233.  if (0 < strSlashProts.indexOf(strProtocol))
  234.  {
  235.   strProtocol = strProtocol + "//";
  236.  }
  237.  initialRange = range.duplicate();
  238.  if ( IsRangeEmpty( range ) )
  239.  {
  240.   range.text = txtURL.value;
  241.   fUseExecCommand = false;
  242.  }
  243.  else
  244.  {
  245.   dupRange = range.duplicate();
  246.   iRight = dupRange.moveEnd( "Character", 2 );
  247.   if ( iRight < 2 && dupRange.htmlText == "" )
  248.   {
  249.    range.text = txtURL.value;
  250.    fUseExecCommand = false;
  251.   }
  252.  }
  253.  if ( fUseExecCommand )
  254.  {
  255.   range.execCommand(cmdCreateLink, false, txtURL.value);
  256.  }
  257.  else
  258.  {
  259.   dupRange = range.duplicate();
  260.   dupRange.move( "Character", -1 );
  261.   elmParent = dupRange.parentElement();
  262.   if (elmParent.tagName == "A")
  263.   {    
  264.    elmParent.href = txtURL.value;
  265.   }
  266.   else
  267.   {
  268.    range.setEndPoint( "StartToEnd", initialRange );
  269.    range.execCommand(cmdCreateLink, false, txtURL.value);
  270.   }
  271.  }
  272.  window.close();
  273. </SCRIPT>
  274. </HEAD>
  275. <BODY id=bdy style="font-family: MS Shell Dlg; font-size: 8pt;
  276. background: threedface; color: windowtext;"
  277. onLoad="bdyLoad()" scroll=no>
  278. <FIELDSET id=fldLink style="font-family: MS Shell Dlg; font-size: 8pt; 
  279. position: absolute; left: 0.98em; top: .8em; width: 25.76em; 
  280. height: 7.9em;">
  281. <LEGEND id=lgdLink>
  282. Hyperlink Information
  283. </LEGEND>
  284. </FIELDSET>
  285. <DIV id=div2 style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  286. left: 1.82em; top: 2.8899em; width: 2.66em; height: 1.2168em; ">
  287. <LABEL id=lblProtocol FOR=selProtocol tabIndex=-1 helpid="35550" 
  288. helpfile=msoe.hlp>
  289. <u>T</u>ype:
  290. </LABEL>
  291. </DIV>
  292. <select id=selProtocol size=1 ACCESSKEY=t tabIndex=50
  293. style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  294. left: 5.04em; top: 2.7378em; width: 6.44em; height: 2.1294em; "
  295. helpid="35550" helpfile=msoe.hlp>
  296. <OPTION id=optOther value="">     (other) </OPTION>
  297. <OPTION id=optFile value="file:">   file: </OPTION>
  298. <OPTION id=optFtp value="ftp:">    ftp: </OPTION>
  299. <OPTION id=optGopher value="gopher:">   gopher: </OPTION>
  300. <OPTION id=optHttp value="http:" SELECTED> http: </OPTION>
  301. <OPTION id=optHttps value="https:">   https: </OPTION>
  302. <OPTION id=optMailto value="mailto:">   mailto: </OPTION>
  303. <OPTION id=optNews value="news:">   news: </OPTION>
  304. <OPTION id=optTelnet value="telnet:">   telnet: </OPTION>
  305. <OPTION id=optWais value="wais:">   wais: </OPTION>
  306. </select>
  307. <DIV id=div3 style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  308. left: 1.82em; top: 5.9319em; width: 2.52em; height: 1.2168em; ">
  309. <LABEL id=lblURL FOR=txtURL tabIndex=-1 helpid="35550" 
  310. helpfile=msoe.hlp>
  311. <u>U</u>RL:
  312. </LABEL>
  313. </DIV>
  314. <input accesskey=u ID="txtURL" value="http://" type=text size=35
  315. maxlength=1024 tabIndex=15 helpid="35550" helpfile=msoe.hlp
  316. style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  317. left: 5.04em; top: 5.6277em; width: 20.72em; height: 2.1294em; ">
  318. <BUTTON id=btnOK tabIndex=35 DISABLED=1 helpid="28443" helpfile="windows.hlp"
  319. style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  320. left: 28em; top: 1.521em; width: 7em; height: 2.2em; " type=submit>
  321. OK
  322. </BUTTON>
  323. <BUTTON id=btnCancel tabIndex=40 helpid="28444" helpfile="windows.hlp"
  324. style="font-family: MS Shell Dlg; font-size: 8pt; position: absolute;
  325. left: 28em; top: 4.1067em; width: 7em; height: 2.2em; " type=reset>
  326. Cancel
  327. </BUTTON>
  328. </BODY>
  329. </HTML>
  330.