home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 January / Gamestar_80_2006-01_dvd.iso / Utility / 5-11_xp-2k_dd_ccc_wdm_enu_27345.exe / Data1.cab / _043D5BC0D9FB45ABA815A730E4951FED < prev    next >
Text File  |  2003-09-15  |  41KB  |  1,407 lines

  1. // Copyright (c) 2000-2003 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHSearch_Object()
  5. {
  6.   this.mbPanelInitialized    = false;
  7.   this.mPanelAnchor          = null;
  8.   this.mPanelTabTitle        = WWHFrame.WWHJavaScript.mMessages.mTabsSearchLabel;
  9.   this.mPanelTabIndex        = -1;
  10.   this.mPanelFilename        = "panelfss.htm";
  11.   this.mInitIndex            = 0;
  12.   this.mBookSearchInfoList   = new Array();
  13.   this.mbSearching           = false;
  14.   this.mSearchScopeInfo      = null;
  15.   this.mSavedSearchWords     = "";
  16.   this.mSavedSearchScope     = 0;
  17.   this.mSearchWordList       = new Array();
  18.   this.mSearchWordRegExpList = new Array();
  19.   this.mBookIndex            = 0;
  20.   this.mBookMatchesList      = new Array();
  21.   this.mCombinedResults      = new WWHSearchResults_Object();
  22.  
  23.   this.fInitHeadHTML           = WWHSearch_InitHeadHTML;
  24.   this.fInitBodyHTML           = WWHSearch_InitBodyHTML;
  25.   this.fInitLoadBookSearchInfo = WWHSearch_InitLoadBookSearchInfo;
  26.   this.fNavigationHeadHTML     = WWHSearch_NavigationHeadHTML;
  27.   this.fNavigationBodyHTML     = WWHSearch_NavigationBodyHTML;
  28.   this.fHeadHTML               = WWHSearch_HeadHTML;
  29.   this.fStartHTMLSegments      = WWHSearch_StartHTMLSegments;
  30.   this.fAdvanceHTMLSegment     = WWHSearch_AdvanceHTMLSegment;
  31.   this.fGetHTMLSegment         = WWHSearch_GetHTMLSegment;
  32.   this.fEndHTMLSegments        = WWHSearch_EndHTMLSegments;
  33.   this.fPanelNavigationLoaded  = WWHSearch_PanelNavigationLoaded;
  34.   this.fPanelViewLoaded        = WWHSearch_PanelViewLoaded;
  35.   this.fHoverTextTranslate     = WWHSearch_HoverTextTranslate;
  36.   this.fHoverTextFormat        = WWHSearch_HoverTextFormat;
  37.   this.fDisplaySearchForm      = WWHSearch_DisplaySearchForm;
  38.   this.fSubmit                 = WWHSearch_Submit;
  39.   this.fSetSearchWords         = WWHSearch_SetSearchWords;
  40.   this.fCheckForMatch          = WWHSearch_CheckForMatch;
  41.   this.fSearchComplete         = WWHSearch_SearchComplete;
  42.   this.fCombineResults         = WWHSearch_CombineResults;
  43.   this.fShowEntry              = WWHSearch_ShowEntry;
  44. }
  45.  
  46. function  WWHSearch_InitHeadHTML()
  47. {
  48.   var  InitHeadHTML = "";
  49.  
  50.  
  51.   // Create search scope info
  52.   //
  53.   this.mSearchScopeInfo = new WWHSearchScope_Object();
  54.  
  55.   return InitHeadHTML;
  56. }
  57.  
  58. function  WWHSearch_InitBodyHTML()
  59. {
  60.   var  HTML = new WWHStringBuffer_Object();
  61.   var  BookList;
  62.   var  MaxIndex;
  63.   var  Index;
  64.  
  65.  
  66.   // Display initializing message
  67.   //
  68.   HTML.fAppend("<h2>" + WWHFrame.WWHJavaScript.mMessages.mInitializingMessage + "</h2>\n");
  69.  
  70.   // Load search info
  71.   //
  72.   this.mInitIndex = 0;
  73.   BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  74.   for (MaxIndex = BookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  75.   {
  76.     // Reference search info
  77.     //
  78.     HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + WWHFrame.WWHBrowser.fRestoreEscapedSpaces(BookList[Index].mDirectory) + "wwhdata/js/search.js\"></script>\n");
  79.  
  80.     // Load search info for current book
  81.     //
  82.     HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search1s.js\"></script>\n");
  83.   }
  84.  
  85.   return HTML.fGetBuffer();
  86. }
  87.  
  88. function  WWHSearch_InitLoadBookSearchInfo(ParamSearchFileCount,
  89.                                            ParamMinimumWordLength,
  90.                                            ParamSearchSkipWordsFunc)
  91. {
  92.   // Load book search info
  93.   //
  94.   this.mBookSearchInfoList[this.mInitIndex] = new WWHBookSearchInfo_Object(ParamSearchFileCount, ParamMinimumWordLength);
  95.   ParamSearchSkipWordsFunc(this.mBookSearchInfoList[this.mInitIndex]);
  96.  
  97.   // Create match objects for each book
  98.   //
  99.   this.mBookMatchesList[this.mBookMatchesList.length] = new WWHSearchBookMatches_Object();
  100.  
  101.   // Increment init book index
  102.   //
  103.   this.mInitIndex++;
  104.  
  105.   // Mark initialized if done
  106.   //
  107.   if (this.mInitIndex == WWHFrame.WWHHelp.mBooks.mBookList.length)
  108.   {
  109.     this.mbPanelInitialized = true;
  110.   }
  111. }
  112.  
  113. function  WWHSearch_NavigationHeadHTML()
  114. {
  115.   return "";
  116. }
  117.  
  118. function  WWHSearch_NavigationBodyHTML()
  119. {
  120.   return this.fDisplaySearchForm();
  121. }
  122.  
  123. function  WWHSearch_HeadHTML()
  124. {
  125.   var  HTML = new WWHStringBuffer_Object();
  126.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  127.  
  128.  
  129.   // Generate style section
  130.   //
  131.   HTML.fAppend("<style type=\"text/css\">\n");
  132.   HTML.fAppend(" <!--\n");
  133.   HTML.fAppend("  a:active\n");
  134.   HTML.fAppend("  {\n");
  135.   HTML.fAppend("    text-decoration: none;\n");
  136.   HTML.fAppend("    background-color: " + Settings.mHighlightColor + ";\n");
  137.   HTML.fAppend("  }\n");
  138.   HTML.fAppend("  a:hover\n");
  139.   HTML.fAppend("  {\n");
  140.   HTML.fAppend("    text-decoration: underline;\n");
  141.   HTML.fAppend("    color: " + Settings.mEnabledColor + ";\n");
  142.   HTML.fAppend("  }\n");
  143.   HTML.fAppend("  a\n");
  144.   HTML.fAppend("  {\n");
  145.   HTML.fAppend("    text-decoration: none;\n");
  146.   HTML.fAppend("    color: " + Settings.mEnabledColor + ";\n");
  147.   HTML.fAppend("  }\n");
  148.   HTML.fAppend("  p\n");
  149.   HTML.fAppend("  {\n");
  150.   HTML.fAppend("    margin-top: 1pt;\n");
  151.   HTML.fAppend("    margin-bottom: 1pt;\n");
  152.   HTML.fAppend("    " + Settings.mFontStyle + ";\n");
  153.   HTML.fAppend("  }\n");
  154.   HTML.fAppend("  p.BookTitle\n");
  155.   HTML.fAppend("  {\n");
  156.   HTML.fAppend("    margin-top: 1pt;\n");
  157.   HTML.fAppend("    margin-bottom: 1pt;\n");
  158.   HTML.fAppend("    font-weight: bold;\n");
  159.   HTML.fAppend("    " + Settings.mFontStyle + ";\n");
  160.   HTML.fAppend("  }\n");
  161.   HTML.fAppend("  ol\n");
  162.   HTML.fAppend("  {\n");
  163.   HTML.fAppend("    margin-top: 1pt;\n");
  164.   HTML.fAppend("    margin-bottom: 1pt;\n");
  165.   if (Settings.mbShowRank)
  166.   {
  167.     HTML.fAppend("    " + Settings.mFontStyle + ";\n");
  168.   }
  169.   else
  170.   {
  171.     HTML.fAppend("    list-style: none;\n");
  172.   }
  173.   HTML.fAppend("  }\n");
  174.   HTML.fAppend("  li\n");
  175.   HTML.fAppend("  {\n");
  176.   HTML.fAppend("    margin-top: 2pt;\n");
  177.   HTML.fAppend("    margin-bottom: 0pt;\n");
  178.   HTML.fAppend("    " + Settings.mFontStyle + ";\n");
  179.   HTML.fAppend("  }\n");
  180.   HTML.fAppend(" -->\n");
  181.   HTML.fAppend("</style>\n");
  182.  
  183.   return HTML.fGetBuffer();
  184. }
  185.  
  186. function  WWHSearch_StartHTMLSegments()
  187. {
  188.   var  HTML = new WWHStringBuffer_Object();
  189.   var  MaxBookIndex;
  190.   var  BookIndex;
  191.   var  BookList;
  192.   var  MaxIndex;
  193.   var  Index;
  194.   var  BookDirectory;
  195.   var  bDisplayBookTitles;
  196.  
  197.  
  198.   if (this.mbPanelInitialized)
  199.   {
  200.     // Perform search if required
  201.     //
  202.     if (this.mbSearching)
  203.     {
  204.       // Display searching message
  205.       //
  206.       HTML.fAppend("<h2>" + WWHFrame.WWHJavaScript.mMessages.mSearchSearchingMessage + "</h2>\n");
  207.  
  208.       // Handle single book search
  209.       //
  210.       BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  211.       if (this.mSavedSearchScope > 0)
  212.       {
  213.         BookIndex    = this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mStartBookIndex;
  214.         MaxBookIndex = this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mEndBookIndex + 1;
  215.       }
  216.       else
  217.       {
  218.         BookIndex    = 0;
  219.         MaxBookIndex = BookList.length;
  220.       }
  221.  
  222.       // Generate search actions
  223.       //
  224.       this.mBookIndex = BookIndex;
  225.       for ( ; BookIndex < MaxBookIndex ; BookIndex++)
  226.       {
  227.         BookDirectory = BookList[BookIndex].mDirectory;
  228.  
  229.         for (MaxIndex = this.mBookSearchInfoList[BookIndex].mSearchFileCount, Index = 0 ; Index < MaxIndex ; Index++)
  230.         {
  231.           HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + WWHFrame.WWHBrowser.fRestoreEscapedSpaces(BookDirectory) + "wwhdata/js/search/search" + Index + ".js\"></script>\n");
  232.           HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search2s.js\"></script>\n");
  233.         }
  234.  
  235.         HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search3s.js\"></script>\n");
  236.       }
  237.  
  238.       HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/search4s.js\"></script>\n");
  239.     }
  240.     else
  241.     {
  242.       // Define accessor functions to reduce file size
  243.       //
  244.       HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\">\n");
  245.       HTML.fAppend(" <!--\n");
  246.       HTML.fAppend("  function  fC(ParamEntryID)\n");
  247.       HTML.fAppend("  {\n");
  248.       HTML.fAppend("    WWHFrame.WWHSearch.fShowEntry(ParamEntryID);\n");
  249.       HTML.fAppend("  }\n");
  250.       HTML.fAppend("\n");
  251.       HTML.fAppend("  function  fS(ParamEntryID,\n");
  252.       HTML.fAppend("               ParamEvent)\n");
  253.       HTML.fAppend("  {\n");
  254.       HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fShow(ParamEntryID, ParamEvent);\n");
  255.       HTML.fAppend("  }\n");
  256.       HTML.fAppend("\n");
  257.       HTML.fAppend("  function  fH()\n");
  258.       HTML.fAppend("  {\n");
  259.       HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fHide();\n");
  260.       HTML.fAppend("  }\n");
  261.       HTML.fAppend(" // -->\n");
  262.       HTML.fAppend("</script>\n");
  263.  
  264.       // Display search message and/or prepare results for display
  265.       //
  266.       if (this.mSavedSearchWords.length == 0)
  267.       {
  268.         HTML.fAppend("<h3>" + WWHFrame.WWHJavaScript.mMessages.mSearchDefaultMessage + "</h3>\n");
  269.       }
  270.       else if ((typeof(this.mCombinedResults.mEntries) != "undefined") &&
  271.                (this.mCombinedResults.mEntries.length > 0))
  272.       {
  273.         // Determine if book name should be displayed about results
  274.         //
  275.         if ((WWHFrame.WWHHelp.mBooks.mBookList.length == 1) ||
  276.             ((this.mSavedSearchScope > 0) &&
  277.              (this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mStartBookIndex == this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mEndBookIndex)))
  278.         {
  279.           // Single book scope selected, do not display book titles
  280.           //
  281.           bDisplayBookTitles = false;
  282.         }
  283.         else
  284.         {
  285.           // More than one book in search scope, display book titles
  286.           //
  287.           bDisplayBookTitles = true;
  288.         }
  289.  
  290.         this.mCombinedResults.fDisplayReset(bDisplayBookTitles);
  291.       }
  292.       else
  293.       {
  294.         HTML.fAppend("<h3>" + WWHFrame.WWHJavaScript.mMessages.mSearchNothingFoundMessage + "</h3>\n");
  295.       }
  296.     }
  297.   }
  298.  
  299.   return HTML.fGetBuffer();
  300. }
  301.  
  302. function  WWHSearch_AdvanceHTMLSegment()
  303. {
  304.   var  bSegmentCreated = false;
  305.  
  306.  
  307.   if (this.mbPanelInitialized)
  308.   {
  309.     if ( ! this.mbSearching)
  310.     {
  311.       bSegmentCreated = this.mCombinedResults.fDisplayAdvance();
  312.     }
  313.   }
  314.  
  315.   return bSegmentCreated;
  316. }
  317.  
  318. function  WWHSearch_GetHTMLSegment()
  319. {
  320.   return this.mCombinedResults.mHTMLSegment.fGetBuffer();
  321. }
  322.  
  323. function  WWHSearch_EndHTMLSegments()
  324. {
  325.   return "";
  326. }
  327.  
  328. function  WWHSearch_PanelNavigationLoaded()
  329. {
  330.   // Set focus
  331.   //
  332.   WWHFrame.WWHHelp.fFocus("WWHPanelNavigationFrame");
  333. }
  334.  
  335. function  WWHSearch_PanelViewLoaded()
  336. {
  337.   // Display search results if necessary
  338.   //
  339.   if (this.mbSearching)
  340.   {
  341.     this.mbSearching = false;
  342.  
  343.     WWHFrame.WWHJavaScript.mPanels.fReloadView();
  344.   }
  345. }
  346.  
  347. function  WWHSearch_HoverTextTranslate(ParamEntryID)
  348. {
  349.   var  HTML     = "";
  350.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  351.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  352.   var  Messages = WWHFrame.WWHJavaScript.mMessages;
  353.   var  Entry;
  354.   var  Rank = "";
  355.   var  Title;
  356.   var  Book = "";
  357.   var  Format;
  358.  
  359.  
  360.   // Retrieve specified entry
  361.   //
  362.   Entry = this.mCombinedResults.mEntries[ParamEntryID];
  363.  
  364.   // Get Rank
  365.   //
  366.   if (Settings.mbShowRank)
  367.   {
  368.     Rank = Math.floor((Entry.mScore / this.mCombinedResults.mMaxScore) * 100) + "%";
  369.   }
  370.  
  371.   // Get Title
  372.   //
  373.   Title = Entry.mTitle;
  374.  
  375.   // Get Book
  376.   //
  377.   if ((BookList.length > 1) &&                 // More than one book exists
  378.       (this.mCombinedResults.mSortedBy == 1))  // By Score
  379.   {
  380.     Book = BookList[Entry.mBookIndex].mTitle;
  381.   }
  382.  
  383.   // Format for display
  384.   //
  385.   if ((Rank.length == 0) &&
  386.       (Book.length == 0))
  387.   {
  388.     // Simple format, just the title
  389.     //
  390.     HTML = Title;
  391.   }
  392.   else
  393.   {
  394.     Format = " align=\"left\" valign=\"top\"><span style=\"" + WWHFrame.WWHJavaScript.mSettings.mHoverText.mFontStyle + "\">";
  395.  
  396.     // Complex format, requires a table
  397.     //
  398.     HTML += "<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
  399.     if (Rank.length > 0)
  400.     {
  401.       HTML += "<tr>";
  402.       HTML += "<th" + Format + Messages.mSearchRankLabel + "</span></th>";
  403.       HTML += "<td" + Format + Rank + "</span></td>";
  404.       HTML += "</tr>";
  405.     }
  406.     HTML += "<tr>";
  407.     HTML += "<th" + Format + Messages.mSearchTitleLabel + "</span></th>";
  408.     HTML += "<td" + Format + Title + "</span></td>";
  409.     HTML += "</tr>";
  410.     if (Book.length > 0)
  411.     {
  412.       HTML += "<tr>";
  413.       HTML += "<th" + Format + Messages.mSearchBookLabel + "</span></th>";
  414.       HTML += "<td" + Format + Book + "</span></td>";
  415.       HTML += "</tr>";
  416.     }
  417.     HTML += "</table>";
  418.  
  419.     // IE 5.0 on the Macintosh drops the last table for some reason
  420.     //
  421.     if (WWHFrame.WWHBrowser.mbMacIE50)
  422.     {
  423.       HTML += "<table><tr><td></td></tr></table>";
  424.     }
  425.   }
  426.  
  427.   return HTML;
  428. }
  429.  
  430. function  WWHSearch_HoverTextFormat(ParamWidth,
  431.                                     ParamTextID,
  432.                                     ParamText)
  433. {
  434.   var  FormattedText   = "";
  435.   var  ForegroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mForegroundColor;
  436.   var  BackgroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBackgroundColor;
  437.   var  BorderColor     = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBorderColor;
  438.   var  ImageDir        = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images";
  439.   var  ReqSpacer1w2h   = "<img src=\"" + ImageDir + "/spc1w2h.gif\" width=1 height=2>";
  440.   var  ReqSpacer2w1h   = "<img src=\"" + ImageDir + "/spc2w1h.gif\" width=2 height=1>";
  441.   var  ReqSpacer1w7h   = "<img src=\"" + ImageDir + "/spc1w7h.gif\" width=1 height=7>";
  442.   var  ReqSpacer5w1h   = "<img src=\"" + ImageDir + "/spc5w1h.gif\" width=5 height=1>";
  443.   var  Spacer1w2h      = ReqSpacer1w2h;
  444.   var  Spacer2w1h      = ReqSpacer2w1h;
  445.   var  Spacer1w7h      = ReqSpacer1w7h;
  446.   var  Spacer5w1h      = ReqSpacer5w1h;
  447.  
  448.  
  449.   // Netscape 6.x (Mozilla) renders table cells with graphics
  450.   // incorrectly inside of <div> tags that are rewritten on the fly
  451.   //
  452.   if (WWHFrame.WWHBrowser.mBrowser == 4)  // Shorthand for Netscape 6.x (Mozilla)
  453.   {
  454.     Spacer1w2h = "";
  455.     Spacer2w1h = "";
  456.     Spacer1w7h = "";
  457.     Spacer5w1h = "";
  458.   }
  459.  
  460.   FormattedText += "<table width=\"" + ParamWidth + "\" border=0 cellspacing=0 cellpadding=0 bgcolor=\"" + BackgroundColor + "\">";
  461.   FormattedText += " <tr>";
  462.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  463.   FormattedText += " </tr>";
  464.  
  465.   FormattedText += " <tr>";
  466.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  467.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  468.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  469.   FormattedText += " </tr>";
  470.  
  471.   FormattedText += " <tr>";
  472.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  473.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  474.   FormattedText += "  <td width=\"100%\" id=\"" + ParamTextID + "\" style=\"color: " + ForegroundColor + " ; " + WWHFrame.WWHJavaScript.mSettings.mHoverText.mFontStyle + "\">" + ParamText + "</td>";
  475.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  476.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  477.   FormattedText += " </tr>";
  478.  
  479.   FormattedText += " <tr>";
  480.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  481.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  482.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  483.   FormattedText += " </tr>";
  484.  
  485.   FormattedText += " <tr>";
  486.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  487.   FormattedText += " </tr>";
  488.   FormattedText += "</table>";
  489.  
  490.   return FormattedText;
  491. }
  492.  
  493. function  WWHSearch_DisplaySearchForm()
  494. {
  495.   var  HTML = "";
  496.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  497.   var  SelectedIndex;
  498.   var  MaxIndex;
  499.   var  Index;
  500.   var  SearchScopeEntry;
  501.   var  MaxLevel;
  502.   var  Level;
  503.  
  504.  
  505.   HTML += "<form name=\"WWHSearchForm\" onSubmit=\"WWHFrame.WWHSearch.fSubmit();\">\n";
  506.   HTML += "<nobr>\n";
  507.   HTML += "<input type=\"text\" name=\"WWHSearchWordsText\" size=\"20\" value=\"" + this.mSavedSearchWords + "\" onKeyDown=\"WWHFrame.WWHHelp.fIgnoreNextKeyPress((document.all||document.getElementById||document.layers)?event:null);\">\n";
  508.   HTML += "<input type=\"submit\" value=\"" + WWHFrame.WWHJavaScript.mMessages.mSearchButtonLabel + "\">\n";
  509.   HTML += "</nobr>\n";
  510.  
  511.   if (BookList.length > 1)
  512.   {
  513.     SelectedIndex = this.mSavedSearchScope - 1;
  514.  
  515.     HTML += "<br>\n";
  516.     HTML += "<select name=\"WWHSearchScope\">\n";
  517.     HTML += "<option>" + WWHFrame.WWHJavaScript.mMessages.mSearchScopeAllLabel + "</option>\n";
  518.     for (MaxIndex = this.mSearchScopeInfo.mEntries.length, Index = 0 ; Index < MaxIndex ; Index++)
  519.     {
  520.       // Access current search scope entry
  521.       //
  522.       SearchScopeEntry = this.mSearchScopeInfo.mEntries[Index];
  523.  
  524.       // Restore selection
  525.       //
  526.       if (Index == SelectedIndex)
  527.       {
  528.         HTML += "<option selected>";
  529.       }
  530.       else
  531.       {
  532.         HTML += "<option>";
  533.       }
  534.  
  535.       // Indent to show different levels
  536.       //
  537.       for (MaxLevel = SearchScopeEntry.mLevel, Level = 0 ; Level < MaxLevel ; Level++)
  538.       {
  539.         HTML += "- ";
  540.       }
  541.  
  542.       // Close out entry
  543.       //
  544.       HTML += SearchScopeEntry.mTitle + "</option>\n";
  545.     }
  546.     HTML += "</select>\n";
  547.   }
  548.  
  549.   HTML += "</form>\n";
  550.  
  551.   return HTML;
  552. }
  553.  
  554. function  WWHSearch_Submit()
  555. {
  556.   var  VarPanelNavigationFrame;
  557.   var  SearchForm;
  558.   var  NewSearchWords;
  559.   var  NewSearchScope;
  560.   var  MaxIndex;
  561.   var  Index;
  562.  
  563.  
  564.   if (WWHFrame.WWHHandler.fIsReady())
  565.   {
  566.     VarPanelNavigationFrame = eval(WWHFrame.WWHHelp.fGetFrameReference("WWHPanelNavigationFrame"));
  567.     SearchForm = VarPanelNavigationFrame.document.forms["WWHSearchForm"];
  568.  
  569.     // Update search words
  570.     //
  571.     NewSearchWords = SearchForm.elements["WWHSearchWordsText"].value;
  572.     if (NewSearchWords != this.mSavedSearchWords)
  573.     {
  574.       this.mSavedSearchWords = NewSearchWords;
  575.  
  576.       this.mbSearching = true;
  577.     }
  578.  
  579.     // Update search scope
  580.     //
  581.     if (WWHFrame.WWHHelp.mBooks.mBookList.length > 1)
  582.     {
  583.       NewSearchScope = SearchForm.elements["WWHSearchScope"].selectedIndex;
  584.       if (NewSearchScope != this.mSavedSearchScope)
  585.       {
  586.         this.mSavedSearchScope = NewSearchScope;
  587.  
  588.         this.mbSearching = true;
  589.       }
  590.     }
  591.  
  592.     // Perform search if something changed
  593.     //
  594.     if (this.mbSearching)
  595.     {
  596.       if (this.mSavedSearchWords.length > 0)
  597.       {
  598.         // Clear previous results
  599.         //
  600.         for (MaxIndex = this.mBookMatchesList.length, Index = 0 ; Index < MaxIndex ; Index++)
  601.         {
  602.           this.mBookMatchesList[Index].fClear();
  603.         }
  604.         this.mCombinedResults.fClear();
  605.  
  606.         // Perform search
  607.         //
  608.         this.fSetSearchWords(this.mSavedSearchWords);
  609.         WWHFrame.WWHJavaScript.mPanels.fClearScrollPosition();
  610.  
  611.         // Submit will cause navigation area to reload which will trigger the view pane
  612.         // to reload and perform the search.
  613.         //
  614.       }
  615.     }
  616.   }
  617.  
  618.   return this.mbSearching;
  619. }
  620.  
  621. function  WWHSearch_SetSearchWords(ParamSearchWordsString)
  622. {
  623.   // Workaround for stupid Netscape 4.x bug
  624.   //
  625.   var  StringWithSpace = "x x";
  626.   var  SearchWordList;
  627.   var  MaxIndex;
  628.   var  Index;
  629.   var  SearchWord;
  630.   var  SearchRegExpPattern;
  631.  
  632.  
  633.   // Clear search words
  634.   //
  635.   this.mSearchWordList.length = 0;
  636.   this.mSearchWordRegExpList.length = 0;
  637.  
  638.   // Add search words to hash
  639.   //
  640.   SearchWordList = ParamSearchWordsString.split(StringWithSpace.substring(1, 2));
  641.   for (MaxIndex = SearchWordList.length, Index = 0 ; Index < MaxIndex ; Index++)
  642.   {
  643.     // Skip 0 length words
  644.     //
  645.     if (SearchWordList[Index].length > 0)
  646.     {
  647.       // Add to search words hash
  648.       //
  649.       SearchWord = SearchWordList[Index].toLowerCase();
  650.       SearchRegExpPattern = WWHStringUtilities_WordToRegExpPattern(SearchWord);
  651.  
  652.       this.mSearchWordList[this.mSearchWordList.length] = SearchWord;
  653.       this.mSearchWordRegExpList[this.mSearchWordRegExpList.length] = new RegExp(SearchRegExpPattern, "i");
  654.     }
  655.   }
  656. }
  657.  
  658. function  WWHSearch_CheckForMatch(ParamSearchFunc)
  659. {
  660.   var  Count;
  661.   var  MaxIndex;
  662.   var  Index;
  663.   var  BookSearchInfoEntry;
  664.   var  BookMatchesListEntry;
  665.   var  SearchPattern;
  666.  
  667.  
  668.   Count = 0;
  669.   for (MaxIndex = this.mSearchWordList.length, Index = 0 ; Index < MaxIndex ; Index++)
  670.   {
  671.     BookSearchInfoEntry = this.mBookSearchInfoList[this.mBookIndex]
  672.  
  673.     if (this.mBookSearchInfoList[this.mBookIndex].fValidSearchWord(this.mSearchWordList[Index]))
  674.     {
  675.       BookMatchesListEntry = this.mBookMatchesList[this.mBookIndex];
  676.  
  677.       BookMatchesListEntry.fSetMatchedWordIndex(Count);
  678.  
  679.       SearchPattern = this.mSearchWordRegExpList[Index];
  680.       SearchPattern.t = SearchPattern.test;
  681.  
  682.       ParamSearchFunc(SearchPattern, BookMatchesListEntry);
  683.  
  684.       Count++;
  685.     }
  686.   }
  687. }
  688.  
  689. function  WWHSearch_SearchComplete()
  690. {
  691.   // Combine results for display
  692.   //
  693.   this.fCombineResults();
  694.  
  695.   // Sort results based on single or multi-book display
  696.   //
  697.   if ((WWHFrame.WWHJavaScript.mSettings.mSearch.mbResultsByBook) ||
  698.       ((WWHFrame.WWHHelp.mBooks.mBookList.length == 1) ||
  699.        ((this.mSavedSearchScope > 0) &&
  700.         (this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mStartBookIndex == this.mSearchScopeInfo.mEntries[this.mSavedSearchScope - 1].mEndBookIndex))))
  701.   {
  702.     this.mCombinedResults.fSortByBookIndex();
  703.   }
  704.   else
  705.   {
  706.     this.mCombinedResults.fSortByScore();
  707.   }
  708. }
  709.  
  710. function  WWHSearch_CombineResults()
  711. {
  712.   var  MaxBookIndex;
  713.   var  BookIndex;
  714.   var  BookMatches;
  715.   var  BookListEntry;
  716.   var  FileID;
  717.   var  FileIndex;
  718.  
  719.  
  720.   this.mCombinedResults.fClear();
  721.   for (MaxBookIndex = this.mBookMatchesList.length, BookIndex = 0 ; BookIndex < MaxBookIndex ; BookIndex++)
  722.   {
  723.     BookMatches = this.mBookMatchesList[BookIndex];
  724.     BookListEntry = WWHFrame.WWHHelp.mBooks.mBookList[BookIndex];
  725.  
  726.     // Add results
  727.     //
  728.     BookMatches.fJoinFileScores();
  729.     for (FileID in BookMatches.mFileScores)
  730.     {
  731.       FileIndex = parseInt(FileID.substring(1, FileID.length));
  732.  
  733.       this.mCombinedResults.fAddEntry(BookIndex, FileIndex, BookMatches.mFileScores[FileID], BookListEntry.mFiles.fFileIndexToTitle(FileIndex));
  734.     }
  735.   }
  736. }
  737.  
  738. function  WWHSearch_ShowEntry(ParamIndex)
  739. {
  740.   this.mCombinedResults.fShowEntry(ParamIndex);
  741. }
  742.  
  743. function  WWHSearchScope_Entry_Object(ParamLevel,
  744.                                       ParamTitle,
  745.                                       ParamBookIndex)
  746. {
  747.   this.mLevel          = ParamLevel;
  748.   this.mTitle          = ParamTitle;
  749.   this.mStartBookIndex = ParamBookIndex;
  750.   this.mEndBookIndex   = ParamBookIndex;
  751. }
  752.  
  753. function  WWHSearchScope_Object()
  754. {
  755.   this.mEntries = new Array();
  756.   this.mGroupStack = new Array();
  757.   this.mBookIndex = 0;
  758.  
  759.   this.fAddScopeEntries = WWHSearchScope_AddScopeEntries;
  760.  
  761.   // Set scope entries
  762.   //
  763.   this.fAddScopeEntries(WWHFrame.WWHHelp.mBookGroups);
  764. }
  765.  
  766. function  WWHSearchScope_AddScopeEntries(ParamGroup)
  767. {
  768.   var  MaxIndex;
  769.   var  Index;
  770.   var  MaxGroupStackIndex;
  771.   var  GroupStackIndex;
  772.   var  ScopeEntry;
  773.  
  774.  
  775.   for (MaxIndex = ParamGroup.mChildren.length, Index = 0 ; Index < MaxIndex ; Index++)
  776.   {
  777.     if (ParamGroup.mChildren[Index].mbGrouping)
  778.     {
  779.       // Add an entry
  780.       //
  781.       ScopeEntry = new WWHSearchScope_Entry_Object(this.mGroupStack.length, ParamGroup.mChildren[Index].mTitle, -1);
  782.       this.mEntries[this.mEntries.length] = ScopeEntry;
  783.  
  784.       // Push this entry onto the group stack
  785.       //
  786.       this.mGroupStack[this.mGroupStack.length] = ScopeEntry;
  787.  
  788.       // Process group entries
  789.       //
  790.       this.fAddScopeEntries(ParamGroup.mChildren[Index]);
  791.  
  792.       // Pop this entry off the group stack
  793.       //
  794.       this.mGroupStack.length -= 1;
  795.     }
  796.     else
  797.     {
  798.       // Add an entry
  799.       //
  800.       this.mEntries[this.mEntries.length] = new WWHSearchScope_Entry_Object(this.mGroupStack.length, WWHFrame.WWHHelp.mBooks.mBookList[this.mBookIndex].mTitle, this.mBookIndex);
  801.  
  802.       // Process all entries in the group stack, updating start/end book indicies
  803.       //
  804.       for (MaxGroupStackIndex = this.mGroupStack.length, GroupStackIndex = 0 ; GroupStackIndex < MaxGroupStackIndex ; GroupStackIndex++)
  805.       {
  806.         ScopeEntry = this.mGroupStack[GroupStackIndex];
  807.  
  808.         // Update start
  809.         //
  810.         if (ScopeEntry.mStartBookIndex == -1)
  811.         {
  812.           ScopeEntry.mStartBookIndex = this.mBookIndex;
  813.         }
  814.  
  815.         // Update end
  816.         //
  817.         ScopeEntry.mEndBookIndex = this.mBookIndex;
  818.       }
  819.  
  820.       // Increment book index
  821.       //
  822.       this.mBookIndex += 1;
  823.     }
  824.   }
  825. }
  826.  
  827. function  WWHBookSearchInfo_Object(ParamSearchFileCount,
  828.                                    ParamMinimumWordLength)
  829. {
  830.   this.mSearchFileCount   = ParamSearchFileCount;
  831.   this.mMinimumWordLength = ParamMinimumWordLength;
  832.   this.mSkipWords         = new WWHBookSearchInfo_SkipWords_Object();
  833.  
  834.   this.fAddSkipWord     = WWHBookSearchInfo_AddSkipWord;
  835.   this.fA               = WWHBookSearchInfo_AddSkipWord;
  836.   this.fValidSearchWord = WWHBookSearchInfo_ValidSearchWord;
  837. }
  838.  
  839. function  WWHBookSearchInfo_AddSkipWord(ParamSkipWord)
  840. {
  841.   if (ParamSkipWord.length > 0)
  842.   {
  843.     this.mSkipWords[ParamSkipWord + "~"] = 1;
  844.   }
  845. }
  846.  
  847. function  WWHBookSearchInfo_ValidSearchWord(ParamSearchWord)
  848. {
  849.   var  bValid = true;
  850.  
  851.  
  852.   if ((ParamSearchWord.length < this.mMinimumWordLength) ||
  853.       (typeof(this.mSkipWords[ParamSearchWord + "~"]) == "number"))
  854.   {
  855.     bValid = false;
  856.   }
  857.  
  858.   return bValid;
  859. }
  860.  
  861. function  WWHBookSearchInfo_SkipWords_Object()
  862. {
  863. }
  864.  
  865. function  WWHSearchBookMatches_Object()
  866. {
  867.   this.mFirstMatchedWordIndex = -1;
  868.   this.mMatchedWordIndex      = -1;
  869.   this.mWordFileScores        = new Array();
  870.   this.mFileScores            = new WWHSearchBookMatches_FileScores_Object();
  871.  
  872.   this.fClear               = WWHSearchBookMatches_Clear;
  873.   this.fSetMatchedWordIndex = WWHSearchBookMatches_SetMatchedWordIndex;
  874.   this.fAddMatches          = WWHSearchBookMatches_AddMatches;
  875.   this.f                    = WWHSearchBookMatches_AddMatches;  // For smaller search files
  876.   this.fJoinFileScores      = WWHSearchBookMatches_JoinFileScores;
  877. }
  878.  
  879. function  WWHSearchBookMatches_Clear()
  880. {
  881.   this.mFirstMatchedWordIndex = -1;
  882.   this.mMatchedWordIndex      = -1;
  883.   this.mWordFileScores.length = 0;
  884.   this.mFileScores            = new WWHSearchBookMatches_FileScores_Object();
  885. }
  886.  
  887. function  WWHSearchBookMatches_SetMatchedWordIndex(ParamMatchedWordIndex)
  888. {
  889.   this.mMatchedWordIndex = ParamMatchedWordIndex;
  890.   if (ParamMatchedWordIndex == this.mWordFileScores.length)
  891.   {
  892.     this.mWordFileScores[this.mWordFileScores.length] = new WWHSearchBookMatches_FileScores_Object();
  893.   }
  894. }
  895.  
  896. function  WWHSearchBookMatches_AddMatches(ParamMatchString)
  897. {
  898.   var  MatchList = null;
  899.   var  WordFileScoresEntry;
  900.   var  MaxIndex;
  901.   var  Index;
  902.   var  FileID;
  903.   var  Score;
  904.  
  905.  
  906.   if (typeof(ParamMatchString) != "undefined")
  907.   {
  908.     MatchList = ParamMatchString.split(",");
  909.   }
  910.  
  911.   if ((MatchList != null) &&
  912.       (MatchList.length > 0))
  913.   {
  914.     WordFileScoresEntry = this.mWordFileScores[this.mMatchedWordIndex];
  915.  
  916.     // Add all entries to word file score entry
  917.     //
  918.     for (MaxIndex = MatchList.length, Index = 0 ; Index < MaxIndex ; Index += 2)
  919.     {
  920.       FileID = "i" + MatchList[Index];
  921.       Score  = MatchList[Index + 1];
  922.  
  923.       WordFileScoresEntry[FileID] = parseInt(Score);
  924.     }
  925.   }
  926. }
  927.  
  928. function  WWHSearchBookMatches_JoinFileScores()
  929. {
  930.   var  MaxIndex;
  931.   var  Index;
  932.   var  WordFileScoresEntry;
  933.  
  934.  
  935.   this.mFileScores = new WWHSearchBookMatches_FileScores_Object();
  936.   for (MaxIndex = this.mWordFileScores.length, Index = 0 ; Index < MaxIndex ; Index++)
  937.   {
  938.     WordFileScoresEntry = this.mWordFileScores[Index];
  939.  
  940.     if (Index == 0)
  941.     {
  942.       // Add all entries if first entry
  943.       //
  944.       this.mFileScores = WordFileScoresEntry;
  945.     }
  946.     else
  947.     {
  948.       // Remove all entries not found in results set
  949.       //
  950.       for (FileID in this.mFileScores)
  951.       {
  952.         if (typeof(WordFileScoresEntry[FileID]) == "number")
  953.         {
  954.           this.mFileScores[FileID] += WordFileScoresEntry[FileID];
  955.         }
  956.         else
  957.         {
  958.           delete this.mFileScores[FileID];
  959.         }
  960.       }
  961.     }
  962.   }
  963. }
  964.  
  965. function  WWHSearchBookMatches_FileScores_Object()
  966. {
  967. }
  968.  
  969. function  WWHSearchResults_Object()
  970. {
  971.   this.mSortedBy     = null;
  972.   this.mEntries      = new Array();
  973.   this.mMaxScore     = 0;
  974.   this.mDisplayIndex = 0;
  975.   this.mByBookDetect = -1;
  976.   this.mHTMLSegment  = new WWHStringBuffer_Object();
  977.   this.mEventString  = WWHPopup_EventString();
  978.  
  979.   this.fClear           = WWHSearchResults_Clear;
  980.   this.fAddEntry        = WWHSearchResults_AddEntry;
  981.   this.fSortByScore     = WWHSearchResults_SortByScore;
  982.   this.fSortByBookIndex = WWHSearchResults_SortByBookIndex;
  983.   this.fDisplayReset    = WWHSearchResults_DisplayReset;
  984.   this.fDisplayAdvance  = WWHSearchResults_DisplayAdvance;
  985.   this.fGetPopupAction  = WWHSearchResults_GetPopupAction;
  986.   this.fShowEntry       = WWHSearchResults_ShowEntry;
  987. }
  988.  
  989. function  WWHSearchResults_Clear()
  990. {
  991.   this.mSortedBy       = null;
  992.   this.mEntries.length = 0;
  993.   this.mMaxScore       = 0;
  994. }
  995.  
  996. function  WWHSearchResults_AddEntry(ParamBookIndex,
  997.                                     ParamFileIndex,
  998.                                     ParamScore,
  999.                                     ParamTitle)
  1000. {
  1001.   // Add a new entry
  1002.   //
  1003.   this.mEntries[this.mEntries.length] = new WWHSearchResultsEntry_Object(ParamBookIndex,
  1004.                                                                          ParamFileIndex,
  1005.                                                                          ParamScore,
  1006.                                                                          ParamTitle);
  1007.  
  1008.   // Bump mMaxScore if necessary
  1009.   //
  1010.   if (ParamScore > this.mMaxScore)
  1011.   {
  1012.     this.mMaxScore = ParamScore;
  1013.   }
  1014. }
  1015.  
  1016. function  WWHSearchResults_SortByScore()
  1017. {
  1018.   this.mSortedBy = 1;  // By Score
  1019.  
  1020.   if (this.mEntries.length > 0)
  1021.   {
  1022.     this.mEntries = this.mEntries.sort(WWHSearchResultsEntry_ByScoreByBookIndexByTitleFileIndexURL);
  1023.   }
  1024. }
  1025.  
  1026. function  WWHSearchResults_SortByBookIndex()
  1027. {
  1028.   this.mSortedBy = 2;  // By BookIndex
  1029.  
  1030.   if (this.mEntries.length > 0)
  1031.   {
  1032.     this.mEntries = this.mEntries.sort(WWHSearchResultsEntry_ByBookIndexByScoreByTitleFileIndexURL);
  1033.   }
  1034. }
  1035.  
  1036. function  WWHSearchResults_DisplayReset(bParamDisplayBookTitles)
  1037. {
  1038.   this.mDisplayIndex = 0;
  1039.   this.mByBookDetect = -1;
  1040.  
  1041.   if ( ! bParamDisplayBookTitles)
  1042.   {
  1043.     this.mByBookDetect = -2;
  1044.   }
  1045. }
  1046.  
  1047. function  WWHSearchResults_DisplayAdvance()
  1048. {
  1049.   var  bSegmentCreated = false;
  1050.   var  Settings = WWHFrame.WWHJavaScript.mSettings.mSearch;
  1051.   var  HTML;
  1052.   var  MaxHTMLSegmentSize;
  1053.   var  BookList;
  1054.   var  MaxIndex;
  1055.   var  Index;
  1056.   var  Entry;
  1057.   var  VarAccessibilityTitle = "";
  1058.   var  VarPercent;
  1059.  
  1060.  
  1061.   // Insure that there is something to display
  1062.   //
  1063.   if ((this.mSortedBy != null) &&
  1064.       (this.mEntries.length > 0))
  1065.   {
  1066.     MaxHTMLSegmentSize = WWHFrame.WWHJavaScript.mMaxHTMLSegmentSize;
  1067.     this.mHTMLSegment.fReset();
  1068.     BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  1069.  
  1070.     // If this is the first entry, display the headers and open the list
  1071.     //
  1072.     if (this.mDisplayIndex == 0)
  1073.     {
  1074.       HTML = "";
  1075.  
  1076.       HTML += "<p><nobr><b>";
  1077.  
  1078.       // Display column headers
  1079.       //
  1080.       if (Settings.mbShowRank)
  1081.       {
  1082.         HTML += WWHFrame.WWHJavaScript.mMessages.mSearchRankLabel + " ";
  1083.       }
  1084.       HTML += WWHFrame.WWHJavaScript.mMessages.mSearchTitleLabel;
  1085.       if ((BookList.length > 1) &&  // More than one book exists
  1086.           (this.mSortedBy == 1))    // By Score
  1087.       {
  1088.         HTML += ", " + WWHFrame.WWHJavaScript.mMessages.mSearchBookLabel;
  1089.       }
  1090.       HTML += "</b></nobr></p>\n";
  1091.  
  1092.       HTML += "<ol>\n";
  1093.  
  1094.       this.mHTMLSegment.fAppend(HTML);
  1095.     }
  1096.  
  1097.     // Display result entries
  1098.     //
  1099.     MaxIndex = this.mEntries.length;
  1100.     Index = this.mDisplayIndex;
  1101.     while ((this.mHTMLSegment.fSize() < MaxHTMLSegmentSize) &&
  1102.            (Index < MaxIndex))
  1103.     {
  1104.       HTML = "";
  1105.  
  1106.       Entry = this.mEntries[Index];
  1107.  
  1108.       // Display Book
  1109.       //
  1110.       if ((BookList.length > 1) &&  // More than one book exists
  1111.           (this.mSortedBy == 2))    // By BookIndex
  1112.       {
  1113.         if (this.mByBookDetect == -2)
  1114.         {
  1115.           // Do not display book titles
  1116.           //
  1117.         }
  1118.         else if (this.mByBookDetect != Entry.mBookIndex)
  1119.         {
  1120.           // Close list for previous book
  1121.           //
  1122.           if (Index > 0)
  1123.           {
  1124.             HTML += "</ol>\n";
  1125.           }
  1126.  
  1127.           HTML += "<p><nobr> </nobr></p>";
  1128.           HTML += "<p class=\"BookTitle\"><nobr>" + BookList[Entry.mBookIndex].mTitle + "</nobr></p>";
  1129.  
  1130.           this.mByBookDetect = Entry.mBookIndex;
  1131.  
  1132.           // Open new list for next book
  1133.           //
  1134.           HTML += "<ol>\n";
  1135.         }
  1136.       }
  1137.  
  1138.       // Accessibility support
  1139.       //
  1140.       if (WWHFrame.WWHHelp.mbAccessible)
  1141.       {
  1142.         VarAccessibilityTitle = "";
  1143.  
  1144.         // Rank
  1145.         //
  1146.         if (Settings.mbShowRank)
  1147.         {
  1148.           VarPercent = Math.floor((Entry.mScore / this.mMaxScore) * 100);
  1149.  
  1150.           // Some browsers do not allow value attributes to be 0
  1151.           //
  1152.           if (VarPercent < 1)
  1153.           {
  1154.             VarPercent = 1;
  1155.           }
  1156.  
  1157.           VarAccessibilityTitle += WWHStringUtilities_EscapeHTML(WWHFrame.WWHJavaScript.mMessages.mSearchRankLabel + " " + VarPercent + ", ");
  1158.         }
  1159.  
  1160.         // Title
  1161.         //
  1162.         VarAccessibilityTitle += WWHStringUtilities_EscapeHTML(WWHFrame.WWHJavaScript.mMessages.mSearchTitleLabel + " " + Entry.mTitle);
  1163.  
  1164.         // Book
  1165.         //
  1166.         if (BookList.length > 1)  // More than one book exists
  1167.         {
  1168.           VarAccessibilityTitle += WWHStringUtilities_EscapeHTML(WWHFrame.WWHHelp.mMessages.mAccessibilityListSeparator + " " + WWHFrame.WWHJavaScript.mMessages.mSearchBookLabel + " " + BookList[Entry.mBookIndex].mTitle);
  1169.         }
  1170.  
  1171.         VarAccessibilityTitle = " title=\"" + VarAccessibilityTitle + "\"";
  1172.       }
  1173.  
  1174.       // Display Rank
  1175.       //
  1176.       if (Settings.mbShowRank)
  1177.       {
  1178.         VarPercent = Math.floor((Entry.mScore / this.mMaxScore) * 100);
  1179.  
  1180.         // Some browsers do not allow value attributes to be 0
  1181.         //
  1182.         if (VarPercent < 1)
  1183.         {
  1184.           VarPercent = 1;
  1185.         }
  1186.  
  1187.         HTML += "<li value=\"" + VarPercent + "\">";
  1188.       }
  1189.       else
  1190.       {
  1191.         HTML += "<li>";
  1192.       }
  1193.  
  1194.       // Display Title
  1195.       //
  1196.       HTML += "<a href=\"javascript:fC(" + Index + ");\"" + this.fGetPopupAction(Index) + VarAccessibilityTitle + ">";
  1197.       HTML += Entry.mTitle;
  1198.       HTML += "</a>";
  1199.  
  1200.       // Display Book
  1201.       //
  1202.       if ((BookList.length > 1) &&  // More than one book exists
  1203.           (this.mSortedBy == 1))    // By Score
  1204.       {
  1205.         HTML += ", " + BookList[Entry.mBookIndex].mTitle;
  1206.       }
  1207.  
  1208.       HTML += "</li>\n";
  1209.  
  1210.       this.mHTMLSegment.fAppend(HTML);
  1211.  
  1212.       Index++;
  1213.     }
  1214.  
  1215.     // Record current display index so we can pick up where we left off
  1216.     //
  1217.     this.mDisplayIndex = Index;
  1218.     if (this.mHTMLSegment.fSize() > 0)
  1219.     {
  1220.       bSegmentCreated = true;
  1221.     }
  1222.  
  1223.     // If this is the last entry, close the list
  1224.     //
  1225.     if (this.mDisplayIndex == this.mEntries.length)
  1226.     {
  1227.       this.mHTMLSegment.fAppend("</ol>\n");
  1228.     }
  1229.   }
  1230.  
  1231.   return bSegmentCreated;
  1232. }
  1233.  
  1234. function  WWHSearchResults_GetPopupAction(ParamEntryIndex)
  1235. {
  1236.   var  PopupAction = "";
  1237.  
  1238.  
  1239.   if (WWHFrame.WWHJavaScript.mSettings.mHoverText.mbEnabled)
  1240.   {
  1241.     PopupAction += " onMouseOver=\"fS('" + ParamEntryIndex + "', " + this.mEventString + ");\"";
  1242.     PopupAction += " onMouseOut=\"fH();\"";
  1243.   }
  1244.  
  1245.   return PopupAction;
  1246. }
  1247.  
  1248. function  WWHSearchResults_ShowEntry(ParamIndex)
  1249. {
  1250.   var  Entry;
  1251.   var  URL;
  1252.  
  1253.  
  1254.   // Update highlight words
  1255.   //
  1256.   WWHFrame.WWHHighlightWords.fSetWordList(WWHFrame.WWHSearch.mSavedSearchWords);
  1257.  
  1258.   // Display document
  1259.   //
  1260.   Entry = this.mEntries[ParamIndex];
  1261.   URL = WWHFrame.WWHHelp.fGetBookIndexFileIndexURL(Entry.mBookIndex, Entry.mFileIndex, null);
  1262.   WWHFrame.WWHHelp.fSetDocumentHREF(URL, false);
  1263. }
  1264.  
  1265. function  WWHSearchResultsEntry_Object(ParamBookIndex,
  1266.                                        ParamFileIndex,
  1267.                                        ParamScore,
  1268.                                        ParamTitle)
  1269. {
  1270.   this.mBookIndex = ParamBookIndex;
  1271.   this.mFileIndex = ParamFileIndex;
  1272.   this.mScore     = ParamScore;
  1273.   this.mTitle     = ParamTitle;
  1274. }
  1275.  
  1276. function  WWHSearchResultsEntry_ByScoreByBookIndexByTitleFileIndexURL(ParamAlphaEntry,
  1277.                                                                       ParamBetaEntry)
  1278. {
  1279.   var  Result;
  1280.  
  1281.  
  1282.   Result = WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry, ParamBetaEntry);
  1283.   if (Result == 0)
  1284.   {
  1285.     Result = WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry, ParamBetaEntry);
  1286.   }
  1287.   if (Result == 0)
  1288.   {
  1289.     Result = WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry, ParamBetaEntry);
  1290.   }
  1291.  
  1292.   return Result;
  1293. }
  1294.  
  1295. function  WWHSearchResultsEntry_ByBookIndexByScoreByTitleFileIndexURL(ParamAlphaEntry,
  1296.                                                                       ParamBetaEntry)
  1297. {
  1298.   var  Result;
  1299.  
  1300.  
  1301.   Result = WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry, ParamBetaEntry);
  1302.   if (Result == 0)
  1303.   {
  1304.     Result = WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry, ParamBetaEntry);
  1305.   }
  1306.   if (Result == 0)
  1307.   {
  1308.     Result = WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry, ParamBetaEntry);
  1309.   }
  1310.  
  1311.   return Result;
  1312. }
  1313.  
  1314. function  WWHSearchResultsEntry_CompareByScore(ParamAlphaEntry,
  1315.                                                ParamBetaEntry)
  1316. {
  1317.   var  Result = 0;
  1318.  
  1319.  
  1320.   // Sort by score
  1321.   //
  1322.   if (ParamAlphaEntry.mScore < ParamBetaEntry.mScore)
  1323.   {
  1324.     Result = 1;
  1325.   }
  1326.   else if (ParamAlphaEntry.mScore > ParamBetaEntry.mScore)
  1327.   {
  1328.     Result = -1;
  1329.   }
  1330.  
  1331.   return Result;
  1332. }
  1333.  
  1334. function  WWHSearchResultsEntry_CompareByBookIndex(ParamAlphaEntry,
  1335.                                                    ParamBetaEntry)
  1336. {
  1337.   var  Result = 0;
  1338.  
  1339.  
  1340.   if (ParamAlphaEntry.mBookIndex < ParamBetaEntry.mBookIndex)
  1341.   {
  1342.     Result = -1;
  1343.   }
  1344.   else if (ParamAlphaEntry.mBookIndex > ParamBetaEntry.mBookIndex)
  1345.   {
  1346.     Result = 1;
  1347.   }
  1348.  
  1349.   return Result;
  1350. }
  1351.  
  1352. function  WWHSearchResultsEntry_CompareByTitleFileIndexURL(ParamAlphaEntry,
  1353.                                                            ParamBetaEntry)
  1354. {
  1355.   var  Result = 0;
  1356.   var  BookList;
  1357.   var  AlphaBookEntry;
  1358.   var  BetaBookEntry;
  1359.   var  AlphaURL;
  1360.   var  BetaURL;
  1361.  
  1362.  
  1363.   // Sort by Title
  1364.   //
  1365.   if (ParamAlphaEntry.mTitle < ParamBetaEntry.mTitle)
  1366.   {
  1367.     Result = -1;
  1368.   }
  1369.   else if (ParamAlphaEntry.mTitle > ParamBetaEntry.mTitle)
  1370.   {
  1371.     Result = 1;
  1372.   }
  1373.   // Sort by FileIndex
  1374.   //
  1375.   else if (ParamAlphaEntry.mFileIndex < ParamBetaEntry.mFileIndex)
  1376.   {
  1377.     Result = -1;
  1378.   }
  1379.   else if (ParamAlphaEntry.mFileIndex > ParamBetaEntry.mFileIndex)
  1380.   {
  1381.     Result = 1;
  1382.   }
  1383.   // Sort by URL
  1384.   //
  1385.   else
  1386.   {
  1387.     BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  1388.  
  1389.     AlphaBookEntry = BookList[ParamAlphaEntry.mBookIndex];
  1390.     BetaBookEntry  = BookList[ParamBetaEntry.mBookIndex];
  1391.  
  1392.     AlphaURL = WWHFrame.WWHHelp.mBaseURL + AlphaBookEntry.mDirectory + AlphaBookEntry.mFiles.fFileIndexToHREF(ParamAlphaEntry.mFileIndex);
  1393.     BetaURL  = WWHFrame.WWHHelp.mBaseURL + BetaBookEntry.mDirectory + BetaBookEntry.mFiles.fFileIndexToHREF(ParamBetaEntry.mFileIndex);
  1394.  
  1395.     if (AlphaURL < BetaURL)
  1396.     {
  1397.       Result = -1;
  1398.     }
  1399.     else if (AlphaURL > BetaURL)
  1400.     {
  1401.       Result = 1;
  1402.     }
  1403.   }
  1404.  
  1405.   return Result;
  1406. }
  1407.