Ignore:
Timestamp:
Aug 30, 2019 7:54:52 AM (6 years ago)
Author:
anonymous
Message:

add bin

File:
1 edited

Legend:

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

    r36 r41  
    1212    }
    1313
    14     async setup(top_sel){
    15         console.log("SideMenu setup menu_sel=" + this.menu_sel)
    16         let content = `<ul id="${this.menu_id}"></ul>`
    17         $(top_sel).append( content )
    18         this.get_filelist_async( this.num , this.part , (text) => {
    19             console.log("SideMenu setup text=" + text)
    20             let str = text
    21             let obj
    22             if( str.match( /{.*}/ ) === null ){
    23                 obj = {}
    24                 console.log("sidemenu setup 1 num=" + this.num + " part=" + this.part)
    25             }
    26             else {
    27                 obj = JSON.parse( str )
    28                 console.log("sidemenu setup 2 num=" + this.num + " part=" + this.part + " str="+str)
    29             }
    30             console.log( "sidemenu setup this.num=" + this.num + " this.part=" + this.part )
    31             Globalx.storagex.change_cache( obj, this.num , this.part )
    32            
    33             this.make_menu_item_list( obj , Globalx[this.part].key)
    34             $( this.menu_sel ).menu({
     14    display_menu( text ) {
     15        let str = text
     16        let obj
     17        if( str.match( /{.*}/ ) === null ){
     18            console.log("sidemenu 1 num="+ this.num + " part="+ this.part +" str="+str)
     19            obj = {}
     20        }
     21        else {
     22            console.log("sidemenu 2 num="+ this.num +" part="+ this.part +" str="+str)
     23            obj = JSON.parse( str )
     24        }
     25        Globalx.storagex.change_cache( obj, this.num , this.part )
     26
     27        this.setup_menu(obj)
     28    }
     29
     30    setup_menu(obj){
     31        this.make_menu_item_list( obj , Globalx[this.part].key)
     32        if( Globalx[this.part].menu === null ){
     33            Globalx[this.part].menu = $( this.menu_sel ).menu({
    3534                classes: {
    3635                    "ui-menu": "highlight"
    3736                }
    3837            })
    39         })
     38        }
     39    }
     40
     41    menu_init( top_sel ){
     42        $( top_sel ).empty()
     43        let content = `<ul id="${this.menu_id}"></ul>`
     44        $( top_sel ).append( content )
     45    }
     46
     47    async setup( top_sel ){
     48        this.menu_init( top_sel )
     49        this.get_filelist_async( this.num , this.part , (text) => {
     50            this.display_menu(text)
     51        } )
     52    }
     53
     54    async update( top_sel ){
     55        this.menu_init( top_sel )
     56        await Globalx.remotex.update_filelist( this.num, this.part, (text) => {
     57            this.display_menu(text)
     58        } )
    4059    }
    4160
    4261    async get_filelist_async( num , part , func){
    43         if( part == "setting" ){
    44             console.log( "get_filelist_async START part="+ part)
    45         }
    4662        let realData = Globalx.storagex.get_filelist( num , part )
    4763
    48         if( part == "setting" ){
    49             console.log( "get_filelist_async 2 part=" + part)
    50         }
    5164        if( realData === undefined || realData === null ){
    52             if( part == "setting" ){
    53                 console.log( "get_filelist_async 3 part=" + part)
    54             }
    5565            await Globalx.remotex.get_filelist_from_remote( num, part, func )
    56             if( part == "setting" ){
    57                 console.log( "get_filelist_async 4 part=" + part)
    58             }
    5966        }
    6067        else{
    6168            const obj = Globalx.storagex.get_filelist( num , part )
    62             this.make_menu_item_list( obj , Globalx[this.part].key)
    63             $( this.menu_sel ).menu({
    64                 classes: {
    65                     "ui-menu": "highlight"
    66                 }
    67             })
     69            this.setup_menu( obj )
    6870        }
    6971    }
     
    121123            if( jsondata[Globalx[part].key].length == 0 ){
    122124                Globalx[part].key_indicate_file = true;
     125console.log("Globalx[" + part + "].key_indicate_file = " + Globalx[part].key_indicate_file)
    123126                let url = ""
    124127                $( Globalx[part].download_url_sel ).val( Globalx[part].key )
     
    128131                $( Globalx[part].download_partial_url_sel ).attr('href' , url )
    129132                Globalx.remotex.get_content( this.num, this.part, Globalx[part].key , (content) => {
    130                     //console.log("content=" + content)
    131133                    Globalx[part].editor.getSession().setValue( content );
    132134                    $( Globalx[part].textarea_sel ).val( content );
     
    143145        let name = '..(Up)'
    144146        content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu">${name}</div></li>`;
    145         // content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu" onclick="menu_action( '${this.part}', '${this.name}', true)">${name}</div></li>`;
    146         //      content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu" onclick="this.menu_action_2">${name}</div></li>`;
    147147        $( this.menu_sel ).append(content);
    148         item = $( this.menu_sel ).last()
     148        item = $( this.menu_sel ).children().last()
    149149        item.on('click' , () => {
    150150            this.menu_action( key , true )
     
    154154            ary.map( ( item_name ) => {
    155155                content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu">${item_name}</div></li>`;
    156                 // content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu" onclick="menu_action( '${this.part}', '${item_name}' , false)">${item_name}</div></li>`;
    157                 //          content = `<li class="ui-menu-item"><div class="ui-menu-item-wrapper hasmenu" onclick="this.menu_action_2">${item_name}</div></li>`;
    158156                $( this.menu_sel ).append(content);
    159                 item = $( this.menu_sel ).last()
     157                item = $( this.menu_sel ).children().last()
    160158                item.on('click' , () => {
    161159                    this.menu_action( item_name )
     
    165163    }
    166164
    167     set_globalx_item_name( item_name ) {
    168         Globalx[this.part].item_name = item_name
    169         let dl = $( Globalx[ this.part ].download_sel )
    170         dl.attr('download' , Globalx[this.part].item_name)
     165    set_globalx_item_name( part , item_name ) {
     166        Globalx[part].item_name = item_name
     167        let dl = $( Globalx[ part ].download_sel )
     168        dl.attr('download' , Globalx[part].item_name)
    171169        dl.removeAttr('href')
    172170    }
     
    190188}
    191189
    192 /*
    193 function menu_action(part, item_name , up_flag = false) {
    194     Globalx[part].sidemenu.menu_action(item_name , up_flag)
    195 }
    196 */
Note: See TracChangeset for help on using the changeset viewer.