Changeset 36 for branches/testa-single-bookmark/js/bookmarkmgr.js
- Timestamp:
- Aug 26, 2019 6:15:44 PM (6 years ago)
- File:
-
- 1 edited
-
branches/testa-single-bookmark/js/bookmarkmgr.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa-single-bookmark/js/bookmarkmgr.js
r25 r36 1 1 class BookmarkMgr { 2 constructor( max_display_name_length ) { 3 this.paths = [] 2 constructor( max_display_name_length , parts ) { 3 this.paths = {} 4 5 this.parts = parts 6 this.parts.map( (part) => { 7 this.paths[part] = [] 8 } ) 4 9 this.items = {} 10 this.parts.map( (part) => { 11 this.items[part] = {} 12 } ) 5 13 this.max_display_name_length = max_display_name_length 6 14 } 7 15 8 add( path , display_name = null){ 9 let result = this.paths.indexOf( path ) 16 add( part, path , display_name = null){ 17 console.log("BookmarkMgr add part=" + part + " path="+ path) 18 let result = this.paths[part].indexOf( path ) 10 19 if( result < 0 ){ 11 this.paths .push( path )12 this.items[ path ] = new Bookmark( path , this.max_display_name_length , display_name )20 this.paths[part].push( path ) 21 this.items[part][ path ] = new Bookmark( path , this.max_display_name_length , display_name ) 13 22 } 14 return this.items[ path ]23 return this.items[part][ path ] 15 24 } 16 25 17 remove( pa th ){18 let result = this.paths .indexOf( path )26 remove( part, path ){ 27 let result = this.paths[part].indexOf( path ) 19 28 if( result >= 0 ){ 20 delete this.items[ path ]21 delete this.paths[ result ]29 delete this.items[part][ path ] 30 delete this.paths[part][ result ] 22 31 } 23 32 } 24 33 25 get( pa th ){34 get( part, path ){ 26 35 let ret = null 27 let result = this.paths .indexOf( path )36 let result = this.paths[part].indexOf( path ) 28 37 if( result >= 0 ){ 29 ret = this.items[ path ]38 ret = this.items[part][ path ] 30 39 } 31 40 return ret 32 41 } 33 42 34 display_name( pa th ){35 let result = this.paths .indexOf( path )43 display_name( part, path ){ 44 let result = this.paths[part].indexOf( path ) 36 45 let disp = null 37 46 if( result >= 0 ){ 38 disp = this.items[ path ].display_name47 disp = this.items[part][ path ].display_name 39 48 } 40 49 return disp 41 50 } 42 51 43 get_paths( ){44 return this.paths 52 get_paths(part){ 53 return this.paths[part] 45 54 } 46 55 47 get_display_names( ){48 const array = thils.paths 56 get_display_names(part, path){ 57 const array = thils.paths[part] 49 58 return array.map( function( path ){ 50 return this.items[ path ].display_name59 return this.items[part][ path ].display_name 51 60 } ) 52 61 } 53 62 54 63 get_restricted_display_name( path ){ 55 return path.substr( - this.max_display_name_length)64 return path.substr( -(this.max_display_name_length) ) 56 65 } 57 66 58 get_items( ) {59 return this.items 67 get_items(part) { 68 return this.items[part] 60 69 } 61 70
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)