home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 August / 08_02.iso / software / cb5 / files / Bryce5TrialVersion.exe / data1.cab / HelpFiles / wwhelp / common / scripts / frmsetf.js < prev    next >
Encoding:
JavaScript  |  2001-07-16  |  9.6 KB  |  369 lines

  1. function  WWHelpFrameSet_WWHelp_Object()
  2. {
  3.   this.mBookDirList = new Array();
  4.  
  5.   this.fAddBookDir = WWHelpFrameSet_WWHelp_AddBookDir;
  6. }
  7.  
  8. function  WWHelpFrameSet_WWHelp_AddBookDir(ParamBookDir)
  9. {
  10.   this.mBookDirList.length++;
  11.  
  12.   if (ParamBookDir == ".")
  13.   {
  14.     this.mBookDirList[this.mBookDirList.length - 1] = "";
  15.   }
  16.   else
  17.   {
  18.     this.mBookDirList[this.mBookDirList.length - 1] = escape(ParamBookDir) + "/";
  19.   }
  20. }
  21.  
  22. function  WWHelpFrameSet_Popup_Object()
  23. {
  24. }
  25.  
  26. function  WWHelpFrameSet_PopupBook_Object(ParamBookDir)
  27. {
  28.   this.mBookDir = ParamBookDir;
  29.   this.mPopups  = new WWHelpFrameSet_Popup_Object();
  30. }
  31.  
  32. function  WWHelpFrameSet_Object(ParamDocumentFrame)
  33. {
  34.   var  Agent = "";
  35.   var  MajorVersion = 0;
  36.   var  Parts;
  37.  
  38.  
  39.   // Determine browser
  40.   //
  41.   this.mBrowser = 0;  // Shorthand for Unknown
  42.  
  43.   Agent = navigator.userAgent.toLowerCase();
  44.   if ((Agent.indexOf("mozilla") != -1) &&
  45.       (Agent.indexOf("spoofer") == -1) &&
  46.       (Agent.indexOf("compatible") == -1))
  47.   {
  48.     MajorVersion = parseInt(navigator.appVersion)
  49.     if (MajorVersion >= 4)
  50.     {
  51.       this.mBrowser = 1;  // Shorthand for Netscape
  52.     }
  53.   }
  54.   else if (Agent.indexOf("msie") != -1)
  55.   {
  56.     MajorVersion = parseInt(navigator.appVersion)
  57.     if (MajorVersion >= 4)
  58.     {
  59.       this.mBrowser = 2;  // Shorthand for IE
  60.     }
  61.   }
  62.   else if (Agent.indexOf("icab") != -1)
  63.   {
  64.     this.mBrowser = 3;  // Shorthand for iCab
  65.   }
  66.  
  67.   // Determine platform
  68.   //
  69.   this.mPlatform = 0;  // Shorthand for Unknown
  70.  
  71.   if ((Agent.indexOf("win") != -1) ||
  72.       (Agent.indexOf("16bit") != -1))
  73.   {
  74.     this.mPlatform = 1;  // Shorthand for Windows
  75.   }
  76.   else if (Agent.indexOf("mac") != -1)
  77.   {
  78.     this.mPlatform = 2;  // Shorthand for Macintosh
  79.   }
  80.  
  81.   this.mBaseURL = location.href.substring(0, location.href.lastIndexOf("/"));
  82.   Parts = this.mBaseURL.split("/wwhelp/java/html");
  83.   if (Parts[0] == this.mBaseURL)
  84.   {
  85.     Parts = this.mBaseURL.split("/wwhelp/js/html");
  86.   }
  87.   this.mBaseURL = Parts[0] + "/";
  88.  
  89.   this.mBookDirList      = null;
  90.   this.mCurrentBookIndex = -1;
  91.   this.mPopups           = new WWHelpFrameSet_Popup_Object();
  92.   this.mBookTag          = null;
  93.   this.mTopicTag         = null;
  94.   this.mContextHREF      = null;
  95.   this.mLinkHREF         = null;
  96.   this.mPopup            = new Popup_Object("parent.WWHelpFrameSet.mPopup", "parent." + ParamDocumentFrame + ".document",
  97.                                             WWHelpPopup_PopupTranslate, WWHelpPopup_PopupFormat,
  98.                                             "WWHelpPopupDIV", "WWHelpPopupText", 500, 12, 20, 200);
  99.  
  100.   // Included from "handlers.js"
  101.   //
  102.   this.fUpdateFavorite = WWHelpFrameSet_UpdateFavorite;
  103.   this.fSyncTOC        = WWHelpFrameSet_SyncTOC;
  104.  
  105.   // Functions defined in this file
  106.   //
  107.   this.fExecute               = WWHelpFrameSet_Execute;
  108.   this.fParseHREF             = WWHelpFrameSet_ParseHREF;
  109.   this.fLoadData              = WWHelpFrameSet_LoadData;
  110.   this.fProcessBook           = WWHelpFrameSet_ProcessBook;
  111.   this.fLoadPopups            = WWHelpFrameSet_LoadPopups;
  112.   this.fCheckContext          = WWHelpFrameSet_CheckContext;
  113.   this.fIncrementCurBookIndex = WWHelpFrameSet_IncrementCurBookIndex;
  114.   this.fGetPopup              = WWHelpFrameSet_GetPopup;
  115.   this.fShowPopup             = WWHelpFrameSet_ShowPopup;
  116.   this.fHidePopup             = WWHelpFrameSet_HidePopup;
  117.   this.fClickedPopup          = WWHelpFrameSet_ClickedPopup;
  118. }
  119.  
  120. function  WWHelpFrameSet_Execute(ParamHREF,
  121.                                  ParamBookDirList)
  122. {
  123.   this.mBookDirList = ParamBookDirList;
  124.  
  125.   this.fParseHREF(ParamHREF);
  126.   this.fLoadData();
  127. }
  128.  
  129. function  WWHelpFrameSet_ParseHREF(ParamHREF)
  130. {
  131.   // Reset context tags
  132.   //
  133.   this.mBookTag  = null;
  134.   this.mTopicTag = null;
  135.  
  136.   // Check for possible context specification
  137.   //
  138.   if (ParamHREF.indexOf("?") != -1)
  139.   {
  140.     var  Parts;
  141.     var  ContextMarker = "context=";
  142.     var  TopicMarker   = "topic=";
  143.  
  144.  
  145.     Parts = ParamHREF.split("?");
  146.  
  147.     // Check for our context tags
  148.     //
  149.     if ((Parts[1].indexOf("&") != -1) &&
  150.         (Parts[1].indexOf(ContextMarker) != -1) &&
  151.         (Parts[1].indexOf(TopicMarker) != -1))
  152.     {
  153.       var  MaxIndex;
  154.       var  Index;
  155.  
  156.  
  157.       Parts = Parts[1].split("&");
  158.  
  159.       // Set context and topic, if specified
  160.       //
  161.       for (MaxIndex = Parts.length, Index = 0 ; Index < MaxIndex ; Index++)
  162.       {
  163.         if (Parts[Index].indexOf(ContextMarker) == 0)
  164.         {
  165.           this.mBookTag  = Parts[Index].substring(ContextMarker.length, Parts[Index].length);
  166.         }
  167.         if (Parts[Index].indexOf(TopicMarker) == 0)
  168.         {
  169.           this.mTopicTag = Parts[Index].substring(TopicMarker.length, Parts[Index].length);
  170.         }
  171.       }
  172.  
  173.       // Make certain we have both a BookTag and TopicTag
  174.       // Otherwise, reset them
  175.       //
  176.       if ((this.mBookTag  == null) ||
  177.           (this.mTopicTag == null))
  178.       {
  179.         this.mBookTag  = null;
  180.         this.mTopicTag = null;
  181.       }
  182.     }
  183.   }
  184. }
  185.  
  186. function  WWHelpFrameSet_LoadData()
  187. {
  188.   this.mContextHREF = null;
  189.  
  190.   this.mCurrentBookIndex = 0;
  191.   for (MaxIndex = this.mBookDirList.length, Index = 0 ; Index < MaxIndex ; Index++)
  192.   {
  193.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/context.js\"></script>");
  194.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/popups.js\"></script>");
  195.  
  196.     if ((this.mBookTag  != null) &&
  197.         (this.mTopicTag != null))
  198.     {
  199.       document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../../" + this.mBookDirList[Index] + "wwhdata/common/topics.js\"></script>");
  200.     }
  201.  
  202.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../common/scripts/frmset1s.js\"></script>");
  203.     document.writeln("<script type=\"text/javascript\" language=\"JavaScript\" src=\"../../common/scripts/frmset2s.js\"></script>");
  204.   }
  205. }
  206.  
  207. function  WWHelpFrameSet_ProcessBook(ParamBookContextFunc,
  208.                                      ParamPopupsFunc,
  209.                                      ParamMatchTopicFunc)
  210. {
  211.   var  Context;
  212.  
  213.  
  214.   // Get current book context
  215.   //
  216.   Context = ParamBookContextFunc();
  217.  
  218.   // Load up popups for this book
  219.   //
  220.   this.fLoadPopups(Context, ParamPopupsFunc);
  221.  
  222.   // Check for context match
  223.   //
  224.   this.fCheckContext(Context, ParamMatchTopicFunc);
  225. }
  226.  
  227. function  WWHelpFrameSet_LoadPopups(ParamContext,
  228.                                     ParamPopupsFunc)
  229. {
  230.   var  ContextPopups = new WWHelpFrameSet_PopupBook_Object(this.mBookDirList[this.mCurrentBookIndex]);
  231.  
  232.  
  233.   // Add entry for the current book dir and context
  234.   //
  235.   this.mPopups[ParamContext] = ContextPopups;
  236.  
  237.   // Now load the popups for the book
  238.   //
  239.   ParamPopupsFunc(ContextPopups.mPopups);
  240. }
  241.  
  242. function  WWHelpFrameSet_CheckContext(ParamContext,
  243.                                       ParamMatchTopicFunc)
  244. {
  245.   if (ParamMatchTopicFunc != null)
  246.   {
  247.     if ((this.mBookTag  != null) &&
  248.         (this.mTopicTag != null))
  249.     {
  250.       if (ParamContext == this.mBookTag)
  251.       {
  252.         if (this.mContextHREF == null)
  253.         {
  254.           this.mContextHREF = ParamMatchTopicFunc(this.mTopicTag);
  255.  
  256.           if (this.mContextHREF != null)
  257.           {
  258.             this.mContextHREF = "../../../" + this.mBookDirList[this.mCurrentBookIndex] + this.mContextHREF;
  259.           }
  260.         }
  261.       }
  262.     }
  263.   }
  264. }
  265.  
  266. function  WWHelpFrameSet_IncrementCurBookIndex()
  267. {
  268.   // Increment CurrentBookIndex
  269.   //
  270.   if (this.mCurrentBookIndex != -1)
  271.   {
  272.     if (this.mCurrentBookIndex < this.mBookDirList.length)
  273.     {
  274.       this.mCurrentBookIndex++;
  275.     }
  276.     else  // We're done!
  277.     {
  278.       this.mCurrentBookIndex = -1;
  279.     }
  280.   }
  281. }
  282.  
  283. function  WWHelpFrameSet_GetPopup(ParamContext,
  284.                                   ParamLink)
  285. {
  286.   var  ContextPopups;
  287.   var  BookDir = "";
  288.   var  PopupText = "";
  289.  
  290.  
  291.   // Match the context
  292.   //
  293.   ContextPopups = this.mPopups[ParamContext];
  294.   if (ContextPopups != null)
  295.   {
  296.     // Match the link
  297.     //
  298.     BookDir   = ContextPopups.mBookDir;
  299.     PopupText = ContextPopups.mPopups[ParamLink];
  300.   }
  301.  
  302.   return new Array(BookDir, PopupText);
  303. }
  304.  
  305. function  WWHelpFrameSet_ShowPopup(ParamContext,
  306.                                    ParamLink,
  307.                                    ParamEvent)
  308. {
  309.   var  PopupData;
  310.   var  PopupText;
  311.  
  312.  
  313.   // Get the popup text
  314.   //
  315.   PopupData = this.fGetPopup(ParamContext, ParamLink);
  316.   PopupText = PopupData[1];
  317.  
  318.   if ((PopupData != null) &&
  319.       (PopupText != null))
  320.   {
  321.     if (PopupText.length > 0)
  322.     {
  323.       this.mPopup.fShow(PopupText, ParamEvent);
  324.     }
  325.   }
  326. }
  327.  
  328. function  WWHelpFrameSet_HidePopup()
  329. {
  330.   this.mPopup.fHide();
  331. }
  332.  
  333. function  WWHelpFrameSet_ClickedPopup(ParamContext,
  334.                                       ParamLink)
  335. {
  336.   var  LinkHREF = "#";
  337.   var  PopupData;
  338.  
  339.  
  340.   // IE unescapes stuff for us, so we'll escape it right back
  341.   //
  342.   if (this.mBrowser == 2)  // Shorthand for IE
  343.   {
  344.     var  Parts;
  345.  
  346.  
  347.     Parts = ParamLink.split("#");
  348.     Parts[0] = escape(Parts[0]);
  349.     ParamLink = Parts.join("#");
  350.   }
  351.  
  352.   // Get the popup text
  353.   //
  354.   PopupData = this.fGetPopup(ParamContext, ParamLink);
  355.  
  356.   if (PopupData[0] != null)  // BookDir is valid
  357.   {
  358.     // Trim off the base filename and then up two levels
  359.     //
  360.     LinkHREF = this.mBaseURL + PopupData[0] + ParamLink;
  361.   }
  362.  
  363.   // Hide the popup if it is visible
  364.   //
  365.   this.mPopup.fHide();
  366.  
  367.   return LinkHREF;
  368. }
  369.