Ignore:
Timestamp:
Aug 26, 2019 6:15:44 PM (6 years ago)
Author:
anonymous
Message:

hide unused menu by css

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/testa-single-bookmark/js/bookmarkmgr.js

    r25 r36  
    11class 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        } )
    49        this.items = {}
     10        this.parts.map( (part) => {
     11            this.items[part] = {}
     12        } )
    513        this.max_display_name_length = max_display_name_length
    614    }
    715
    8     add( path , display_name = null){
    9         let result = this.paths.indexOf( path )
     16    add( part, path , display_name = null){
     17console.log("BookmarkMgr add part=" + part + " path="+ path)
     18        let result = this.paths[part].indexOf( path )
    1019        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 )
    1322        }
    14         return this.items[ path ]
     23        return this.items[part][ path ]
    1524    }
    1625
    17     remove( path ){
    18         let result = this.paths.indexOf( path )
     26    remove( part, path ){
     27        let result = this.paths[part].indexOf( path )
    1928        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 ]
    2231        }
    2332    }
    2433
    25     get( path ){
     34    get( part, path ){
    2635        let ret = null
    27         let result = this.paths.indexOf( path )
     36        let result = this.paths[part].indexOf( path )
    2837        if( result >= 0 ){
    29             ret = this.items[ path ]
     38            ret = this.items[part][ path ]
    3039        }
    3140        return ret
    3241    }
    3342
    34     display_name( path ){
    35         let result = this.paths.indexOf( path )
     43    display_name( part, path ){
     44        let result = this.paths[part].indexOf( path )
    3645        let disp = null
    3746        if( result >= 0 ){
    38             disp = this.items[ path ].display_name
     47            disp = this.items[part][ path ].display_name
    3948        }
    4049        return disp
    4150    }
    4251
    43     get_paths(){
    44         return this.paths
     52    get_paths(part){
     53        return this.paths[part]
    4554    }
    4655
    47     get_display_names(){
    48         const array = thils.paths
     56    get_display_names(part, path){
     57        const array = thils.paths[part]
    4958        return array.map( function( path ){
    50             return this.items[ path ].display_name
     59            return this.items[part][ path ].display_name
    5160        } )
    5261    }
    5362
    5463    get_restricted_display_name( path ){
    55         return path.substr( -this.max_display_name_length )
     64        return path.substr( -(this.max_display_name_length) )
    5665    }
    5766
    58     get_items() {
    59         return this.items
     67    get_items(part) {
     68        return this.items[part]
    6069    }
    6170
Note: See TracChangeset for help on using the changeset viewer.