home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Bookmark / moveNext.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.2 KB  |  70 lines

  1. !!Script 
  2. // Copyright ⌐ 2001 - Miguel Angel Rojas G.
  3. // @Modified build 497 cm20010225
  4.  
  5. /**
  6. @Tool: moveNext~goes to the next bookmark.
  7. */
  8.  
  9. function DoCommand()
  10. {
  11.     var bookmarkMap = getMapFile( "Bookmarks" );
  12.     var list = getBookmarksAsList( bookmarkMap );
  13.     
  14.     if ( list == null || list.getCount() == 0 )
  15.     {
  16.         return;
  17.     }
  18.     
  19.     var currentBookmark = getGlobal( "currentBookmark", 0 ); // first by default: zero-based index
  20.     
  21.     var position = list.getPosition( currentBookmark );
  22.     
  23.     var item;
  24.     if ( position && position.valid )
  25.     {
  26.         list.getAt( position );
  27.         
  28.         if ( position && position.valid )
  29.         {
  30.             item = list.getNext( position );
  31.         }
  32.     
  33.         var currentMark = bookmarkMap.lookup( item.value.hashKey );
  34.         if ( currentMark )
  35.         {
  36.             currentMark.go();
  37.         }
  38.     }
  39. }
  40.  
  41. function getBookmarksAsList( bookmarkMap )
  42. {
  43.     if ( bookmarkMap.count == 0 )
  44.     {
  45.         return null;
  46.     }
  47.     
  48.     var list = newList();
  49.     var position = bookmarkMap.getHeadPosition();
  50.     
  51.     while ( position && position.valid )
  52.     {
  53.         var next = bookmarkMap.getNext( position );
  54.         if (next.value.valid())
  55.         {
  56.             list.addTail(next);
  57.         }
  58.         else
  59.         {
  60.             bookmarkMap.remove(next.value.hashKey);
  61.         }
  62.     }
  63.  
  64.     list.sort(); // sort in order of creation
  65.  
  66.     return list;
  67. }
  68.  
  69. !!/Script
  70.