home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 July / VPR0107A.BIN / mshtmler.dll / HTML / EDLINK.DLG < prev    next >
Text File  |  2000-06-19  |  9KB  |  343 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
  2. <HTML id=dlgLink style="font-family: MS UI Gothic; font-size: 9pt;
  3. width: 36.7em; height: 12.3em; ">
  4. <HEAD>
  5. <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
  6. <TITLE>ハイパーリンク</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 = "このダイアログでエラーが発生しました。";
  50. var L_ErrorNumber_Text = "エラー : ";
  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()
  122. {
  123.  var htmlKeyAlt = 18;
  124.  if (!g_fURLLoaded)
  125.  {
  126.   if ((("" == txtURL.value) || (txtURL.value == selProtocol.value)
  127.    ||(txtURL.value == selProtocol.value + "//"))
  128.    == g_fOKEnabled)
  129.   {
  130.    btnOK.disabled = g_fOKEnabled
  131.    g_fOKEnabled = !g_fOKEnabled;
  132.   }
  133.  }
  134. function bdyLoad()
  135. {
  136.  var globalDoc = window.dialogArguments;
  137.  var rngMaster;
  138.  var rngLink;
  139.  var elmLink;
  140.  document.onhelp  = new 
  141.   Function("callHelp(window.event.srcElement)");
  142.  document.onmouseup = new Function("mouseClick()");
  143.  selProtocol.onchange = new Function("updateProtocolTxt()");
  144.  btnOK.onclick = new Function("btnOKClick()");
  145.  btnCancel.onclick = new Function("btnCancelClick()");
  146.  txtURL.onfocus = new Function("txtURL.select()");
  147.  txtURL.onpropertychange = new Function("if (event.propertyName == 'value') setOKState();");
  148.  txtURL.onkeypress = new Function("txtDefaultESC()");
  149.  if ("Control" == globalDoc.selection.type)
  150.  {
  151.   rngMaster = globalDoc.selection.createRange();
  152.   if (1 == rngMaster.length)
  153.   {
  154.    rngMaster = getTextRange(rngMaster(0));
  155.    rngMaster.select();
  156.   }
  157.  }
  158.  if (("Text" == globalDoc.selection.type) ||
  159.   ("None" == globalDoc.selection.type))
  160.  {
  161.   rngMaster = globalDoc.selection.createRange();
  162.   globalDoc.execCommand("AutoDetect");
  163.   elmLink = findAnchor(rngMaster);
  164.   if (null != elmLink)
  165.   {
  166.    rngLink = getTextRange(elmLink);
  167.    if (rngLink.compareEndPoints("StartToStart", rngMaster) < 0)
  168.    {
  169.     rngMaster.setEndPoint("StartToStart", rngLink);
  170.    }
  171.    if (rngLink.compareEndPoints("EndToEnd", rngMaster) > 0)
  172.    {
  173.     rngMaster.setEndPoint("EndToEnd", rngLink);
  174.    }
  175.    rngMaster.select();
  176.    if ("" != elmLink.href)
  177.    {
  178.     txtURL.value = elmLink.href;
  179.     txtURL.href = elmLink.href;
  180.     g_fURLLoaded = true;
  181.     btnOK.disabled = false;
  182.    }
  183.    updateProtocolSel();
  184.   }
  185.  txtURL.focus();
  186.  txtURL.select();
  187.  setOKState();
  188.  }
  189. function IsRangeEmpty( range )
  190. {
  191.  var tempRange;
  192.  tempRange = range.duplicate();
  193.  result = tempRange.compareEndPoints( "StartToEnd", range );
  194.  if ( result == 0 )
  195.  {
  196.   return true;
  197.  }
  198.  else
  199.  {
  200.   return false;
  201.  }
  202. }
  203. function btnOKClick()
  204. {
  205.  var globalDoc = window.dialogArguments;
  206.  var cmdCreateLink = "CreateLink";
  207.  var cmdUnlink  = "Unlink";
  208.  var range = globalDoc.selection.createRange();
  209.  var strSlashProts = " file:ftp:gopher:http:https:";
  210.  var strProtocol = selProtocol.value; 
  211.  var dupRange;
  212.  var initialRange;
  213.  var iRight;
  214.  var fUseExecCommand = true;
  215.  if ("" == txtURL.value)
  216.  {
  217.   range.execCommand(cmdUnlink, false);
  218.   window.close();
  219.   return;
  220.  }
  221.  if (g_fURLLoaded && (txtURL.value == txtURL.href))
  222.  {
  223.   window.close();
  224.   return;
  225.  }
  226.  updateProtocolSel();
  227.  if (0 < strSlashProts.indexOf(strProtocol))
  228.  {
  229.   strProtocol = strProtocol + "//";
  230.  }
  231.  initialRange = range.duplicate();
  232.  if ( IsRangeEmpty( range ) )
  233.  {
  234.   range.text = txtURL.value;
  235.   fUseExecCommand = false;
  236.  }
  237.  else
  238.  {
  239.   dupRange = range.duplicate();
  240.   iRight = dupRange.moveEnd( "Character", 2 );
  241.   if ( iRight < 2 && dupRange.htmlText == "" )
  242.   {
  243.    range.text = txtURL.value;
  244.    fUseExecCommand = false;
  245.   }
  246.  }
  247.  if ( fUseExecCommand )
  248.  {
  249.   range.execCommand(cmdCreateLink, false, txtURL.value);
  250.  }
  251.  else
  252.  {
  253.   dupRange = range.duplicate();
  254.   dupRange.move( "Character", -1 );
  255.   elmParent = dupRange.parentElement();
  256.   if (elmParent.tagName == "A")
  257.   {    
  258.    elmParent.href = txtURL.value;
  259.   }
  260.   else
  261.   {
  262.    range.setEndPoint( "StartToEnd", initialRange );
  263.    dupRange = range.duplicate();
  264.    dupRange.collapse(true); 
  265.    elmParent = dupRange.parentElement();
  266.    if (elmParent.tagName == "A")
  267.    {
  268.     range.execCommand(cmdUnlink, false);
  269.    }     
  270.    range.execCommand(cmdCreateLink, false, txtURL.value);
  271.   }
  272.  }
  273.  window.close();
  274. </SCRIPT>
  275. </HEAD>
  276. <BODY id=bdy style="font-family: MS UI Gothic; font-size: 9pt;
  277. background: threedface; color: windowtext;"
  278. onLoad="bdyLoad()" scroll=no>
  279. <FIELDSET id=fldLink style="font-family: MS UI Gothic; font-size: 9pt; 
  280. position: absolute; left: 0.98em; top: .8em; width: 26.2em; 
  281. height: 7.9em;">
  282. <LEGEND id=lgdLink>
  283. ハイパーリンク情報
  284. </LEGEND>
  285. </FIELDSET>
  286. <DIV id=div2 style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  287. left: 1.82em; top: 2.8899em; width: 3.5em; height: 1.2168em; ">
  288. <LABEL id=lblProtocol FOR=selProtocol tabIndex=-1 helpid="35550" 
  289. helpfile=msoe.hlp>
  290. 種類(<U>T</U>):
  291. </LABEL>
  292. </DIV>
  293. <select id=selProtocol size=1 ACCESSKEY=t tabIndex=50
  294. style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  295. left: 5.64em; top: 2.7378em; width: 6.44em; height: 2.1294em; "
  296. helpid="35550" helpfile=msoe.hlp>
  297. <OPTION id=optOther value="">     (その他) </OPTION>
  298. <OPTION id=optFile value="file:">   file: </OPTION>
  299. <OPTION id=optFtp value="ftp:">    ftp: </OPTION>
  300. <OPTION id=optGopher value="gopher:">   gopher: </OPTION>
  301. <OPTION id=optHttp value="http:" SELECTED> http: </OPTION>
  302. <OPTION id=optHttps value="https:">   https: </OPTION>
  303. <OPTION id=optMailto value="mailto:">   mailto: </OPTION>
  304. <OPTION id=optNews value="news:">   news: </OPTION>
  305. <OPTION id=optTelnet value="telnet:">   telnet: </OPTION>
  306. <OPTION id=optWais value="wais:">   wais: </OPTION>
  307. </select>
  308. <DIV id=div3 style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  309. left: 1.82em; top: 5.9319em; width: 3.5em; height: 1.2168em; ">
  310. <LABEL id=lblURL FOR=txtURL tabIndex=-1 helpid="35550" 
  311. helpfile=msoe.hlp>
  312. URL(<U>U</U>):
  313. </LABEL>
  314. </DIV>
  315. <input accesskey=u ID="txtURL" value="http://" type=text size=35
  316. maxlength=1024 tabIndex=15 helpid="35550" helpfile=msoe.hlp
  317. style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  318. left: 5.64em; top: 5.6277em; width: 20.72em; height: 1.7em; ">
  319. <BUTTON id=btnOK tabIndex=35 DISABLED=1 helpid="28443" helpfile="windows.hlp"
  320. style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  321. left: 28em; top: 1.521em; width: 7em; height: 1.8em; " type=submit>
  322. OK
  323. </BUTTON>
  324. <BUTTON id=btnCancel tabIndex=40 helpid="28444" helpfile="windows.hlp"
  325. style="font-family: MS UI Gothic; font-size: 9pt; position: absolute;
  326. left: 28em; top: 4.1067em; width: 7em; height: 1.8em; " type=reset>
  327. キャンセル
  328. </BUTTON>
  329. </BODY>
  330. </HTML>
  331.