home *** CD-ROM | disk | FTP | other *** search
/ Thomson (Residential) / TGSTPv7203.iso / mac / Documentation / HTML / TG585-v7_en / wwhelp / wwhimpl / js / scripts / outline.js < prev    next >
Text File  |  2007-10-04  |  26KB  |  959 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHOutline_Object()
  5. {
  6.   var  bUseSafeMethods = true;
  7.  
  8.  
  9.   // Determine display method based on browser type
  10.   //
  11.   if ((WWHFrame.WWHBrowserInfo.mBrowser == 2) ||  // Shorthand for IE
  12.       (WWHFrame.WWHBrowserInfo.mBrowser == 3) ||  // Shorthand for iCab
  13.       (WWHFrame.WWHBrowserInfo.mBrowser == 4))    // Shorthand for Netscape 6.0 (Mozilla)
  14.   {
  15.     bUseSafeMethods = false;
  16.   }
  17.  
  18.   this.mbPanelInitialized = false;
  19.   this.mPanelAnchor       = null;
  20.   this.mPanelTabTitle     = WWHFrame.WWHJavaScript.mMessages.mTabsTOCLabel;
  21.   this.mInitIndex         = 0;
  22.   this.mBookEntryArray    = new Array();
  23.   this.mEntryHash         = new WWHOutlineEntryHash_Object();
  24.   this.mTopEntry          = new WWHOutlineEntry_Top_Object();
  25.   this.mNextEntryID       = 0;
  26.   this.mMaxLevel          = 0;
  27.   this.mSyncBookID        = null;
  28.   this.mSyncFileHREF      = null;
  29.   this.mImagingObject     = (bUseSafeMethods) ? new WWHOutlineImagingSafe_Object() : new WWHOutlineImagingFast_Object();
  30.  
  31.   this.fInitHeadHTML       = WWHOutline_InitHeadHTML;
  32.   this.fInitBodyHTML       = WWHOutline_InitBodyHTML;
  33.   this.fInitGroupings      = WWHOutline_InitGroupings;
  34.   this.fInitLoadBookTOC    = WWHOutline_InitLoadBookTOC;
  35.   this.fHeadHTML           = WWHOutline_HeadHTML;
  36.   this.fStartHTMLSegments  = WWHOutline_StartHTMLSegments;
  37.   this.fAdvanceHTMLSegment = WWHOutline_AdvanceHTMLSegment;
  38.   this.fGetHTMLSegment     = WWHOutline_GetHTMLSegment;
  39.   this.fEndHTMLSegments    = WWHOutline_EndHTMLSegments;
  40.   this.fHoverTextTranslate = WWHOutline_HoverTextTranslate;
  41.   this.fHoverTextFormat    = WWHOutline_HoverTextFormat;
  42.   this.fDisplayDoc         = WWHOutline_DisplayDoc;
  43.   this.fExpand             = WWHOutline_Expand;
  44.   this.fCollapse           = WWHOutline_Collapse;
  45.   this.fSync               = WWHOutline_Sync;
  46. }
  47.  
  48. function  WWHOutline_InitHeadHTML()
  49. {
  50.   var  InitHeadHTML = "";
  51.  
  52.  
  53.   return InitHeadHTML;
  54. }
  55.  
  56. function  WWHOutline_InitBodyHTML()
  57. {
  58.   var  HTML = new WWHStringBuffer_Object();
  59.   var  BookList = WWHFrame.WWHHelp.mBooks.mBookList;
  60.   var  MaxIndex;
  61.   var  Index;
  62.  
  63.  
  64.   // Display initializing message
  65.   //
  66.   HTML.fAppend("<h2>" + WWHFrame.WWHJavaScript.mMessages.mInitializingMessage + "</h2>\n");
  67.  
  68.   // Create top level entries for groups and books
  69.   //
  70.   this.fInitGroupings(this.mTopEntry, WWHFrame.WWHHelp.mBookGroups);
  71.  
  72.   // Load book TOC data
  73.   //
  74.   this.mInitIndex = 0;
  75.   for (MaxIndex = BookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  76.   {
  77.     // Reference TOC data
  78.     //
  79.     HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + WWHStringUtilities_RestoreEscapedSpaces(BookList[Index].mDirectory) + "wwhdata/js/toc.js\"></script>\n");
  80.  
  81.     // Load TOC data for current book
  82.     //
  83.     HTML.fAppend("<script language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/js/scripts/outlin1s.js\"></script>\n");
  84.   }
  85.  
  86.   return HTML.fGetBuffer();
  87. }
  88.  
  89. function  WWHOutline_InitGroupings(ParamParentEntry,
  90.                                    ParamGroup)
  91. {
  92.   var  MaxIndex;
  93.   var  Index;
  94.   var  GroupEntry;
  95.   var  TOCEntry;
  96.  
  97.  
  98.   for (MaxIndex = ParamGroup.mChildren.length, Index = 0 ; Index < MaxIndex ; Index++)
  99.   {
  100.     GroupEntry = ParamGroup.mChildren[Index];
  101.  
  102.     if (GroupEntry.mbGrouping)
  103.     {
  104.       // Create entry in TOC
  105.       //
  106.       TOCEntry = ParamParentEntry.fNewChild(GroupEntry.mTitle, "", GroupEntry.mIcon, GroupEntry.mOpenIcon);
  107.       TOCEntry.mbExpanded = GroupEntry.mbExpand;
  108.  
  109.       this.fInitGroupings(TOCEntry, GroupEntry);
  110.     }
  111.     else  // Must be a book directory
  112.     {
  113.       TOCEntry = ParamParentEntry.fNewChild(WWHFrame.WWHHelp.mBooks.mBookList[this.mBookEntryArray.length].mTitle, "", GroupEntry.mIcon, GroupEntry.mOpenIcon);
  114.  
  115.       // Set display options
  116.       //
  117.       TOCEntry.mbShow = GroupEntry.mbShow;
  118.       if (GroupEntry.mbShow)
  119.       {
  120.         TOCEntry.mbExpanded = GroupEntry.mbExpand;
  121.       }
  122.       else
  123.       {
  124.         TOCEntry.mbExpanded = true;
  125.         TOCEntry.mLevel     = ParamParentEntry.mLevel;
  126.       }
  127.  
  128.       // Add to mBookEntryArray
  129.       //
  130.       this.mBookEntryArray[this.mBookEntryArray.length] = TOCEntry;
  131.     }
  132.   }
  133. }
  134.  
  135. function  WWHOutline_InitLoadBookTOC(ParamAddTOCEntriesFunc)
  136. {
  137.   var  BookEntry;
  138.  
  139.  
  140.   // Access book entry
  141.   //
  142.   BookEntry = this.mBookEntryArray[this.mInitIndex];
  143.  
  144.   // Set Book Index
  145.   //
  146.   BookEntry.mBookIndex = this.mInitIndex;
  147.  
  148.   // Load TOC
  149.   //
  150.   ParamAddTOCEntriesFunc(BookEntry);
  151.  
  152.   // Assign URL for book entry
  153.   //
  154.   if ((BookEntry.mbShow) &&
  155.       (WWHFrame.WWHHelp.mBooks.mBookList[BookEntry.mBookIndex].mFiles.mFileList.length > 0))
  156.   {
  157.     BookEntry.mURL = "0";
  158.   }
  159.  
  160.   // Increment init book index
  161.   //
  162.   this.mInitIndex++;
  163.  
  164.   // Mark initialized if done
  165.   //
  166.   if (this.mInitIndex == WWHFrame.WWHHelp.mBooks.mBookList.length)
  167.   {
  168.     this.mbPanelInitialized = true;
  169.  
  170.     // Sync contents if necessary
  171.     //
  172.     if ((this.mSyncBookID != null) &&
  173.         (this.mSyncFileHREF != null))
  174.     {
  175.       this.fSync(this.mSyncBookID, this.mSyncFileHREF, false);
  176.  
  177.       this.mSyncBookID   = null;
  178.       this.mSyncFileHREF = null;
  179.     }
  180.   }
  181. }
  182.  
  183. function  WWHOutline_HeadHTML()
  184. {
  185.   var  HTML = new WWHStringBuffer_Object();
  186.  
  187.  
  188.   // Write formatting styles
  189.   //
  190.   HTML.fAppend(this.mImagingObject.fGenerateStyles());
  191.  
  192.   return HTML.fGetBuffer();
  193. }
  194.  
  195. function  WWHOutline_StartHTMLSegments()
  196. {
  197.   var  HTML = new WWHStringBuffer_Object();
  198.  
  199.  
  200.   // Reset imaging object
  201.   //
  202.   this.mImagingObject.fReset();
  203.  
  204.   // Define accessor functions to reduce file size
  205.   //
  206.   HTML.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\">\n");
  207.   HTML.fAppend(" <!--\n");
  208.   HTML.fAppend("  function  fE(ParamEntryID)\n");
  209.   HTML.fAppend("  {\n");
  210.   HTML.fAppend("    WWHFrame.WWHOutline.fExpand(ParamEntryID);\n");
  211.   HTML.fAppend("  }\n");
  212.   HTML.fAppend("\n");
  213.   HTML.fAppend("  function  fC(ParamEntryID)\n");
  214.   HTML.fAppend("  {\n");
  215.   HTML.fAppend("    WWHFrame.WWHOutline.fCollapse(ParamEntryID);\n");
  216.   HTML.fAppend("  }\n");
  217.   HTML.fAppend("\n");
  218.   HTML.fAppend("  function  fD(ParamEntryID)\n");
  219.   HTML.fAppend("  {\n");
  220.   HTML.fAppend("    WWHFrame.WWHOutline.fDisplayDoc(ParamEntryID);\n");
  221.   HTML.fAppend("  }\n");
  222.   HTML.fAppend("\n");
  223.   HTML.fAppend("  function  fS(ParamEntryID,\n");
  224.   HTML.fAppend("               ParamEvent)\n");
  225.   HTML.fAppend("  {\n");
  226.   HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fShow(ParamEntryID, ParamEvent);\n");
  227.   HTML.fAppend("  }\n");
  228.   HTML.fAppend("\n");
  229.   HTML.fAppend("  function  fH()\n");
  230.   HTML.fAppend("  {\n");
  231.   HTML.fAppend("    WWHFrame.WWHJavaScript.mPanels.mPopup.fHide();\n");
  232.   HTML.fAppend("  }\n");
  233.   HTML.fAppend(" // -->\n");
  234.   HTML.fAppend("</script>\n");
  235.  
  236.   return HTML.fGetBuffer();
  237. }
  238.  
  239. function  WWHOutline_AdvanceHTMLSegment()
  240. {
  241.   return this.mImagingObject.fAdvance(WWHFrame.WWHJavaScript.mMaxHTMLSegmentSize);
  242. }
  243.  
  244. function  WWHOutline_GetHTMLSegment()
  245. {
  246.   return this.mImagingObject.mHTMLSegment.fGetBuffer();
  247. }
  248.  
  249. function  WWHOutline_EndHTMLSegments()
  250. {
  251.   return "";
  252. }
  253.  
  254. function  WWHOutline_HoverTextTranslate(ParamEntryID)
  255. {
  256.   return this.mEntryHash[ParamEntryID].mText;
  257. }
  258.  
  259. function  WWHOutline_HoverTextFormat(ParamWidth,
  260.                                      ParamTextID,
  261.                                      ParamText)
  262. {
  263.   var  FormattedText   = "";
  264.   var  ForegroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mForegroundColor;
  265.   var  BackgroundColor = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBackgroundColor;  
  266.   var  BorderColor     = WWHFrame.WWHJavaScript.mSettings.mHoverText.mBorderColor;
  267.   var  ImageDir        = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/images";
  268.   var  ReqSpacer1w2h   = "<img src=\"" + ImageDir + "/spc1w2h.gif\" width=1 height=2>";
  269.   var  ReqSpacer2w1h   = "<img src=\"" + ImageDir + "/spc2w1h.gif\" width=2 height=1>";
  270.   var  ReqSpacer1w7h   = "<img src=\"" + ImageDir + "/spc1w7h.gif\" width=1 height=7>";
  271.   var  ReqSpacer5w1h   = "<img src=\"" + ImageDir + "/spc5w1h.gif\" width=5 height=1>";
  272.   var  Spacer1w2h      = ReqSpacer1w2h;
  273.   var  Spacer2w1h      = ReqSpacer2w1h;
  274.   var  Spacer1w7h      = ReqSpacer1w7h;
  275.   var  Spacer5w1h      = ReqSpacer5w1h;
  276.  
  277.  
  278.   // Netscape 6.x (Mozilla) renders table cells with graphics
  279.   // incorrectly inside of <div> tags that are rewritten on the fly
  280.   //
  281.   if (WWHFrame.WWHBrowserInfo.mBrowser == 4)  // Shorthand for Netscape 6.x (Mozilla)
  282.   {
  283.     Spacer1w2h = "";
  284.     Spacer2w1h = "";
  285.     Spacer1w7h = "";
  286.     Spacer5w1h = "";
  287.   }
  288.  
  289.   FormattedText += "<table width=\"" + ParamWidth + "\" border=0 cellspacing=0 cellpadding=0 bgcolor=\"" + BackgroundColor + "\">";
  290.   FormattedText += " <tr>";
  291.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  292.   FormattedText += " </tr>";
  293.  
  294.   FormattedText += " <tr>";
  295.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  296.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  297.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  298.   FormattedText += " </tr>";
  299.  
  300.   FormattedText += " <tr>";
  301.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  302.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  303.   FormattedText += "  <td width=\"100%\" id=\"" + ParamTextID + "\" style=\"color: " + ForegroundColor + " ; " + WWHFrame.WWHJavaScript.mSettings.mHoverText.mFontStyle + "\">" + ParamText + "</td>";
  304.   FormattedText += "  <td>" + ReqSpacer5w1h + "</td>";
  305.   FormattedText += "  <td bgcolor=\"" + BorderColor + "\">" + ReqSpacer2w1h + "</td>";
  306.   FormattedText += " </tr>";
  307.  
  308.   FormattedText += " <tr>";
  309.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  310.   FormattedText += "  <td height=7 colspan=3>" + Spacer1w7h + "</td>";
  311.   FormattedText += "  <td height=7 bgcolor=\"" + BorderColor + "\">" + Spacer2w1h + "</td>";
  312.   FormattedText += " </tr>";
  313.  
  314.   FormattedText += " <tr>";
  315.   FormattedText += "  <td height=2 colspan=5 bgcolor=\"" + BorderColor + "\">" + Spacer1w2h + "</td>";
  316.   FormattedText += " </tr>";
  317.   FormattedText += "</table>";
  318.  
  319.   return FormattedText;
  320. }
  321.  
  322. function  WWHOutline_DisplayDoc(ParamEntryID)
  323. {
  324.   var  Entry;
  325.   var  Parent;
  326.   var  Parts;
  327.   var  LinkFileIndex;
  328.   var  LinkAnchor;
  329.   var  BookListEntry;
  330.   var  NewHREF;
  331.  
  332.  
  333.   // Close down any popups we had going to prevent JavaScript errors
  334.   //
  335.   WWHFrame.WWHJavaScript.mPanels.mPopup.fHide();
  336.  
  337.   Entry = this.mEntryHash[ParamEntryID];
  338.  
  339.   // Expand if folder
  340.   //
  341.   if (( ! Entry.mbExpanded) &&
  342.       (Entry.mChildren != null))
  343.   {
  344.     this.fExpand(ParamEntryID);
  345.   }
  346.  
  347.   // Determine which book this document belongs to
  348.   //
  349.   Parent = Entry;
  350.   while ((Parent.mParent != null) &&
  351.          (typeof Parent.mBookIndex != "number"))
  352.   {
  353.     Parent = Parent.mParent;
  354.   }
  355.  
  356.   if (typeof Parent.mBookIndex == "number")
  357.   {
  358.     // Confirm URL defined (handles group entries)
  359.     //
  360.     if (Entry.mURL.length > 0)
  361.     {
  362.       // Determine link file index and anchor
  363.       //
  364.       Parts = Entry.mURL.split("#");
  365.       LinkFileIndex = parseInt(Parts[0]);
  366.       if (Parts.length > 1)
  367.       {
  368.         LinkAnchor = "#" + Parts[1];
  369.       }
  370.       else
  371.       {
  372.         LinkAnchor = "";
  373.       }
  374.  
  375.       BookListEntry = WWHFrame.WWHHelp.mBooks.mBookList[Parent.mBookIndex];
  376.       NewHREF = WWHFrame.WWHHelp.mBaseURL + BookListEntry.mDirectory + BookListEntry.mFiles.fFileIndexToHREF(LinkFileIndex) + LinkAnchor;
  377.  
  378.       WWHFrame.WWHHelp.fSetDocumentHREF(NewHREF, false);
  379.     }
  380.   }
  381. }
  382.  
  383. function  WWHOutline_Expand(ParamEntryID)
  384. {
  385.   var  Entry = this.mEntryHash[ParamEntryID];
  386.  
  387.  
  388.   Entry.mbExpanded = true;
  389.   this.mImagingObject.fUpdateEntry(Entry);
  390. }
  391.  
  392. function  WWHOutline_Collapse(ParamEntryID)
  393. {
  394.   var  Entry = this.mEntryHash[ParamEntryID];
  395.  
  396.  
  397.   Entry.mbExpanded = false;
  398.   this.mImagingObject.fUpdateEntry(Entry);
  399. }
  400.  
  401. function  WWHOutline_Sync(ParamBookID,
  402.                           ParamFileHREF,
  403.                           bParamVisible)
  404. {
  405.   var  BookEntry;
  406.   var  MaxIndex;
  407.   var  Index;
  408.   var  Parts;
  409.   var  FileIndex;
  410.   var  Anchor;
  411.   var  SearchPattern;
  412.   var  Iterator;
  413.   var  MatchedEntry;
  414.   var  CandidateEntry;
  415.  
  416.  
  417.   if ( ! this.mbPanelInitialized)
  418.   {
  419.     this.mSyncBookID   = ParamBookID;
  420.     this.mSyncFileHREF = ParamFileHREF;
  421.   }
  422.   else  // (this.mbPanelInitialized)
  423.   {
  424.     BookEntry = null;
  425.     MatchedEntry = null;
  426.  
  427.     // Find book entry
  428.     //
  429.     if (this.mBookEntryArray.length > 0)
  430.     {
  431.       // Find matching book entry
  432.       //
  433.       for (MaxIndex = this.mBookEntryArray.length, Index = 0 ; Index < MaxIndex ; Index++)
  434.       {
  435.         if (this.mBookEntryArray[Index].mBookIndex == ParamBookID)
  436.         {
  437.           BookEntry = this.mBookEntryArray[Index];
  438.         }
  439.       }
  440.     }
  441.  
  442.     // Confirm we found our matching book entry
  443.     //
  444.     if (BookEntry != null)
  445.     {
  446.       // Determine file index and anchor
  447.       //
  448.       Parts = ParamFileHREF.split("#");
  449.       FileIndex = WWHFrame.WWHHelp.mBooks.mBookList[BookEntry.mBookIndex].mFiles.fHREFToIndex(escape(Parts[0]));
  450.       if (Parts.length > 1)
  451.       {
  452.         Anchor = "#" + Parts[1];
  453.       }
  454.       else
  455.       {
  456.         Anchor = "";
  457.       }
  458.  
  459.       // Confirm we have a possible entry
  460.       //
  461.       if (FileIndex != -1)
  462.       {
  463.         SearchPattern = "" + FileIndex + Anchor;
  464.         Iterator = new WWHOutlineIterator_Object(false);
  465.  
  466.         if (Anchor.length > 0)
  467.         {
  468.           // Look for match
  469.           //
  470.           Iterator.fReset(BookEntry);
  471.           while ((MatchedEntry == null) &&
  472.                  (Iterator.fAdvance(null)))
  473.           {
  474.             if (Iterator.mEntry.mURL == SearchPattern)
  475.             {
  476.               MatchedEntry = Iterator.mEntry;
  477.             }
  478.           }
  479.         }
  480.  
  481.         // If match not found, search using just the file index without the anchor
  482.         //
  483.         if (MatchedEntry == null)
  484.         {
  485.           SearchPattern = "" + FileIndex;
  486.  
  487.           // Look for match
  488.           //
  489.           Iterator.fReset(BookEntry);
  490.           while ((MatchedEntry == null) &&
  491.                  (Iterator.fAdvance(null)))
  492.           {
  493.             // Trim of any trailing anchor information, if specified
  494.             //
  495.             if (Iterator.mEntry.mURL.indexOf("#") != -1)
  496.             {
  497.               CandidateEntry = Iterator.mEntry.mURL.substring(0, Iterator.mEntry.mURL.indexOf("#"));
  498.             }
  499.             else
  500.             {
  501.               CandidateEntry = Iterator.mEntry.mURL;
  502.             }
  503.  
  504.             if (CandidateEntry == SearchPattern)
  505.             {
  506.               MatchedEntry = Iterator.mEntry;
  507.             }
  508.           }
  509.         }
  510.  
  511.         // See if this matches the book entry
  512.         //
  513.         if ((MatchedEntry == null) &&
  514.             (BookEntry.mbShow))
  515.         {
  516.           SearchPattern = "" + FileIndex;
  517.  
  518.           if (SearchPattern == BookEntry.mURL)
  519.           {
  520.             MatchedEntry = BookEntry;
  521.           }
  522.         }
  523.  
  524.         // Sync display if entry found
  525.         //
  526.         if (MatchedEntry != null)
  527.         {
  528.           // Update display
  529.           //
  530.           this.mImagingObject.fRevealEntry(MatchedEntry, bParamVisible);
  531.         }
  532.       }
  533.     }
  534.  
  535.     // Display a message if the entry was not found
  536.     //
  537.     if ((BookEntry == null) ||
  538.         (MatchedEntry == null))
  539.     {
  540.       setTimeout("alert(\"" + WWHFrame.WWHJavaScript.mMessages.mTOCFileNotFoundMessage + "\");", 1);
  541.     }
  542.   }
  543. }
  544.  
  545. function  WWHOutlineEntry_Top_Object()
  546. {
  547.   this.mParent    = null;
  548.   this.mbShow     = false;
  549.   this.mText      = "Top Level";
  550.   this.mURL       = "";
  551.   this.mID        = -1;
  552.   this.mLevel     = -1;
  553.   this.mbExpanded = true;
  554.   this.mChildren  = null;
  555.  
  556.   this.fNewChild = WWHOutlineEntry_NewChild;
  557.   this.fN        = WWHOutlineEntry_NewChild;
  558. }
  559.  
  560. function  WWHOutlineEntry_Object(ParamParent,
  561.                                  ParamText,
  562.                                  ParamURL,
  563.                                  ParamIcon,
  564.                                  ParamOpenIcon)
  565. {
  566.   this.mParent    = ParamParent;
  567.   this.mbShow     = true;
  568.   this.mText      = ParamText;
  569.   this.mURL       = (typeof ParamURL == "string") ? ParamURL : "";
  570.   this.mID        = WWHFrame.WWHOutline.mNextEntryID;
  571.   this.mLevel     = ParamParent.mLevel + 1;
  572.   this.mbExpanded = false;
  573.   this.mChildren  = null;
  574.  
  575.   this.fNewChild = WWHOutlineEntry_NewChild;
  576.   this.fN        = WWHOutlineEntry_NewChild;
  577.  
  578.   // Assign custom icons if defined
  579.   //
  580.   if (typeof ParamIcon == "string")
  581.   {
  582.     this.mIcon = ParamIcon;
  583.   }
  584.   if (typeof ParamOpenIcon == "string")
  585.   {
  586.     this.mOpenIcon = ParamOpenIcon;
  587.   }
  588.  
  589.   // Increment ID
  590.   //
  591.   WWHFrame.WWHOutline.mNextEntryID++;
  592. }
  593.  
  594. function  WWHOutlineEntry_NewChild(ParamText,
  595.                                    ParamURL,
  596.                                    ParamIcon,
  597.                                    ParamOpenIcon)
  598. {
  599.   var  NewChild;
  600.  
  601.  
  602.   // Create a new entry
  603.   //
  604.   NewChild = new WWHOutlineEntry_Object(this, ParamText, ParamURL, ParamIcon, ParamOpenIcon);
  605.  
  606.   // Add to entry hash keyed by ID
  607.   //
  608.   WWHFrame.WWHOutline.mEntryHash[NewChild.mID] = NewChild;
  609.  
  610.   // Add child to parent entry
  611.   //
  612.   if (this.mChildren == null)
  613.   {
  614.     this.mChildren = new Array(NewChild);
  615.   }
  616.   else
  617.   {
  618.     this.mChildren[this.mChildren.length] = NewChild;
  619.   }
  620.  
  621.   // Bump mMaxLevel if we've exceeded it
  622.   //
  623.   if (NewChild.mLevel > WWHFrame.WWHOutline.mMaxLevel)
  624.   {
  625.     WWHFrame.WWHOutline.mMaxLevel = NewChild.mLevel;
  626.   }
  627.  
  628.   return NewChild;
  629. }
  630.  
  631. function  WWHOutlineEntryHash_Object()
  632. {
  633. }
  634.  
  635. function  WWHOutlineIterator_Object(bParamVisibleOnly)
  636. {
  637.   this.mbVisibleOnly  = bParamVisibleOnly;
  638.   this.mIteratorScope = null;
  639.   this.mEntry         = null;
  640.   this.mStack         = new Array();
  641.  
  642.   this.fReset   = WWHOutlineIterator_Reset;
  643.   this.fAdvance = WWHOutlineIterator_Advance;
  644. }
  645.  
  646. function  WWHOutlineIterator_Reset(ParamEntry)
  647. {
  648.   this.mIteratorScope = ParamEntry;
  649.   this.mEntry         = ParamEntry;
  650.   this.mStack.length  = 0;
  651. }
  652.  
  653. function  WWHOutlineIterator_Advance(ParamLevelStatusObject)
  654. {
  655.   // Advance to the next visible entry
  656.   //
  657.   if (this.mEntry != null)
  658.   {
  659.     // Check for visible children
  660.     //
  661.     if ((this.mEntry.mChildren != null) &&
  662.         (( ! this.mbVisibleOnly) ||
  663.          (this.mEntry.mbExpanded)))
  664.     {
  665.       // Process children
  666.       //
  667.       this.mEntry = this.mEntry.mChildren[0];
  668.       this.mStack[this.mStack.length] = 0;
  669.  
  670.       if (ParamLevelStatusObject != null)
  671.       {
  672.         ParamLevelStatusObject.fOpenLevel();
  673.       }
  674.     }
  675.     // If we've reached the iterator scope, we're done
  676.     //
  677.     else if (this.mEntry.mID == this.mIteratorScope.mID)
  678.     {
  679.       this.mEntry = null;
  680.     }
  681.     else
  682.     {
  683.       var  bSameLevel = true;
  684.       var  ParentEntry;
  685.       var  StackTop;
  686.  
  687.  
  688.       ParentEntry = this.mEntry.mParent;
  689.       this.mEntry = null;
  690.  
  691.       // Find next child of parent entry
  692.       //
  693.       while (ParentEntry != null)
  694.       {
  695.         // Increment position
  696.         //
  697.         StackTop = this.mStack.length - 1;
  698.         this.mStack[StackTop]++;
  699.  
  700.         // Confirm this is a valid entry
  701.         //
  702.         if (this.mStack[StackTop] < ParentEntry.mChildren.length)
  703.         {
  704.           // Return the parent's next child
  705.           //
  706.           this.mEntry = ParentEntry.mChildren[this.mStack[StackTop]];
  707.  
  708.           // Signal break from loop
  709.           //
  710.           ParentEntry = null;
  711.         }
  712.         else
  713.         {
  714.           // Last child of parent, try up a level
  715.           //
  716.           if (ParentEntry.mID == this.mIteratorScope.mID)
  717.           {
  718.             ParentEntry = null;
  719.           }
  720.           else
  721.           {
  722.             ParentEntry = ParentEntry.mParent;
  723.           }
  724.  
  725.           this.mStack.length--;
  726.  
  727.           bSameLevel = false;
  728.  
  729.           if (ParamLevelStatusObject != null)
  730.           {
  731.             ParamLevelStatusObject.fCloseLevel();
  732.           }
  733.         }
  734.       }
  735.  
  736.       if (bSameLevel)
  737.       {
  738.         if (ParamLevelStatusObject != null)
  739.         {
  740.           ParamLevelStatusObject.fSameLevel();
  741.         }
  742.       }
  743.     }
  744.   }
  745.  
  746.   return (this.mEntry != null);
  747. }
  748.  
  749. function  WWHOutlineImaging_ImageSrcDir()
  750. {
  751.   var  ImageSrcDir = "../../../";
  752.  
  753.  
  754.   // Update img src reference based on browser type and platform
  755.   //
  756.   if ((WWHFrame.WWHBrowserInfo.mBrowser == 2) &&  // Shorthand for IE
  757.       (WWHFrame.WWHBrowserInfo.mPlatform == 2))   // Shorthand for Macintosh
  758.   {
  759.     ImageSrcDir = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/";
  760.   }
  761.  
  762.   return ImageSrcDir;
  763. }
  764.  
  765. function  WWHOutlineImaging_EventString()
  766. {
  767.   var  EventString = "null";
  768.  
  769.  
  770.   // Set event string based on browser type
  771.   //
  772.   if ((WWHFrame.WWHBrowserInfo.mBrowser == 1) ||  // Shorthand for Netscape
  773.       (WWHFrame.WWHBrowserInfo.mBrowser == 2) ||  // Shorthand for IE
  774.       (WWHFrame.WWHBrowserInfo.mBrowser == 4))    // Shorthand for Netscape 6.0
  775.   {
  776.     EventString = "event";
  777.   }
  778.   else
  779.   {
  780.     EventString = "null";
  781.   }
  782.  
  783.   return EventString;
  784. }
  785.  
  786. function  WWHOutlineImaging_GetIconURL(ParamEntry)
  787. {
  788.   var  IconURL = "";
  789.  
  790.  
  791.   if (ParamEntry.mChildren != null)
  792.   {
  793.     if (ParamEntry.mbExpanded)
  794.     {
  795.       if (typeof ParamEntry.mOpenIcon == "string")
  796.       {
  797.         IconURL = this.mImageSrcDir + "images/" + ParamEntry.mOpenIcon;
  798.       }
  799.       else if (typeof ParamEntry.mIcon == "string")
  800.       {
  801.         IconURL = this.mImageSrcDir + "images/" + ParamEntry.mIcon;
  802.       }
  803.       else
  804.       {
  805.         IconURL = this.mImageSrcDir + "wwhimpl/common/images/fo.gif";
  806.       }
  807.     }
  808.     else
  809.     {
  810.       if (typeof ParamEntry.mIcon == "string")
  811.       {
  812.         IconURL = this.mImageSrcDir + "images/" + ParamEntry.mIcon;
  813.       }
  814.       else
  815.       {
  816.         IconURL = this.mImageSrcDir + "wwhimpl/common/images/fc.gif";
  817.       }
  818.     }
  819.   }
  820.   else
  821.   {
  822.     if (typeof ParamEntry.mIcon == "string")
  823.     {
  824.       IconURL = this.mImageSrcDir + "images/" + ParamEntry.mIcon;
  825.     }
  826.     else
  827.     {
  828.       IconURL = this.mImageSrcDir + "wwhimpl/common/images/doc.gif";
  829.     }
  830.   }
  831.  
  832.   return IconURL;
  833. }
  834.  
  835. function  WWHOutlineImaging_GetPopupAction(ParamEntry)
  836. {
  837.   var  PopupAction = "";
  838.  
  839.  
  840.   if (WWHFrame.WWHJavaScript.mSettings.mHoverText.mbEnabled)
  841.   {
  842.     PopupAction += " onMouseOver=\"fS(" + ParamEntry.mID + ", " + this.mEventString + ");\"";
  843.     PopupAction += " onMouseOut=\"fH();\"";
  844.   }
  845.  
  846.   return PopupAction;
  847. }
  848.  
  849. function  WWHOutlineImaging_GetLink(ParamEntry,
  850.                                     ParamPrefixText)
  851. {
  852.   var  LinkHTML = "";
  853.   var  Link     = "";
  854.  
  855.   // Add prefix to link HTML, if specified
  856.   //
  857.   if (ParamPrefixText != null)
  858.   {
  859.     LinkHTML += ParamPrefixText;
  860.   }
  861.  
  862.   // Add link text
  863.   //
  864.   LinkHTML += ParamEntry.mText;
  865.  
  866.   // Set link
  867.   //
  868.   if ((ParamEntry.mURL.length > 0) ||
  869.       (ParamEntry.mChildren != null))
  870.   {
  871.     Link += "<a name=\"t" + ParamEntry.mID + "\" href=\"javascript:fD(" + ParamEntry.mID + ");\"";
  872. //    Link += this.fGetPopupAction(ParamEntry) + ">" + LinkHTML + "</a>";
  873.     Link += ">" + LinkHTML + "</a>";
  874.   }
  875.   else
  876.   {
  877.     Link += LinkHTML;
  878.   }
  879.  
  880.   return Link;
  881. }
  882.  
  883. function  WWHOutlineImaging_GetLink2(ParamEntry,
  884.                                     sImage)
  885. {
  886.   // Opening table
  887.   var  LinkHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\">";
  888.  
  889.   // Wrap image in <a> tag
  890.   if ((ParamEntry.mURL.length > 0) ||
  891.       (ParamEntry.mChildren != null))
  892.   {
  893.     LinkHTML += "<a name=\"t" + ParamEntry.mID + "\" href=\"javascript:fD(" + ParamEntry.mID + ");\"";
  894.     LinkHTML += ">" + sImage + "</a>";
  895.   }
  896.   else
  897.   {
  898.     LinkHTML += sImage;
  899.   }
  900.  
  901.   // Add some HTML (new cell)
  902.   LinkHTML += "</td><td valign=\"top\" class=\"enf1\">";
  903.   
  904.   // Wrap text in <a> tag
  905.   if ((ParamEntry.mURL.length > 0) ||
  906.       (ParamEntry.mChildren != null))
  907.   {
  908.     LinkHTML += "<a name=\"t" + ParamEntry.mID + "\" href=\"javascript:fD(" + ParamEntry.mID + ");\"";
  909.     LinkHTML += ">" + ParamEntry.mText + "</a>";
  910.   }
  911.   else
  912.   {
  913.     LinkHTML += ParamEntry.mText;
  914.   }
  915.   
  916.   // Close table
  917.   LinkHTML += "</td></tr></table></td></tr></table>";
  918.  
  919.   return LinkHTML;
  920. }
  921.  
  922. function  WWHOutlineImaging_GetLink3(ParamEntry,
  923.                                     sImage)
  924. {
  925.   // Opening table
  926.   var  LinkHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\" class=l" + ParamEntry.mLevel + ">";
  927.  
  928.   // Wrap image in <a> tag
  929.   if ((ParamEntry.mURL.length > 0) ||
  930.       (ParamEntry.mChildren != null))
  931.   {
  932.     LinkHTML += "<a name=\"t" + ParamEntry.mID + "\" href=\"javascript:fD(" + ParamEntry.mID + ");\"";
  933.     LinkHTML += ">" + sImage + "</a>";
  934.   }
  935.   else
  936.   {
  937.     LinkHTML += sImage;
  938.   }
  939.  
  940.   // Add some HTML (new cell)
  941.   LinkHTML += "</td><td valign=\"top\" class=l" + ParamEntry.mLevel + ">";
  942.   
  943.   // Wrap text in <a> tag
  944.   if ((ParamEntry.mURL.length > 0) ||
  945.       (ParamEntry.mChildren != null))
  946.   {
  947.     LinkHTML += "<a name=\"t" + ParamEntry.mID + "\" href=\"javascript:fD(" + ParamEntry.mID + ");\"";
  948.     LinkHTML += ">" + ParamEntry.mText + "</a>";
  949.   }
  950.   else
  951.   {
  952.     LinkHTML += ParamEntry.mText;
  953.   }
  954.   
  955.   // Close table
  956.   LinkHTML += "</td></tr></table></td></tr></table>";
  957.  
  958.   return LinkHTML;
  959. }