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 / REPLACE.DLG < prev    next >
Text File  |  1997-04-04  |  18KB  |  542 lines

  1. <HTML STYLE="font: messagebox">
  2. <HEAD>
  3. <TITLE id=dialogTitle>
  4. Replace
  5. </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.  
  58.     //+---------------------------------------------------------------------
  59.     //
  60.     //  Synopsis:   Given a string, returns the number the string represents.
  61.     //              This is needed because current localization tools can
  62.     //              only find strings.
  63.     //
  64.     //  Arguments:  string  The string we're changing into a number.
  65.     //
  66.     //  Returns:    a number
  67.     //
  68.     //----------------------------------------------------------------------
  69.  
  70.     function number(string)
  71.     {
  72.         return parseFloat(string);
  73.     }   //  number
  74.  
  75. </SCRIPT>
  76.  
  77. <SCRIPT LANGUAGE=JavaScript>
  78.  
  79. //+--------------------------------------------------------------------------
  80. //
  81. //  This section contains variables that need to be LOCALIZED
  82. //
  83. //---------------------------------------------------------------------------
  84.  
  85. var L_Replace_DIALOG_Width_Text  = "34.1em";
  86. var L_Replace_DIALOG_Height_Text = "14em";
  87.  
  88. var L_FinishedDocument_Text   = "Finished searching the document.";
  89. var L_FinishedReplaceAll_Text = "Finished replace all";
  90.  
  91. var L_NoHelp_Text = "No help topic available.";
  92.  
  93. </SCRIPT>
  94.  
  95. <SCRIPT LANGUAGE="JavaScript">
  96.  
  97. //+--------------------------------------------------------------------------
  98. //
  99. //  This section contains code LOCAL to this particular dialog.
  100. //
  101. //---------------------------------------------------------------------------
  102.  
  103.     expandoOff();
  104.  
  105.     //  Set dialog dimensions
  106.     window.width   =   L_Replace_DIALOG_Width_Text;
  107.     window.height  =   L_Replace_DIALOG_Height_Text;
  108.  
  109.     //  Dim global variables
  110.     var rngFoundText;               //  The found text
  111.     var rngMaster;                  //  The selection when the dialog is called
  112.     var rngWorking;                 //  A range we can play with
  113.     var boolFoundText = false;      //  If the text has been found
  114.     var boolFinishedSearch = false; //  If we've reached the start or end of the document
  115.                                     //  or range
  116.     var lngInsertion;               //  Where the insertion point is
  117.     var dummy;                      //  dummy variable
  118.  
  119.  
  120.     //+---------------------------------------------------------------------
  121.     //
  122.     //  Synopsis:   Sets the focus to the find button. Also determines
  123.     //              whether something is selected in the document.
  124.     //
  125.     //  Arguments:  none
  126.     //
  127.     //  Returns:    nothing
  128.     //
  129.     //-----------------------------------------------------------------------
  130.  
  131.     function loadBdy()
  132.     {
  133.         docSearch = window.dialogArgs.document;
  134.         txtFindText.focus(); //  Set the focus to the first text box.
  135.  
  136.         rngMaster = docSearch.selection.createRange();
  137.  
  138.         //
  139.         //  If the selection is less than 16 characters, populate txtFind with the
  140.         //  selection
  141.         //
  142.         if ("Text" == docSearch.selection.type)
  143.         {
  144.             if ( 16 > rngMaster.text.length)
  145.             {
  146.                 txtFindText.value = rngMaster.text;
  147.  
  148.                 btnFind.disabled = false;
  149.                 btnReplace.disabled = false;
  150.                 btnReplaceAll.disabled = false;
  151.  
  152.                 lngInsertion = rngMaster.end;
  153.             }
  154.         }
  155.  
  156.         if (("Control" != docSearch.selection.type) && (rngMaster.end != lngInsertion))
  157.         {
  158.             lngInsertion = rngMaster.start;
  159.         }
  160.  
  161.         //
  162.         //  We've gotten the insertion point, the rngMaster becomes the entire body
  163.         //
  164.         rngMaster = docSearch.body.createTextRange();
  165.  
  166.         rngWorking = rngMaster.duplicate();
  167.     }   //  loadBdy
  168.  
  169.  
  170.     //+---------------------------------------------------------------------
  171.     //
  172.     //  Synopsis:   Checks the status of the appropriate checkboxes and
  173.     //              sets the flags for the rangeFromText method.
  174.     //
  175.     //  Arguments:  none
  176.     //
  177.     //  returns:    a number representing the flags for the rangeFromText
  178.     //              method. (See OM spec for more info.)
  179.     //
  180.     //----------------------------------------------------------------------
  181.  
  182.     function findFlags()
  183.     {
  184.         var htmlMatchWord = 2;
  185.         var htmlMatchCase = 4;
  186.  
  187.         return (htmlMatchWord * document.all.chkWholeWord.checked)
  188.             | (htmlMatchCase * document.all.chkMatchCase.checked)
  189.     }   //  findFlags
  190.  
  191.  
  192.     //+---------------------------------------------------------------------
  193.     //
  194.     //  Synopsis:   Three steps:
  195.     //              1. Make sure there's something to find.
  196.     //              2. Determine the direction and how far to search.
  197.     //              3. Find and select the text.
  198.     //
  199.     //  Arguments:  none
  200.     //
  201.     //  Returns:    nothing
  202.     //
  203.     //-----------------------------------------------------------------------
  204.  
  205.     function btnFindClick()
  206.     {
  207.         var intDirection;       //  What direction to search and how far to search
  208.  
  209.         if (btnFind.disabled == true)    //  No text to search for!
  210.         {
  211.             return;
  212.         }
  213.  
  214.         //
  215.         //  Set direction
  216.         //
  217.         if (radDirection[0].checked)    //  Search backwards
  218.         {
  219.             //
  220.             //  set range to search
  221.             //
  222.             if (!boolFoundText && !boolFinishedSearch)
  223.             {
  224.                 //
  225.                 //  Search from insertion point to beginning of document
  226.                 //
  227.                 rngWorking.end = lngInsertion;
  228.             }
  229.             else
  230.             {
  231.             //
  232.             //  Note: boolFoundText and boolFinishedSearch should never both be true.
  233.             //
  234.                 if (boolFoundText)
  235.                 {
  236.                     //
  237.                     //  Search from start of found text to start of document or range
  238.                     //
  239.                     rngWorking.end = rngFoundText.start;
  240.                     rngWorking.start = rngMaster.start;
  241.                 }
  242.                 if (boolFinishedSearch)
  243.                 {
  244.                     //
  245.                     //  Search from end of document or range to start of document or range
  246.                     //
  247.                     lngInsertion = rngMaster.end;
  248.                     boolFinishedSearch = false;
  249.                 }
  250.             }
  251.             intDirection = rngWorking.start - rngWorking.end    //  Should be negative or 0
  252.         }
  253.         else                            //  Search forwards
  254.         {
  255.             //
  256.             //  set range to search
  257.             //
  258.             if (!boolFoundText && !boolFinishedSearch)
  259.             {
  260.                 //
  261.                 //  Search from insertion point to end of document
  262.                 //
  263.                 rngWorking.start = lngInsertion;
  264.             }
  265.             else
  266.             {
  267.             //
  268.             //  Note: boolFoundText and boolFinishedSearch should never both be true.
  269.             //
  270.                 if (boolFoundText)
  271.                 {
  272.                     //
  273.                     //  Search from end of found text to end of document or range
  274.                     //
  275.                     rngWorking.start = rngFoundText.end;
  276.                     rngWorking.end = rngMaster.end;
  277.                 }
  278.                 if (boolFinishedSearch)
  279.                 {
  280.                     //
  281.                     //  Search from start of document or range to end of document or range
  282.                     //
  283.                     lngInsertion = rngMaster.start;
  284.                     boolFinishedSearch = false;
  285.                 }
  286.             }
  287.             intDirection = rngWorking.end - rngWorking.start    //  Should be positive or 0
  288.         }
  289.  
  290.         //
  291.         //  Here's where we do the dirty work (step 3) ...
  292.         //
  293.         rngFoundText = docSearch.rangeFromText(txtFindText.value, intDirection, findFlags(), rngWorking);
  294.  
  295.         if (rngFoundText == null)   //  Text was not found
  296.         {
  297.             alert(L_FinishedDocument_Text);
  298.             rngWorking = rngMaster.duplicate();
  299.             boolFoundText = false;
  300.             boolFinishedSearch = true;
  301.          }
  302.         else                        //  Text was found
  303.         {
  304.             rngFoundText.select();
  305.             rngFoundText.scrollIntoView(true);
  306.             boolFoundText = true;
  307.         }
  308.     }   //  btnFindClick
  309.  
  310.  
  311.     //+---------------------------------------------------------------------
  312.     //
  313.     //  Synopsis:   Go through the entire document or range and replace all
  314.     //              occurrences of txtFindText with txtReplaceText
  315.     //
  316.     //  Arguments:  none
  317.     //
  318.     //  Returns:    nothing
  319.     //
  320.     //-----------------------------------------------------------------------
  321.  
  322.     function btnReplaceAllClick()
  323.     {
  324.         //
  325.         // The 0 in the rangeFromText method below confines the search to the given range.
  326.         //
  327.         rngFindText = docSearch.rangeFromText(txtFindText.value, 0, findFlags(),
  328.             docSearch.body.createTextRange());
  329.  
  330.         while (rngFindText != null) //  Loop until text is no longer found.
  331.         {
  332.             rngFindText.text = txtReplaceText.value;
  333.             rngWorking.start = rngFindText.end;
  334.             rngFindText = docSearch.rangeFromText(txtFindText.value, 0, findFlags(),
  335.                 docSearch.body.createTextRange());
  336.         }
  337.  
  338.         alert(L_FinishedReplaceAll_Text);
  339.     }   //  btnReplaceAllClick
  340.  
  341.  
  342.     //+----------------------------------------------------------------------
  343.     //
  344.     //  Synopsis:   Replace current seelction with value from txtReplaceText
  345.     //
  346.     //  Arguments:  none
  347.     //
  348.     //  Returns:    nothing
  349.     //
  350.     //-----------------------------------------------------------------------
  351.  
  352.     function btnReplaceClick()
  353.     {
  354.         rngWorking = docSearch.selection.createRange();
  355.  
  356.         if (txtFindText.value == rngWorking.text)  //  selected text equals text in Find what:
  357.         {
  358.             rngWorking.text = txtReplaceText.value;
  359.         }
  360.  
  361.         btnFindClick();
  362.     }   //  btnReplaceClick
  363.  
  364. </SCRIPT>
  365.  
  366. <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onkeypress()">
  367.  
  368. //+---------------------------------------------------------------------
  369. //
  370. //  Synopsis:   Looks for the ENTER and ESC keypresses and runs the
  371. //              appropriate action.
  372. //
  373. //  Arguments:  none
  374. //
  375. //  Returns:    nothing
  376. //
  377. //-----------------------------------------------------------------------
  378.  
  379.     var htmlKeyReturn = 13;
  380.     var htmlKeyEscape = 27;
  381.  
  382.     if (event.keyCode == htmlKeyReturn)     //  Enter
  383.     {
  384.         btnFindClick();
  385.         btnFind.focus();
  386.     }
  387.  
  388.     if (event.keyCode == htmlKeyEscape)     //  Esc
  389.     {
  390.         btnCancelClick();
  391.     }
  392.  
  393. </SCRIPT>
  394.  
  395. <SCRIPT LANGUAGE=JavaScript>
  396.  
  397. function btnCancelClick()
  398. {
  399.     window.close();
  400. }
  401.  
  402. </SCRIPT>
  403.  
  404. <SCRIPT LANGUAGE=JavaScript FOR=txtFindText EVENT="onkeyup()">
  405.  
  406. //+----------------------------------------------------------------------------------
  407. //
  408. //  Synopsis:   Disables or enables the find button depending on whether
  409. //              there is text in txtFindText.
  410. //
  411. //  Arguments:  none
  412. //
  413. //  Returns:    nothing
  414. //
  415. //-----------------------------------------------------------------------------------
  416.  
  417.     if ("" == txtFindText.value)
  418.     {
  419.         btnFind.disabled = true;
  420.         btnReplace.disabled = true;
  421.         btnReplaceAll.disabled = true;
  422.     }
  423.     else
  424.     {
  425.         btnFind.disabled = false;
  426.         btnReplace.disabled = false;
  427.         btnReplaceAll.disabled = false;
  428.     }
  429.  
  430. </SCRIPT>
  431.  
  432. <SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onhelp()">
  433.  
  434. //+-------------------------------------------------------------------------
  435. //
  436. //  Synopsis:   Opens the help file with the appropriate helpid
  437. //
  438. //  Arguments:  none
  439. //
  440. //  Returns:    nothing
  441. //
  442. //--------------------------------------------------------------------------
  443.  
  444.     //  BUGBUG  Once we get help for the editing dialogs, this function 
  445.     //          will have to change.
  446.     alert(L_NoHelp_Text);
  447.  
  448. </SCRIPT>
  449.  
  450. </HEAD>
  451.  
  452. <BODY ID=bdy onLoad="loadBdy()" style="font: messagebox; background: 'buttonface';">
  453.  
  454. <BUTTON id=btnFind onclick="btnFindClick()" ACCESSKEY=f DISABLED=1 tabIndex=10
  455. style="font: messagebox; position: absolute;LEFT: '25.7em'; TOP: '1em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
  456. <U>F</U>ind Next
  457. </BUTTON>
  458.  
  459. <BUTTON id=btnReplace onclick="btnReplaceClick()" ACCESSKEY=r DISABLED=1 tabIndex=15
  460. style="font: messagebox; position: absolute;LEFT: '25.7em'; TOP: '3.5em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
  461. <U>R</U>eplace
  462. </BUTTON>
  463.  
  464. <BUTTON id=btnReplaceAll onclick="btnReplaceAllClick()" ACCESSKEY=a DISABLED=1 tabIndex=20
  465. style="font: messagebox; position: absolute;LEFT: '25.7em'; TOP: '6em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
  466. Replace <U>A</U>ll
  467. </BUTTON>
  468.  
  469. <BUTTON id=btnCancel onclick="btnCancelClick()" tabIndex=25
  470. style="font: messagebox; position: absolute;LEFT: '25.7em'; TOP: '8.5em'; WIDTH: '6.8em'; HEIGHT: '2.1em'">
  471. Cancel
  472. </BUTTON>
  473.  
  474. <INPUT type=text id=txtFindText ACCESSKEY=n tabIndex=30
  475. style="font: messagebox; position: absolute;LEFT: '7.2em'; TOP: '1em'; WIDTH: '17.5em'; HEIGHT: '2.1em'">
  476.  
  477. <INPUT type=text id=txtReplaceText ACCESSKEY=p tabIndex=35
  478. style="font: messagebox; position: absolute;LEFT: '7.2em'; TOP: '3.5em'; WIDTH: '17.5em'; HEIGHT: '2.1em'">
  479.  
  480. <DIV align=absMiddle style="font: messagebox; position: absolute; LEFT: '1em'; TOP: '1.3em'; WIDTH: '8em'; HEIGHT: '1em'">
  481. <LABEL FOR=txtFindText ID=lblFindText tabIndex="-1">
  482. Fi<U>n</U>d what:
  483. </LABEL>
  484. </DIV>
  485.  
  486. <DIV align=absMiddle style="font: messagebox; position: absolute; LEFT: '1em'; TOP: '3.8em'; WIDTH: '8em'; HEIGHT: '1em'">
  487. <LABEL FOR=txtReplaceText ID=lblReplaceText tabIndex="-1">
  488. Re<U>p</U>lace with:
  489. </LABEL>
  490. </DIV>
  491.  
  492. <INPUT id=chkWholeWord type=checkbox ACCESSKEY=w tabIndex=40
  493. style="font: messagebox; position: absolute;LEFT: '1em'; TOP: '7.6em'; WIDTH: '1em'; HEIGHT: '1em'">
  494.  
  495. <INPUT id=chkMatchCase type=checkbox ACCESSKEY=c tabIndex=45
  496. style="font: messagebox; position: absolute;LEFT: '1em'; TOP: '9.4em'; WIDTH: '1em'; HEIGHT: '1em'">
  497.  
  498. <DIV style="font: messagebox; position: absolute; LEFT: '2.6em'; TOP: '7.6em'; WIDTH: '11em'; HEIGHT: '1.3em'">
  499. <LABEL FOR=chkWholeWord id=lblWholeWord tabIndex="-1">
  500. Match <U>w</U>hole word only
  501. </LABEL>
  502. </DIV>
  503.  
  504. <DIV style="font: messagebox; position: absolute; LEFT: '2.6em'; TOP: '9.4em'; WIDTH: '10em'; HEIGHT: '1em'">
  505. <LABEL FOR=chkMatchCase id=lblMatchCase tabIndex="-1">
  506. Match <U>C</U>ase
  507. </LABEL>
  508. </DIV>
  509.  
  510. <TABLE cellspacing cellPadding=7 borderColorDark=buttonhighlight borderColorLight=buttonshadow border=1 noshade="yes"
  511. style="font: messagebox; position: absolute; LEFT: '14.5em'; TOP: '7.5em'; WIDTH: '9.5em'; HEIGHT: '3em'">
  512.  
  513.  
  514.     <TR>
  515.         <TD style="font: messagebox; position: relative; width: '6.4em'; height: '2em';">
  516.         <DIV style="color: buttonface">a</DIV>
  517.         </TD>
  518.     </TR>
  519. </TABLE>
  520.  
  521.         <INPUT id=radDirectionUp type=radio name=radDirection ACCESSKEY=u tabIndex=50
  522.         style="position: absolute;font: messagebox;top: '8.6em'; left: '15.3em'; width: '1em'; height: '1em';">
  523.  
  524.         <DIV style="position: absolute;font: messagebox;top: '8.6em'; left: '17em'; width: '2em'; height: '2em';">
  525.         <LABEL FOR=radDirectionUp id=lblDirectionUp tabIndex="-1" STYLE="font: messagebox"> <U>U</U>p </LABEL>
  526.         </DIV>
  527.  
  528.         <INPUT id=radDirectionDown type=radio CHECKED name=radDirection ACCESSKEY=d tabIndex=55
  529.         style="position: absolute;font: messagebox;top: '8.6em'; left: '19.25em'; width: '1em'; height: '1em';">
  530.  
  531.         <DIV style="position: absolute;font: messagebox;top: '8.6em'; left: '20.75em'; width: '3em'; height: '1em';">
  532.         <LABEL FOR=radDirectionDown id=lblDirectionDown tabIndex="-1" STYLE="font: messagebox"> <U>D</U>own </LABEL>
  533.         </DIV>
  534.  
  535. <DIV style="font: messagebox; position: absolute;background: buttonface; HEIGHT: '1em'; LEFT: '15em'; TOP: '7em'; WIDTH: '4.1em'">
  536. <LABEL id=lblDirection tabIndex="-1" STYLE="font: messagebox;">
  537.  Direction </LABEL>
  538.  
  539. </DIV>
  540. </BODY>
  541. </HTML>
  542.