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

  1. function  LinksEntry_Object(ParamEntry,
  2.                             ParamHREFArray)
  3. {
  4.   this.mKey   = ParamEntry;
  5.   this.mHREFs = ParamHREFArray;
  6. }
  7.  
  8. function  LinksEntry_SortFunction(ParamAlpha,
  9.                                   ParamBeta)
  10. {
  11.   var  Result = 0;
  12.  
  13.  
  14.   if (ParamAlpha.mSortKey < ParamBeta.mSortKey)
  15.   {
  16.     Result = -1;
  17.   }
  18.   else if (ParamAlpha.mSortKey > ParamBeta.mSortKey)
  19.   {
  20.     Result = 1;
  21.   }
  22.   else if (ParamAlpha.mKey < ParamBeta.mKey)
  23.   {
  24.     Result = -1;
  25.   }
  26.   else if (ParamAlpha.mKey > ParamBeta.mKey)
  27.   {
  28.     Result = 1;
  29.   }
  30.  
  31.   return Result;
  32. }
  33.  
  34. function  Links_Object(ParamBookDir,
  35.                        ParamBookTitle)
  36. {
  37.   this.mBookDir   = ParamBookDir;
  38.   this.mBookTitle = ParamBookTitle;
  39.   this.mLinks     = new Array();
  40.   this.mLinksSize = 0;
  41.  
  42.   this.fLoadIndex       = Links_LoadIndex;
  43.   this.fSetTotalEntries = Links_SetTotalEntries;
  44.   this.fAddEntry        = Links_AddEntry;
  45.   this.fSortEntries     = Links_SortEntries;
  46. }
  47.  
  48. function  Links_LoadIndex(ParamAddLinksFunc)
  49. {
  50.   this.mLinksSize = 0;
  51.  
  52.   ParamAddLinksFunc(this);
  53.  
  54.   if (this.mLinks.length > this.mLinksSize)
  55.   {
  56.     this.mLinks.length = this.mLinksSize;  // Resize to correct length
  57.   }
  58. }
  59.  
  60. function  Links_SetTotalEntries(ParamTotal)
  61. {
  62.   this.mLinks.length = ParamTotal;
  63. }
  64.  
  65. function  Links_AddEntry(ParamEntry,
  66.                          ParamHREFArray)
  67. {
  68.   var  NewLink;
  69.  
  70.  
  71.   NewLink = new LinksEntry_Object(ParamEntry, ParamHREFArray);
  72.  
  73.   this.mLinksSize++;
  74.  
  75.   // Make sure we grow big enough
  76.   //
  77.   if (this.mLinksSize > this.mLinks.length)
  78.   {
  79.     this.mLinks.length++;
  80.   }
  81.  
  82.   this.mLinks[this.mLinksSize - 1] = NewLink;
  83. }
  84.  
  85. function  Links_SortEntries()
  86. {
  87.   var  MaxIndex;
  88.   var  Index;
  89.   var  CurrentEntry;
  90.  
  91.  
  92.   for (MaxIndex = this.mLinks.length, Index = 0 ; Index < MaxIndex ; Index++)
  93.   {
  94.     CurrentEntry = this.mLinks[Index];
  95.  
  96.     if (CurrentEntry.mSortKey == null)
  97.     {
  98.       CurrentEntry.mSortKey = CurrentEntry.mKey.toUpperCase();
  99.     }
  100.   }
  101.  
  102.   this.mLinks.sort(LinksEntry_SortFunction);
  103. }
  104.