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

  1. !!Script 
  2. // Copyright ⌐ 2001 - Miguel Angel Rojas G.
  3. // @Modified build 497 cm20010225
  4.  
  5. /**
  6. @Tool: moveLast~goes to the last 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 = list.getCount() - 1; // last : zero-based index
  20.     
  21.     setGlobal("currentBookmark", currentBookmark);
  22.     
  23.     var position = list.getPosition( currentBookmark );
  24.     var item = list.getAt( position );
  25.     
  26.     var currentMark = bookmarkMap.lookup( item.value.hashKey );
  27.     if ( currentMark )
  28.     {
  29.         currentMark.go();
  30.     }
  31. }
  32.  
  33. function getBookmarksAsList( bookmarkMap )
  34. {
  35.     if ( bookmarkMap.count == 0 )
  36.     {
  37.         return null;
  38.     }
  39.     
  40.     var list = newList();
  41.     var position = bookmarkMap.getHeadPosition();
  42.     
  43.     while ( position && position.valid )
  44.     {
  45.         var next = bookmarkMap.getNext( position );
  46.         if (next.value.valid())
  47.         {
  48.             list.addTail(next);
  49.         }
  50.         else
  51.         {
  52.             bookmarkMap.remove(next.value.hashKey);
  53.         }
  54.     }
  55.  
  56.     list.sort(); // sort in order of creation
  57.  
  58.     return list;
  59. }
  60.  
  61. !!/Script
  62.