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

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