home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 2001 - Miguel Angel Rojas
- // @Modified build 497 cm20010225
-
- /**
- @Tool: gotoNext~goes to the next bookmark.
- If next bookmark does not exist, this will be the first.
- */
-
- function DoCommand()
- {
- var bookmarkMap = getMapFile( "Bookmarks" );
-
- if ( bookmarkMap.count == 0 )
- {
- return;
- }
-
- var currentBookmark = getGlobal( "currentBookmark", 0 );
- var list = getBookmarksAsList( bookmarkMap );
-
- if ( list.count == 0 )
- {
- return;
- }
-
- if ( currentBookmark < (list.count-1) ) // is not the last
- {
- currentBookmark += 1;
- }
- else
- {
- currentBookmark = 0;
- }
-
- var position = list.getPosition( currentBookmark );
-
- if ( position && position.valid )
- {
- setGlobal( "currentBookmark", currentBookmark );
-
- // alert( "gotoNext="+getGlobal( "currentBookmark" ) );
-
- var next = list.getAt( position );
- var nb = bookmarkMap.lookup( next.value.hashKey );
- nb.go();
- }
- }
-
- function getBookmarksAsList( bookmarkMap )
- {
- var list = newList();
- var position = bookmarkMap.getHeadPosition();
-
- while ( position && position.valid )
- {
- var next = bookmarkMap.getNext( position );
- if (next.value.valid())
- {
- list.addTail(next);
- }
- else
- {
- bookmarkMap.remove(next.value.hashKey);
- }
- }
-
- list.sort(); // sort in order of creation
-
- return list;
- }
-
- !!/Script
-