home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
- <HTML id=dlgLink STYLE="font-family: 'ms sans serif'; font-size: '8pt';
- width: '32.7em'; height: '15em'">
- <HEAD>
- <META NAME=GENERATOR CONTENT="Trident 3411">
- <TITLE>Link</TITLE>
-
- <SCRIPT LANGUAGE=JavaScript>
-
- //+-------------------------------------------------------------------------
- //
- // This section contains code to be moved into a GLOBAL MODULE outside
- // of this particular dialog.
- //
- //--------------------------------------------------------------------------
-
-
- //----------------------------------------------------------------------
- //
- // Synopsis: Turns on the document's expando property. When this
- // property is on, it is possible to create new expando
- // properties or assign to existing ones.
- //
- // Arguments: none
- //
- // Returns: Nothing
- //
- //----------------------------------------------------------------------
-
- function expandoOn()
- {
- document.expando = true;
- } // expandoOn
-
-
- //----------------------------------------------------------------------
- //
- // Synopsis: Turns off the document's expando property. When this
- // property is off, it is possible to read the value of
- // existing expando properties, but not possible to create
- // new ones or modify existing ones.
- //
- // EXPANDO SHOULD BE OFF EXCEPT WHEN CREATING/MODIFYING
- // EXPANDO PROPERTIES. This will save hours debugging
- // accidentally created expando properties.
- //
- // Arguments: none
- //
- // Returns: Nothing.
- //
- //----------------------------------------------------------------------
-
- function expandoOff()
- {
- document.expando = false;
- } // expandoOff
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Given a string, returns the number the string represents.
- // This is needed because current localization tools can
- // only find strings.
- //
- // Arguments: string The string we're changing into a number.
- //
- // Returns: a number
- //
- //----------------------------------------------------------------------
-
- function number(string)
- {
- return parseFloat(string);
- } // number
-
- </SCRIPT>
-
- <SCRIPT LANGUAGE=JavaScript>
-
- //+--------------------------------------------------------------------------
- //
- // This section contains variables that need to be LOCALIZED
- //
- //---------------------------------------------------------------------------
-
- // var L_EditLink_DIALOG_Width_Text = "32.7em";
- // var L_EditLink_DIALOG_Height_Text = "15em";
-
- var L_NoHelp_Text = "No help topic available.";
-
- </SCRIPT>
-
-
- <SCRIPT LANGUAGE="JavaScript">
-
- //+-------------------------------------------------------------------------
- //
- // This section contains code LOCAL to this particular dialog.
- //
- //--------------------------------------------------------------------------
-
- expandoOff();
-
- // Set dialog dimensions
- // window.width = L_EditLink_DIALOG_Width_Text;
- // window.height = L_EditLink_DIALOG_Height_Text;
-
- // Constants
- var cmdCreateLink = "CreateLink";
- var cmdUnlink = 2125;
-
- // Global variables
- var globalDoc = window.dialogArgs.document;
- var gboolNewLink = true; // Is the link a new link?
-
-
- //+----------------------------------------------------------------------
- //
- // Synopsis: Given a text range, returns an anchor element if that
- // element appears within or overlaps the range. If no
- // anchor exists, returns null.
- //
- // Arguments: range The range we're looking for an element in.
- //
- // Returns: an anchor element if one is found, null if one is not.
- //
- //-----------------------------------------------------------------------
-
- function findAnchor(range)
- {
- var rangeWorking;
- var elmWorking;
- var index;
-
- //
- // First, look for the anchor as a parent element of the range
- // NOTE: This will only find an anchor under fairly special
- // circumstances (the first character of the range is part of an
- // anchor), but it's much faster than the method below.
- //
- elmWorking = range.parentElement( )
-
- while ("HTML" != elmWorking.tagName)
- {
- if ("A" == elmWorking.tagName)
- {
- return elmWorking;
- }
- else
- {
- elmWorking = elmWorking.parentElement
- }
- }
-
- //
- // That didn't work, so let's walk through each character in the
- // range and see if there's an anchor somewhere.
- //
- rangeWorking = range.duplicate( );
-
- //
- // Reduce rangeWorking to one character
- //
- rangeWorking.end = rangeWorking.start + 1;
-
- while (rangeWorking.end < range.end)
- {
- rangeWorking.move("Character");
- //
- // "Wait!" you're saying. "You can't move rngWorking yet,
- // you'll miss the first character." If the first character
- // is part of an anchor, the section of code above will catch
- // it.
- //
- if (null != findAnchor(rangeWorking))
- {
- return findAnchor(rangeWorking);
- }
- }
-
- //
- // Nothing yet found an anchor, so I guess there isn't one.
- //
- return null;
- } // findAnchor
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Returns the protocol when given a URL.
- //
- // Arguments: strURL The URL to get the protocol from
- //
- // Returns: a string that matches a protocol or null if no match is
- // found.
- //
- //----------------------------------------------------------------------
-
- function getProtocolFromURL(strURL)
- {
- var index;
-
- //
- // We're assuming that the protocol ends at the first colon.
- //
- return strURL.substring(0, strURL.indexOf(":") + 1);
- }
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Updates the protocol combo box based on the entry in
- // the URL text box
- //
- // Arguments: None
- //
- // Returns: nothing
- //
- //----------------------------------------------------------------------
-
- function updateProtocolSel()
- {
- var index;
- var strProtocol = getProtocolFromURL(txtURL.value);
-
- //
- // Loop through the options in selProtocol to see if one matches
- //
- selProtocol.value = strProtocol;
-
- //
- // No match was found. Select "other".
- //
- if (selProtocol.value != strProtocol)
- {
- selProtocol.value = "";
- }
- } // updateProtocolSel
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Updates the protocol portion of txtURL based on the
- // selection in selProtocol
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //----------------------------------------------------------------------
-
- function updateProtocolTxt()
- {
- var strSlashProts = " file:ftp:gopher:http:https:"; // Some protocols are
- // followed by 2 slashes
- var strProtocolTxt = getProtocolFromURL(txtURL.value);
- var strProtocolSel = selProtocol.value;
- var strTempURL;
-
- //
- // If the protocol is followed by two slashes, append them to the protocol
- //
- if ("//" == (txtURL.value.substring(strProtocolTxt.length, strProtocolTxt.length + 2)))
- {
- strProtocolTxt = strProtocolTxt + "//";
- }
-
- //
- // Remove protocol from current URL
- //
- strTempURL = txtURL.value.substring(strProtocolTxt.length);
-
- if (0 < strSlashProts.indexOf(strProtocolSel))
- {
- strProtocolSel = strProtocolSel + "//";
- }
-
- txtUrl.value = strProtocolSel + strTempURL;
-
- } // updateProtocolTxt
-
-
- //----------------------------------------------------------------------
- //
- // Synopsis: Initialize the dialog
- //
- // Arguments: None
- //
- // Returns: nothing
- //
- //----------------------------------------------------------------------
-
- function bdyLoad()
- {
- var rngMaster;
- var rngLink;
- var elmLink;
-
- if (("Text" == globalDoc.selection.type) || ("None" == globalDoc.selection.type))
- {
- rngMaster = globalDoc.selection.createRange();
- elmLink = findAnchor(rngMaster);
-
- if (null != elmLink)
- {
- gboolNewLink = false;
-
- //
- // If the range contains an anchor, expand it to encompass the anchor
- //
- rngLink = globalDoc.rangeFromElement(elmLink);
-
- if (rngLink.start < rngMaster.start)
- {
- rngMaster.start = rngLink.start;
- }
- if (rngLink.end > rngMaster.end)
- {
- rngMaster.end = rngLink.end;
- }
- rngMaster.select();
-
- //
- // Fill the dialog with info about the link
- //
- txtURL.value = elmLink.href
- updateProtocolSel();
- }
- }
- } // bdyLoad
-
-
- //----------------------------------------------------------------------
- //
- // Synopsis: Discard the user's changes and dismiss the dialog.
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //----------------------------------------------------------------------
-
- function btnCancelClick()
- {
- window.close();
- } // btnCancelClick
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Inserts a link in the document
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //----------------------------------------------------------------------
-
- function btnOKClick()
- {
- var range;
- var boolNoURL; // true if there's nothing typed into the txtURL
- var strSlashProts = " file:ftp:gopher:http:https:"; // Some protocols are
- // followed by 2 slashes
- var strProtocol = selProtocol.value; // The Protocol currently selected
-
- updateProtocolSel();
-
- if (0 < strSlashProts.indexOf(strProtocol))
- {
- strProtocol = strProtocol + "//";
- }
-
- //
- // If txtURL is blank, then there's noURL
- //
- if ("" == txtURL.value)
- {
- boolNoURL = true;
- }
- //
- // If txtURL exactly matches the protocol, there's no URL
- //
- else if (txtURL.value == selProtocol.value)
- {
- boolNoURL = true;
- }
- //
- // If txtURL matches the protocol + "//" and the protocol is in strSlashProts,
- // There's no URL.
- //
- else if (strProtocol == txtURL.value)
- {
- boolNoURL = true;
- }
- //
- // All out of cases. There must be a URL.
- //
- else
- {
- boolNoURL = false;
- }
-
- //
- // If no text (or only the protocol) is entered into txtURL, unlink the selection
- //
- if (boolNoURL)
- {
- range = globalDoc.selection.createRange();
- range.execCommand(cmdUnlink);
- }
- else
- {
- //
- // If no text is selected, add the URL as the text, then select it.
- //
- if ("None" == globalDoc.selection.type)
- {
- range = globalDoc.selection.createRange();
- range.text = txtURL.value;
- range.start = range.start - txtURL.value.length
- range.select();
- }
-
- range = globalDoc.selection.createRange()
-
- range.execCommand(cmdCreateLink, false, txtURL.value);
- }
-
- window.close();
- } // btnOKClick
-
- </SCRIPT>
-
- <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onkeypress()">
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Looks for the ENTER and ESC keypresses and runs the
- // appropriate action.
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //-----------------------------------------------------------------------
-
- var htmlKeyReturn = 13;
- var htmlKeyEscape = 27;
-
- if ((event.keyCode) == htmlKeyReturn) // Enter
- {
- btnOKClick();
- btnOK.focus();
- }
-
- if ((event.keyCode) == htmlKeyEscape) // Esc
- {
- btnCancelClick();
- }
-
- </SCRIPT>
-
- <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onhelp()">
-
- //+-------------------------------------------------------------------------
- //
- // Synopsis: Opens the help file with the appropriate helpid
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //--------------------------------------------------------------------------
-
- // BUGBUG Once we get help for the editing dialogs, this function
- // will have to change.
- alert(L_NoHelp_Text);
-
- </SCRIPT>
-
- </HEAD>
-
- <BODY style="font-family: 'ms sans serif'; font-size: '8pt'; background: buttonface;" onLoad="bdyLoad()">
-
- <TABLE cellPadding=7 cellspacing borderColorDark=buttonhighlight borderColorLight=buttonshadow noshade="yes" border=1
- style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '1em'; TOP: '1.5em'; width: '30.5em'; height: '7em'">
-
- <TR>
- <TD style="font: position: relative;LEFT: '0'; TOP: '0'; WIDTH: '20em'; HEIGHT: '4.5em'">
- <DIV style="color: buttonface;">a</DIV>
- </TD>
- </TR>
- </TABLE>
-
- <DIV style="position: absolute; LEFT: '2.4em'; TOP: '2.9em'; WIDTH: '8em'; HEIGHT: '2.1em'; font-family: 'ms sans serif'; font-size: '8pt';">
- <LABEL FOR=selProtocol tabIndex=-1>
- <u>H</u>yperlink Type:
- </LABEL>
- </DIV>
-
- <select id=selProtocol size=1 ACCESSKEY=h tabIndex=10 onchange="updateProtocolTxt()"
- style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '10.5em'; TOP:'2.6em'; WIDTH: '10em'; HEIGHT: '2.1em'">
- <OPTION value=""> (other) </OPTION>
- <OPTION value="file:" SELECTED> file: </OPTION>
- <OPTION value="ftp:"> ftp: </OPTION>
- <OPTION value="gopher:"> gopher: </OPTION>
- <OPTION value="http:"> http: </OPTION>
- <OPTION value="https:"> https: </OPTION>
- <OPTION value="mailto:"> mailto: </OPTION>
- <OPTION value="news:"> news: </OPTION>
- <OPTION value="telnet:"> telnet: </OPTION>
- <OPTION value="wais:"> wais: </OPTION>
- </select>
-
- <DIV style="position: absolute; LEFT: '2.4em'; TOP: '5.8em'; WIDTH: '8em'; HEIGHT: '1.7em'; font-family: 'ms sans serif'; font-size: '8pt';">
- <LABEL FOR=txtURL tabIndex=-1>
- <u>U</u>RL:
- </LABEL>
- </DIV>
-
- <input accesskey=u ID="txtURL" value="file://" type=text size=35 maxlength=256 tabIndex=15
- style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '6em'; TOP: '5.5em'; WIDTH: '20em'; HEIGHT: '2.1em'">
-
- <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;background: buttonface; HEIGHT: '1em'; LEFT: '1.8em'; TOP: '1em'; WIDTH: '8em'">
- <LABEL tabindex=-1> Link information</LABEL>
- </DIV>
-
-
- <BUTTON id=btnOK tabIndex=35 onclick="btnOKClick()"
- style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '16em'; TOP: '9.5em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
- OK
- </BUTTON>
-
- <BUTTON id=btnCancel tabIndex=40 onclick="btnCancelClick()"
- style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '23.6em'; TOP: '9.5em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
- Cancel
- </BUTTON>
-
-
- </BODY >
-
- </HTML>
-