home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd2.bin / ruzne / painter / PAINTE~2.cab / _F3467A6AE9A8438FA925A74A7C2B95A7 < prev    next >
Text File  |  2003-01-06  |  10KB  |  351 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. // 
  3.  
  4. function  WWHelp_Object()
  5. {
  6.   var  BrowserDetect = new BrowserDetect_Object();
  7.  
  8.  
  9.   this.mBrowser          = BrowserDetect.mBrowser;
  10.   this.mPlatform         = BrowserDetect.mPlatform;
  11.   this.mbLoadData        = false;
  12.   this.mbInitialized     = false;
  13.   this.mMessages         = new Array();
  14.   this.mBookDirList      = new Array();
  15.   this.mBookList         = new Array();
  16.   this.mBaseURL          = location.href.substring(0, location.href.lastIndexOf("/wwhelp/js/html/frames.htm")) + "/";
  17.   this.mCurrentBookIndex = -1;
  18.   this.mTabs             = new Tabs_Object();
  19.   this.mSync             = new Sync_Object();
  20.   this.mContents         = new Outline_Object(this.mBrowser, this.mPlatform, this.mBaseURL);
  21.   this.mIndex            = new Index_Object();
  22.   this.mSearch           = new Search_Object();
  23.  
  24.   this.fAddBookDir            = WWHelp_AddBookDir;
  25.   this.fAddBook               = WWHelp_AddBook;
  26.   this.fIncrementCurBookIndex = WWHelp_IncrementCurBookIndex;
  27.   this.fTrimHREF              = WWHelp_TrimHREF;
  28.   this.fHREFToTitle           = WWHelp_HREFToTitle;
  29.   this.fParseHREF             = WWHelp_ParseHREF;
  30.   this.fSyncTOC               = WWHelp_SyncTOC;
  31.   this.fDataHTML              = WWHelp_DataHTML;
  32.   this.fDataHead              = WWHelp_DataHead;
  33.   this.fDataBody              = WWHelp_DataBody;
  34.  
  35.   // Load up messages
  36.   //
  37.   WWHelp_Messages(this.mMessages);
  38. }
  39.  
  40. function  WWHelp_AddBookDir(ParamBookDir)
  41. {
  42.   if ( ! this.mbInitialized)
  43.   {
  44.     if ((ParamBookDir != null) &&
  45.         (ParamBookDir.length > 0))
  46.     {
  47.       this.mBookDirList.length++;
  48.  
  49.       if (ParamBookDir == ".")
  50.       {
  51.         this.mBookDirList[this.mBookDirList.length - 1] = "";
  52.       }
  53.       else
  54.       {
  55.         this.mBookDirList[this.mBookDirList.length - 1] = escape(ParamBookDir) + "/";
  56.       }
  57.     }
  58.   }
  59. }
  60.  
  61. function  WWHelp_AddBook(ParamNewBook)
  62. {
  63.   var  NewBookTOCEntry;
  64.   var  NewBookIndexEntry;
  65.  
  66.  
  67.   this.mBookList.length++;
  68.   this.mBookList[this.mBookList.length - 1] = ParamNewBook;
  69.  
  70.   // Create TOC
  71.   //
  72.   if (this.mMessages["Tabs TOC"].length > 0)
  73.   {
  74.     NewBookTOCEntry = this.mContents.fNewBook(this.mBookList.length - 1, ParamNewBook.mBookTitle);
  75.     ParamNewBook.fAddTOCEntries(NewBookTOCEntry);
  76.   }
  77.  
  78.   // Add Index
  79.   //
  80.   if (this.mMessages["Tabs Index"].length > 0)
  81.   {
  82.     this.mIndex.fNewBook(ParamNewBook);
  83.   }
  84. }
  85.  
  86. function  WWHelp_IncrementCurBookIndex()
  87. {
  88.   // Increment CurrentBookIndex
  89.   //
  90.   if (this.mCurrentBookIndex != -1)
  91.   {
  92.     if (this.mCurrentBookIndex < this.mBookDirList.length)
  93.     {
  94.       this.mCurrentBookIndex++;
  95.     }
  96.     else  // We're done!
  97.     {
  98.       this.mCurrentBookIndex = -1;
  99.     }
  100.   }
  101. }
  102.  
  103. function  WWHelp_TrimHREF(ParamHREF)
  104. {
  105.   var  PoundIndex;
  106.   var  TrimmedHREF;
  107.  
  108.  
  109.   // Remove named anchor entries from link
  110.   //
  111.   PoundIndex = ParamHREF.lastIndexOf("#");
  112.   if (PoundIndex > 0)
  113.   {
  114.     TrimmedHREF = ParamHREF.substring(0, PoundIndex);
  115.   }
  116.   else
  117.   {
  118.     TrimmedHREF = ParamHREF;
  119.   }
  120.  
  121.   return TrimmedHREF;
  122. }
  123.  
  124. function  WWHelp_HREFToTitle(ParamBookIndex,
  125.                              ParamHREF)
  126. {
  127.   var  Title;
  128.   var  MaxIndex;
  129.   var  Index;
  130.  
  131.  
  132.   Title = "";
  133.   MaxIndex = this.mBookList.length;
  134.   Index = 0;
  135.   while ((Title.length == 0) &&
  136.          (Index < MaxIndex))
  137.   {
  138.     Title = this.mBookList[Index].fHREFToTitle(ParamHREF);
  139.  
  140.     Index++;
  141.   }
  142.  
  143.   return Title;
  144. }
  145.  
  146. function  WWHelp_ParseHREF(ParamHREF)
  147. {
  148.   var  ResultArray = new Array("", "");
  149.  
  150.  
  151.   if ((this.mBaseURL.length > 0) &&
  152.       (ParamHREF.length > this.mBaseURL.length))  // Make certain this can match
  153.   {
  154.     var  Prefix;
  155.     var  Suffix;
  156.  
  157.  
  158.     Prefix = ParamHREF.substring(0, this.mBaseURL.length);
  159.     Suffix = ParamHREF.substring(this.mBaseURL.length, ParamHREF.length);
  160.  
  161.     // Confirm we're under the same hierarchy
  162.     //
  163.     if (Prefix == this.mBaseURL)
  164.     {
  165.       var  LongestMatchIndex;
  166.       var  MaxIndex;
  167.       var  Index;
  168.  
  169.  
  170.       // Fix for differences between URL escapes and JavaScript
  171.       //
  172.       Suffix = unescape(Suffix);
  173.       Suffix = escape(Suffix);
  174.  
  175.       // Find the book directory
  176.       //
  177.       LongestMatchIndex = -1;
  178.       for (MaxIndex = this.mBookDirList.length, Index = 0 ; Index < MaxIndex ; Index++)
  179.       {
  180.         if (Suffix.indexOf(this.mBookDirList[Index]) == 0)
  181.         {
  182.           if (LongestMatchIndex == -1)
  183.           {
  184.             LongestMatchIndex = Index;
  185.           }
  186.           else if (this.mBookDirList[Index].length > this.mBookDirList[LongestMatchIndex].length)
  187.           {
  188.             LongestMatchIndex = Index;
  189.           }
  190.         }
  191.       }
  192.  
  193.       // If LongestMatchIndex is valid, we found our book directory
  194.       //
  195.       if (LongestMatchIndex != -1)
  196.       {
  197.         var  Parts;
  198.  
  199.  
  200.         // Reset suffix to be just the file portion
  201.         //
  202.         if (this.mBookDirList[LongestMatchIndex].length > 0)
  203.         {
  204.           Suffix = Suffix.substring(this.mBookDirList[LongestMatchIndex].length, Suffix.length);
  205.         }
  206.  
  207.         // Fixup any escaped "#"s
  208.         //
  209.         Suffix = unescape(Suffix);
  210.         Parts = Suffix.split("#");
  211.         for (MaxIndex = Parts.length, Index = 0 ; Index < MaxIndex ; Index++)
  212.         {
  213.           Parts[Index] = escape(Parts[Index]);
  214.         }
  215.         Suffix = Parts.join("#");
  216.  
  217.         ResultArray[0] = this.mBookDirList[LongestMatchIndex];
  218.         ResultArray[1] = Suffix;
  219.       }
  220.     }
  221.   }
  222.  
  223.   return ResultArray;
  224. }
  225.  
  226. function  WWHelp_SyncTOC(ParamHREF)
  227. {
  228.   // Only sync if TOC is available
  229.   // and selected
  230.   //
  231.   if ((ParamHREF != null) &&
  232.       (this.mMessages["Tabs TOC"].length > 0))
  233.   {
  234.     var  ParsedHREF;
  235.     var  BookDir;
  236.     var  FileHREF;
  237.     var  MaxIndex;
  238.     var  Index;
  239.     var  BookID;
  240.  
  241.  
  242.     // Get BookDir and FileHREF
  243.     //
  244.     ParsedHREF = this.fParseHREF(ParamHREF);
  245.     BookDir  = ParsedHREF[0];
  246.     FileHREF = ParsedHREF[1];
  247.  
  248.     // Determine BookID
  249.     //
  250.     BookID = -1;
  251.     MaxIndex = this.mBookList.length;
  252.     Index = 0;
  253.     while ((BookID == -1) &&
  254.            (Index < MaxIndex))
  255.     {
  256.       if (this.mBookList[Index].mBookDir == BookDir)
  257.       {
  258.         BookID = Index;
  259.       }
  260.  
  261.       Index++;
  262.     }
  263.  
  264.     // Display the selection
  265.     //
  266.     if (BookID != -1)
  267.     {
  268.       var  bVisible = false;
  269.  
  270.  
  271.       if (this.mTabs.mCurrentTab == 0)  // Outline view
  272.       {
  273.         bVisible = true;
  274.       }
  275.  
  276.       this.mContents.fSync(BookID, FileHREF, bVisible);
  277.     }
  278.   }
  279. }
  280.  
  281. function  WWHelp_DataHTML()
  282. {
  283.   if ( ! this.mbInitialized)
  284.   {
  285.     WWHelpTopFrame.WWHNavigation.WWHData.document.open("text/html", "replace");
  286.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"");
  287.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("            \"http://www.w3.org/TR/REC-html40/strict.dtd\">");
  288.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<html>");
  289.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<head>");
  290.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<title>Data</title>");
  291.  
  292.     this.fDataHead();
  293.  
  294.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("</head>");
  295.  
  296.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<body>");
  297.  
  298.     this.fDataBody();
  299.  
  300.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("</body>");
  301.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("</html>");
  302.     WWHelpTopFrame.WWHNavigation.WWHData.document.close();
  303.   }
  304. }
  305.  
  306. function  WWHelp_DataHead()
  307. {
  308.   if ( ! this.mbInitialized)
  309.   {
  310.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + "wwhelp/js/scripts/bookf.js\"></script>");
  311.   }
  312. }
  313.  
  314. function  WWHelp_DataBody()
  315. {
  316.   if ( ! this.mbInitialized)
  317.   {
  318.     var  MaxIndex;
  319.     var  Index;
  320.  
  321.  
  322.     this.mCurrentBookIndex = 0;
  323.     for (MaxIndex = this.mBookDirList.length, Index = 0 ; Index < MaxIndex ; Index++)
  324.     {
  325.       // Add entries for Book info
  326.       //
  327.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + this.mBookDirList[Index] + "wwhdata/js/book.js\"></script>");
  328.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + this.mBookDirList[Index] + "wwhdata/js/search.js\"></script>");
  329.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + this.mBookDirList[Index] + "wwhdata/js/files.js\"></script>");
  330.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + this.mBookDirList[Index] + "wwhdata/js/toc.js\"></script>");
  331.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + this.mBookDirList[Index] + "wwhdata/js/index.js\"></script>");
  332.  
  333.       // Create new book
  334.       //
  335.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + "wwhelp/js/scripts/data1s.js\"></script>");
  336.  
  337.       // Increment this.mCurrentBookIndex
  338.       //
  339.       WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + "wwhelp/js/scripts/data2s.js\"></script>");
  340.     }
  341.  
  342.     // Set initialized flag
  343.     //
  344.     this.mbInitialized = true;
  345.  
  346.     // Update Tabs and Sync frames
  347.     //
  348.     WWHelpTopFrame.WWHNavigation.WWHData.document.writeln("<script language=\"JavaScript\" src=\"" + this.mBaseURL + "wwhelp/js/scripts/data3s.js\"></script>");
  349.   }
  350. }
  351.