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 / FIND.DLG < prev    next >
Text File  |  1997-04-04  |  14KB  |  427 lines

  1. <HTML id=dlgFind STYLE="font-family: 'ms sans serif'; font-size: '8pt';
  2. width: '32.7em'; height: '11em'">
  3. <HEAD>
  4. <TITLE id=dialogTitle>
  5. Find
  6. </TITLE>
  7.  
  8. <SCRIPT LANGUAGE="JavaScript" defer>
  9.  
  10. //+-------------------------------------------------------------------------
  11. //
  12. //  This section contains code to be moved into a GLOBAL MODULE outside
  13. //  of this particular dialog.
  14. //
  15. //--------------------------------------------------------------------------
  16.  
  17.  
  18. //+--------------------------------------------------------------------------
  19. //
  20. //  This section contains variables that need to be LOCALIZED
  21. //
  22. //---------------------------------------------------------------------------
  23.  
  24.  
  25.  
  26. //+-------------------------------------------------------------------------
  27. //
  28. //  This section contains code LOCAL to this particular dilaog.
  29. //
  30. //--------------------------------------------------------------------------
  31.  
  32.     //+--------------------------------------------------------------------
  33.     //
  34.     //  Synopsis:   Opens the help file with the appropriate helpid
  35.     //
  36.     //  Arguments:  none
  37.     //
  38.     //  Returns:    nothing
  39.     //
  40.     //---------------------------------------------------------------------
  41.  
  42.     function callHelp()
  43.     {
  44.         var L_NoHelp_Text = "No help topic available.";
  45.         var elm = window.event.srcElement;
  46.         if (null != elm.helpid)
  47.         {
  48.             if ("btnCancel" != elm.id)
  49.             {
  50.                 window.showHelp("iexplore.hlp", parseInt(elm.helpid));
  51.             }
  52.             else
  53.             {
  54.                 //  BUGBUG  (19759) Once we get help for cancel, this
  55.                 //          function will have to change.
  56.                 alert(L_NoHelp_Text);
  57.             }
  58.         }
  59.     }   //  callHelp
  60.  
  61.  
  62.     //+--------------------------------------------------------------------
  63.     //
  64.     //  Synopsis:   Closes the dialog doing nothing.
  65.     //
  66.     //  Arguments:  none
  67.     //
  68.     //  Returns:    nothing
  69.     //
  70.     //---------------------------------------------------------------------
  71.  
  72.     function btnCancelClick()
  73.     {
  74.         window.close();
  75.     }   //  btnCancelClick
  76.  
  77.  
  78.     //+---------------------------------------------------------------------
  79.     //
  80.     //  Synopsis:   Checks the status of the appropriate checkboxes and
  81.     //              sets the flags for the rangeFromText method.
  82.     //
  83.     //  Arguments:  none
  84.     //
  85.     //  returns:    a number representing the flags for the rangeFromText
  86.     //              method. (See OM spec for more info.)
  87.     //
  88.     //----------------------------------------------------------------------
  89.  
  90.     function findFlags()
  91.     {
  92.         var htmlMatchWord = 2;
  93.         var htmlMatchCase = 4;
  94.  
  95.         return (htmlMatchWord * document.all.chkWholeWord.checked)
  96.             | (htmlMatchCase * document.all.chkMatchCase.checked)
  97.     }   //  findFlags
  98.  
  99.  
  100.     //+---------------------------------------------------------------------
  101.     //
  102.     //  Synopsis:   Three steps:
  103.     //              1. Make sure there's something to find.
  104.     //              2. Determine the direction and how far to search.
  105.     //              3. Find and select the text.
  106.     //
  107.     //  Arguments:  none
  108.     //
  109.     //  Returns:    nothing
  110.     //
  111.     //-----------------------------------------------------------------------
  112.  
  113.     function btnFindClick()
  114.     {
  115.         var L_FinishedDocument_Text = "Finished searching the document.";
  116.         var docSearch = window.dialogArgs.document; //  The document we're
  117.                                                     //  searching
  118.         var intDirection;       //  What direction to search and
  119.                                 //  how far to search
  120.         var rngCurrent = docSearch.selection.createRange(); //  The current
  121.                                                             //  selection in
  122.                                                             //  the document
  123.         var rngWorking = docSearch.body.createTextRange();  //  The range we're
  124.                                                             //  going to search
  125.         var rngFoundText;       //  The found text
  126.         var fFoundText = false; //  If the text has already been found
  127.  
  128.         //
  129.         //  If the current selection == the text in txtFindText,
  130.         //  we've found the text at least once. (At least we can
  131.         //  act as if we have.)
  132.         //
  133.         if ((docSearch.selection.type == "Text") ||
  134.             (docSearch.selection.type == "None"))
  135.         {
  136.             fFoundText = (rngCurrent.text.toLowerCase()
  137.                 == txtFindText.value.toLowerCase());
  138.         }
  139.  
  140.         //
  141.         //  rngWorking starts as the entire body, and is then narrowed
  142.         //  down by the 'set direction' code.
  143.         //
  144.  
  145.         //
  146.         //  Set direction
  147.         //
  148.         if (radDirection[0].checked)    //  Search backwards
  149.         {
  150.             //
  151.             //  set range to search
  152.             //
  153.             if (!fFoundText)
  154.             {
  155.                 //
  156.                 //  Search from the end of the current selection
  157.                 //  to the beginning of document
  158.                 //
  159.                 rngWorking.end = rngCurrent.end;
  160.             }
  161.             else
  162.             {
  163.                 //
  164.                 //  Search from the end of the current selection
  165.                 //  minus 1 so we don't find the text we just found
  166.                 //
  167.                 rngWorking.end = rngCurrent.end - 1;
  168.             }
  169.             intDirection = rngWorking.start - rngWorking.end    //  Should
  170.                                                       //  be negative or 0
  171.         }
  172.         else                            //  Search forwards
  173.         {
  174.             //
  175.             //  set range to search
  176.             //
  177.             if (!fFoundText)
  178.             {
  179.                 //
  180.                 //  Search from start of the current selection to the end
  181.                 //  of document
  182.                 //
  183.                 rngWorking.start = rngCurrent.start;
  184.             }
  185.             else
  186.             {
  187.                 //
  188.                 //  Search from the start of the current selection plus
  189.                 //  one so we don't find the text we just found
  190.                 //
  191.                 rngWorking.start = rngCurrent.start + 1;
  192.             }
  193.             intDirection = rngWorking.end - rngWorking.start    //  Should
  194.                                                     //  be positive or 0
  195.         }
  196.  
  197.         //
  198.         //  Here's where we do the dirty work (step 3) ...
  199.         //
  200.         rngFoundText = docSearch.rangeFromText(txtFindText.value,
  201.             intDirection, findFlags(), rngWorking);
  202.  
  203.         if (null == rngFoundText)   //  Text was not found
  204.         {
  205.             alert(L_FinishedDocument_Text);
  206.         }
  207.         else                        //  Text was found
  208.         {
  209.             rngFoundText.select();
  210.             rngFoundText.scrollIntoView(true);
  211.         }
  212.     }   //  btnFindClick
  213.  
  214.  
  215.     //+---------------------------------------------------------------------
  216.     //
  217.     //  Synopsis:   Looks for the ENTER and ESC keypresses and runs the
  218.     //              appropriate action.
  219.     //
  220.     //  Arguments:  none
  221.     //
  222.     //  Returns:    nothing
  223.     //
  224.     //-----------------------------------------------------------------------
  225.  
  226.     function defaultActions()
  227.     {
  228.         var htmlKeyReturn = 13;
  229.         var htmlKeyEscape = 27;
  230.  
  231.         if ((event.keyCode) == htmlKeyReturn)       //  Enter
  232.         {
  233.             if (!btnFind.disabled)
  234.             {
  235.                 btnFindClick();
  236.                 btnFind.focus();
  237.             }
  238.         }
  239.         else if ((event.keyCode) == htmlKeyEscape)  //  Esc
  240.         {
  241.             btnCancelClick();
  242.         }
  243.     }   //  defaultActions
  244.  
  245.  
  246.     //+---------------------------------------------------------------------
  247.     //
  248.     //  Synopsis:   Disables or enables the find button depending in
  249.     //              whether there is text in txtFindText.
  250.     //
  251.     //  Arguments:  none
  252.     //
  253.     //  Returns:    nothing
  254.     //
  255.     //----------------------------------------------------------------------
  256.  
  257.     function setFindState()
  258.     {
  259.         if ("" == txtFindText.value)
  260.         {
  261.             btnFind.disabled = true;
  262.         }
  263.         else
  264.         {
  265.             btnFind.disabled = false;
  266.         }
  267.     }   //  setFindState
  268.  
  269.  
  270.     //+---------------------------------------------------------------------
  271.     //
  272.     //  Synopsis:   Sets the focus to the find button. Also determines
  273.     //              whether something is selected in the document.
  274.     //
  275.     //  Arguments:  none
  276.     //
  277.     //  Returns:    nothing
  278.     //
  279.     //-----------------------------------------------------------------------
  280.  
  281.     function loadBdy()
  282.     {
  283.         var docSearch = window.dialogArgs.document;
  284.         var rng = docSearch.selection.createRange();
  285.  
  286.         //  EXPANDO SHOULD BE OFF EXCEPT WHEN CREATING/MODIFYING
  287.         //  EXPANDO PROPERTIES.  This will save hours debugging
  288.         //  accidentally created expando properties.
  289.         document.expando = false;
  290.  
  291.         //
  292.         //  Bind events to controls
  293.         //
  294.         btnFind.onclick     = new Function("btnFindClick()");
  295.         btnCancel.onclick   = new Function("btnCancelClick()");
  296.  
  297.         document.onhelp     = new Function("callHelp()");
  298.         document.onkeypress = new Function("defaultActions()");
  299.  
  300.         txtFindText.onkeyup = new Function("setFindState()");
  301.         txtFindText.onfocus = new Function("txtFindText.select()");
  302.  
  303.         //
  304.         //  If the selection is less than 16 characters, populate
  305.         //  txtFind with the selection
  306.         //
  307.         if ("Text" == docSearch.selection.type)
  308.         {
  309.             if (16 > rng.text.length)
  310.             {
  311.                 txtFindText.value = rng.text;
  312.                 txtFindText.select();
  313.             }
  314.         }
  315.  
  316.         setFindState();
  317.     }   //  loadBdy
  318.  
  319. </SCRIPT>
  320.  
  321. </HEAD>
  322. <BODY ID=bdy onLoad="loadBdy()" style="font-family: 'ms sans serif';
  323. font-size: '8pt'; background: buttonface;" topmargin=0>
  324.  
  325. <BUTTON id=btnFind ACCESSKEY=f DISABLED=1 tabIndex=55
  326. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  327. LEFT: '24.4em'; TOP: '1em';
  328. WIDTH: '6.8em'; HEIGHT: '2.1em'">
  329. <U>F</U>ind Next
  330. </BUTTON>
  331.  
  332. <INPUT type=text id=txtFindText ACCESSKEY=n tabIndex=15 helpid="0x3068"
  333. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  334. LEFT: '6.1em'; TOP: '1em';
  335. WIDTH: '17.5em'; HEIGHT: '2.1em'">
  336.  
  337. <DIV align=absMiddle
  338. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  339. LEFT: '1em'; TOP: '1.3em';
  340. WIDTH: '8em'; HEIGHT: '1.1em'">
  341. <LABEL FOR=txtFindText ID=lblFindText tabIndex=-1 helpid="0x3068">
  342. Fi<U>n</U>d what:
  343. </LABEL>
  344. </DIV>
  345.  
  346. <!--
  347. BUGBUG (#19759) waiting for helpid for the cancel button
  348. -->
  349. <BUTTON id=btnCancel tabIndex=60 helpid="0x0000"
  350. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  351. LEFT: '24.4em'; TOP: '3.5em';
  352. WIDTH: '6.8em'; HEIGHT: '2.1em'">
  353. Cancel
  354. </BUTTON>
  355.  
  356. <INPUT id=chkWholeWord ACCESSKEY=w type=checkbox tabIndex=25 helpid="0x3063"
  357. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  358. LEFT: '1em'; TOP: '4.5em';
  359. WIDTH: '1em'; HEIGHT: '1em'">
  360.  
  361. <INPUT ACCESSKEY=c type=checkbox tabIndex=35 helpid="0x3064"
  362. id=chkMatchCase style="font-family: 'ms sans serif'; font-size: '8pt';
  363. position: absolute;LEFT: '1em';
  364. TOP: '6.3em'; WIDTH: '1em'; HEIGHT: '1em'">
  365.  
  366. <DIV
  367. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  368. LEFT: '2.9em'; TOP: '4.5em';
  369. WIDTH: '12em'; HEIGHT: '1em'">
  370. <LABEL FOR=chkWholeWord ID=lblWholeWord tabIndex=-1 helpid="0x3063">
  371. Match <U>w</U>hole word only
  372. </LABEL>
  373. </DIV>
  374.  
  375. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  376. LEFT: '2.9em'; TOP: '6.3em';
  377. WIDTH: '6em'; HEIGHT: '1.1em'">
  378. <LABEL FOR=chkMatchCase ID=lblMatchCase tabIndex=-1 helpid="0x3064">
  379. Match <U>c</U>ase
  380. </LABEL>
  381. </DIV>
  382.  
  383. <TABLE cellspacing cellPadding=7 borderColorDark=buttonhighlight
  384. borderColorLight=buttonshadow noshade="yes" border=1
  385. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  386. LEFT: '14em'; TOP: '4.5em';
  387. WIDTH:'9.5em'; HEIGHT: '3em'">
  388.     <TR>
  389.         <TD style="font-family: 'ms sans serif'; font-size: '8pt'; width: '6.4em';
  390.         height: '2em';">
  391.         <DIV style="color: buttonface">a</DIV>
  392.         </TD></TR>
  393. </TABLE>
  394.  
  395.  
  396.         <INPUT id=radDirectionUp type=radio name=radDirection ACCESSKEY=u
  397.         tabIndex=42 helpid="0x3065"
  398.         style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  399.         top: '5.7em'; left: '15em'; width: '1em'; height: '1em';">
  400.         <DIV style="font-family: 'ms sans serif'; font-size: '8pt';
  401.         position: absolute;top: '5.7em'; left: '16.5em'; width: '2em';
  402.         height: '2em';">
  403.         <LABEL style="font-family: 'ms sans serif'; font-size: '8pt'"
  404.         FOR=radDirectionUp ID=lblDirectionUp
  405.         tabIndex=45 helpid="0x3065"> <U>U</U>p </LABEL>
  406.         </DIV>
  407.         <INPUT id=radDirectionDown type=radio CHECKED name=radDirection
  408.         ACCESSKEY=d tabIndex=47 helpid="0x3066"
  409.         style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  410.         top: '5.7em'; left: '18.5em'; width: '1em'; height: '1em';">
  411.         <DIV style="font-family: 'ms sans serif'; font-size: '8pt';
  412.         position: absolute;top: '5.7em'; left: '20em'; width: '3em';
  413.         height: '2em';">
  414.         <LABEL style="font-family: 'ms sans serif'; font-size: '8pt'"
  415.         FOR=radDirectionDown helpid="0x3066"
  416.         ID=lblDirectionDown tabIndex=50> <U>D</U>own </LABEL>
  417.         </DIV>
  418.  
  419. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  420. background: buttonface;
  421. HEIGHT: '1em'; LEFT: '14.7em'; TOP: '4.1em'; WIDTH: '4.1em'">
  422. <LABEL id=lblDirection> Direction </LABEL>
  423. </DIV>
  424.  
  425. </BODY>
  426. </HTML>
  427.