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