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

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