home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 45 / PCGAMER45.bin / netware / msie4pp / ie4_s3.cab / IE4_3.CAB / MSHTMENU.DLL / 2110 / EDBOOK.DLG < prev    next >
Text File  |  1997-04-04  |  11KB  |  369 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
  2. <HTML STYLE="font: messagebox">
  3. <HEAD>
  4. <META NAME=GENERATOR CONTENT="Trident 3411">
  5. <TITLE>Bookmark</TITLE>
  6.  
  7. <SCRIPT LANGUAGE=JavaScript>
  8.  
  9. //+-------------------------------------------------------------------------
  10. //
  11. //  This section contains code to be moved into a GLOBAL MODULE outside
  12. //  of this particular dialog.
  13. //
  14. //--------------------------------------------------------------------------
  15.  
  16.  
  17.     //----------------------------------------------------------------------
  18.     //
  19.     //  Synopsis:   Turns on the document's expando property.  When this
  20.     //              property is on, it is possible to create new expando
  21.     //              properties or assign to existing ones.
  22.     //
  23.     //  Arguments:  none
  24.     //
  25.     //  Returns:    Nothing
  26.     //
  27.     //----------------------------------------------------------------------
  28.  
  29.     function expandoOn()
  30.     {
  31.         document.expando = true;
  32.     }   //  expandoOn
  33.  
  34.  
  35.     //----------------------------------------------------------------------
  36.     //
  37.     //  Synopsis:   Turns off the document's expando property.  When this
  38.     //              property is off, it is possible to read the value of
  39.     //              existing expando properties, but not possible to create
  40.     //              new ones or modify existing ones.
  41.     //
  42.     //              EXPANDO SHOULD BE OFF EXCEPT WHEN CREATING/MODIFYING
  43.     //              EXPANDO PROPERTIES.  This will save hours debugging
  44.     //              accidentally created expando properties.
  45.     //
  46.     //  Arguments:  none
  47.     //
  48.     //  Returns:    Nothing.
  49.     //
  50.     //----------------------------------------------------------------------
  51.  
  52.     function expandoOff()
  53.     {
  54.         document.expando = false;
  55.     }   //  expandoOff
  56.  
  57. </SCRIPT>
  58.  
  59. <SCRIPT LANGUAGE=JavaScript>
  60.  
  61. //+--------------------------------------------------------------------------
  62. //
  63. //  This section contains variables that need to be LOCALIZED
  64. //
  65. //---------------------------------------------------------------------------
  66.  
  67. var L_EditBookmark_DIALOG_Width_Text  = "38em";
  68. var L_EditBookmark_DIALOG_Height_Text = "16em";
  69.  
  70. var L_NoHelp_Text = "No help topic available.";
  71.  
  72. </SCRIPT>
  73.  
  74.  
  75. <SCRIPT LANGUAGE="JavaScript">
  76.  
  77. //+-------------------------------------------------------------------------
  78. //
  79. //  This section contains code LOCAL to this particular dilaog.
  80. //
  81. //--------------------------------------------------------------------------
  82.  
  83.     expandoOff();
  84.  
  85.     //  Set dialog dimensions
  86.     window.width   = L_EditBookmark_DIALOG_Width_Text;
  87.     window.height  = L_EditBookmark_DIALOG_Height_Text;
  88.  
  89.     //  Constants
  90.     var cmdBookmark     = "CreateBookmark";
  91.     var cmdUnbookmark   = 2128;
  92.  
  93.     // Global variables
  94.     var globalDoc   = window.dialogArgs.document;
  95.     var gboolNewBookmark = true;                 // Is the bookmark a new bookmark?
  96.  
  97.  
  98.     //+----------------------------------------------------------------------
  99.     //
  100.     //  Synopsis:   Given a text range, returns an anchor element if that
  101.     //              element appears within or overlaps the range. If no
  102.     //              anchor exists, returns null.
  103.     //
  104.     //  Arguments:  range   The range we're looking for an element in.
  105.     //
  106.     //  Returns:    an anchor element if one is found, null if one is not.
  107.     //
  108.     //-----------------------------------------------------------------------
  109.  
  110.     function findAnchor(range)
  111.     {
  112.         var rangeWorking;
  113.         var elmWorking;
  114.         var index;
  115.  
  116.         //
  117.         //  First, look for the anchor as a parent element of the range
  118.         //  NOTE: This will only find an anchor under fairly special
  119.         //  circumstances (the first character of the range is part of an
  120.         //  anchor), but it's much faster than the method below.
  121.         //
  122.         elmWorking = range.parentElement( )
  123.  
  124.         while ("HTML" != elmWorking.tagName)
  125.         {
  126.             if ("A" == elmWorking.tagName)
  127.             {
  128.                 return elmWorking;
  129.             }
  130.             else
  131.             {
  132.                 elmWorking = elmWorking.parentElement
  133.             }
  134.         }
  135.  
  136.         //
  137.         //  That didn't work, so let's walk through each character in the
  138.         //  range and see if there's an anchor somewhere.
  139.         //
  140.         rangeWorking = range.duplicate( );
  141.  
  142.         //
  143.         //  Reduce rangeWorking to one character
  144.         //
  145.         rangeWorking.end = rangeWorking.start + 1;
  146.  
  147.         while (rangeWorking.end < range.end)
  148.         {
  149.             rangeWorking.move("Character");
  150.             //
  151.             //  "Wait!" you're saying. "You can't move rngWorking yet,
  152.             //  you'll miss the first character." If the first character
  153.             //  is part of an anchor, the section of code above will catch
  154.             //  it.
  155.             //
  156.             if (null != findAnchor(rangeWorking))
  157.             {
  158.                 return findAnchor(rangeWorking);
  159.             }
  160.         }
  161.  
  162.         //
  163.         //  Nothing yet found an anchor, so I guess there isn't one.
  164.         //
  165.         return null;
  166.     }   //  findAnchor
  167.  
  168.  
  169.     //----------------------------------------------------------------------
  170.     //
  171.     //  Synopsis:   Initialize the dialog
  172.     //
  173.     //  Arguments:  None
  174.     //
  175.     //  Returns:    nothing
  176.     //
  177.     //----------------------------------------------------------------------
  178.  
  179.     function bdyLoad()
  180.     {
  181.         var rngMaster;
  182.         var rngBookmark;
  183.         var elmBookmark;
  184.  
  185.         if (("Text" == globalDoc.selection.type) || ("None" == globalDoc.selection.type))
  186.         {
  187.             rngMaster = globalDoc.selection.createRange();
  188.             elmBookmark = findAnchor(rngMaster);
  189.  
  190.             if (null != elmBookmark)
  191.             {
  192.                 gboolNewBookmark = false;
  193.  
  194.                 //
  195.                 //  If the range contains an anchor, expand it to encompass the anchor
  196.                 //
  197.                 rngBookmark = globalDoc.rangeFromElement(elmBookmark);
  198.                 if (rngBookmark.start < rngMaster.start)
  199.                 {
  200.                     rngMaster.start = rngBookmark.start;
  201.                 }
  202.                 if (rngBookmark.end > rngMaster.end)
  203.                 {
  204.                     rngMaster.end = rngBookmark.end;
  205.                 }
  206.                 rngMaster.select();
  207.  
  208.                 //
  209.                 //  Fill the dialog with info about the link
  210.                 //
  211.                 txtName.value = elmBookmark.name;
  212.             }
  213.         }
  214.     }   // bdyLoad
  215.  
  216.  
  217.     //----------------------------------------------------------------------
  218.     //
  219.     //  Synopsis:   Discard the user's changes and dismiss the dialog.
  220.     //
  221.     //  Arguments:  none
  222.     //
  223.     //  Returns:    nothing
  224.     //
  225.     //----------------------------------------------------------------------
  226.  
  227.     function btnCancelClick()
  228.     {
  229.         window.close();
  230.     }   //  btnCancelClick
  231.  
  232.  
  233.     //+---------------------------------------------------------------------
  234.     //
  235.     //  Synopsis:   Inserts a bookmark in the document
  236.     //
  237.     //  Arguments:  none
  238.     //
  239.     //  Returns:    nothing
  240.     //
  241.     //----------------------------------------------------------------------
  242.  
  243.     function btnOKClick()
  244.     {
  245.         var range;
  246.  
  247.         //
  248.         //  if txtName is empty, delete the bookmark if it exists.
  249.         //  Otherwise, create the bookmark
  250.         //
  251.         if ("" == txtName.value)
  252.         {
  253.             range = globaldoc.selection.createRange();
  254.             range.execCommand(cmdUnbookmark, false);
  255.         }
  256.         else
  257.         {
  258.             //
  259.             //  If no text is selected, add the URL as the text, then select it.
  260.             //
  261.             if ("None" == globalDoc.selection.type)
  262.             {
  263.                 range = globalDoc.selection.createRange();
  264.                 range.text = txtName.value;
  265.                 range.start = range.start - txtName.value.length
  266.                 range.select();
  267.             }
  268.  
  269.             range = globalDoc.selection.createRange()
  270.  
  271.             range.execCommand(cmdBookmark, false, txtName.value);
  272.         }
  273.  
  274.         window.close();
  275.     }   //  btnOKClick
  276.  
  277. </SCRIPT>
  278.  
  279. <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onkeypress()">
  280.  
  281. //+---------------------------------------------------------------------
  282. //
  283. //  Synopsis:   Looks for the ENTER and ESC keypresses and runs the
  284. //              appropriate action.
  285. //
  286. //  Arguments:  none
  287. //
  288. //  Returns:    nothing
  289. //
  290. //-----------------------------------------------------------------------
  291.  
  292.     var htmlKeyReturn = 13;
  293.     var htmlKeyEscape = 27;
  294.  
  295.     if ((event.keyCode) == htmlKeyReturn)     //  Enter
  296.     {
  297.         btnOKClick();
  298.         btnOK.focus();
  299.     }
  300.  
  301.     if ((event.keyCode) == htmlKeyEscape)     //  Esc
  302.     {
  303.         btnCancelClick();
  304.     }
  305.  
  306. </SCRIPT>
  307.  
  308. <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onhelp()">
  309.  
  310. //+-------------------------------------------------------------------------
  311. //
  312. //  Synopsis:   Opens the help file with the appropriate helpid
  313. //
  314. //  Arguments:  none
  315. //
  316. //  Returns:    nothing
  317. //
  318. //--------------------------------------------------------------------------
  319.  
  320.     //  BUGBUG  Once we get help for the editing dialogs, this function 
  321.     //          will have to change.
  322.     alert(L_NoHelp_Text);
  323.  
  324. </SCRIPT>
  325.  
  326. </HEAD>
  327.  
  328. <BODY  style="background: 'buttonface';" onLoad="bdyLoad()" >
  329.  
  330. <TABLE cellPadding=7 cellspacing borderColorDark=buttonhighlight borderColorLight=buttonshadow noshade="yes"
  331. border=1 style="position: absolute;LEFT: '.8em'; TOP: '.8em'">
  332.  
  333. <TR>
  334. <TD style="position: relative;LEFT: 0; TOP: 0; WIDTH: '22em'; HEIGHT: '4em'">
  335.  
  336.  
  337.    <DIV style="position: absolute;LEFT: '.8em'; TOP: '3.5em'; WIDTH: '8em'; HEIGHT: '1.7em';font: messagebox;">
  338.     <LABEL FOR=txtName tabIndex=-1>
  339.     <u>N</u>ame:
  340.     </LABEL>
  341.     </DIV>
  342.     <DIV style="position: absolute;LEFT: '6em'; TOP: '2em'; WIDTH: '10em'; HEIGHT: '1.7em'">
  343.     <input ID="txtName" type=text size=35 maxlength=256 tabIndex=15
  344.     ACCESSKEY=n style="font: messagebox">
  345.  
  346.     </DIV>
  347.  
  348. </TD>
  349. </TR>
  350. </TABLE>
  351.  
  352. <DIV style="position: absolute;background: buttonface; HEIGHT: '1em'; LEFT: '1.6em'; TOP: '.5em'; WIDTH: '10em'">
  353. <LABEL tabindex=-1>  Bookmark information</LABEL>
  354. </DIV>
  355.  
  356.  
  357. <BUTTON id=btnOK tabIndex=35 onclick="btnOKClick()"
  358. style="position: absolute;LEFT: '18.0em'; TOP: '9.5em'; WIDTH: '7.5em'; HEIGHT: '2.5em'">
  359. OK
  360. </BUTTON>
  361. <BUTTON id=btnCancel tabIndex=40 onclick="btnCancelClick()"
  362. style="position: absolute;LEFT: '26em'; TOP: '9.5em'; WIDTH: '7.5em'; HEIGHT: '2.5em'">
  363. Cancel
  364. </BUTTON>
  365.  
  366. </BODY>
  367.  
  368. </HTML>
  369.