Changeset 36 for branches/testa-single-bookmark/js/bookmarkmenu.js
- Timestamp:
- Aug 26, 2019 6:15:44 PM (6 years ago)
- File:
-
- 1 edited
-
branches/testa-single-bookmark/js/bookmarkmenu.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa-single-bookmark/js/bookmarkmenu.js
r29 r36 1 1 class BookmarkMenu { 2 constructor(num, part) { 3 this.num = num 4 this.part = part 5 this.bookmark_op_sel = Globalx[part].bookmark_op_sel 6 this.bookmark_mgr = Globalx[part].bookmark_mgr 7 this.bookmark_sel = Globalx[part].bookmark_sel 8 this.key_sel = Globalx[part].key_sel 9 this.editor = Globalx[part].editor 10 this.textarea_sel = Globalx[part].textarea_sel 11 this.menu_sel = Globalx[part].menu_sel 2 constructor( bookmark_displayname_max_length , mgr ) { 3 this.bookmark_displayname_max_length = bookmark_displayname_max_length 4 this.bookmark_mgr = mgr 5 } 6 7 dlg(){ 8 console.log("BookmarkMenu dlg()") 9 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx.bookmark_displayname_max_length) 10 $('#bookmarkDlg').dialog({ 11 autoOpen: false, 12 modal: true, 13 buttons: { 14 "OK": function() { 15 const part = Globalx.parts[ Globalx.index ] 16 const path = $( '#bookmark_path' ).val() 17 const displayname = $( '#bookmark_displayname' ).val() 18 Globalx.bookmarkmenu.register_bookmark(path, displayname ) 19 $(this).dialog("close")}, 20 "Cancel": function() { 21 const part = Globalx.parts[ Globalx.index ] 22 const bookmark_cb = $( Globalx[part].bookmark_op_sel ) 23 bookmark_cb.prop('checked', false) 24 $(this).dialog("close") 25 } 26 } 27 }) 12 28 } 13 29 14 30 add_bookmark() { 15 $( '#bookmark_displayname' ).val( Globalx[this.part].bookmark_mgr.get_restricted_display_name( Globalx[this.part].key ) ) 16 $( '#bookmark_path' ).val( Globalx[this.part].key ) 31 let part = Globalx.parts[ Globalx.index ] 32 console.log("add_bookmark part=" + part) 33 $( '#bookmark_displayname' ).val( this.bookmark_mgr.get_restricted_display_name( Globalx[part].key ) ) 34 $( '#bookmark_path' ).val( Globalx[part].key ) 17 35 $( '#bookmarkDlg' ).dialog("open") 18 36 } 19 37 20 38 remove_bookmark() { 21 this.bookmark_mgr.remove( Globalx[this.part].key ) 22 this.rebuild_bookmark_menu() 39 let part = Globalx.parts[ Globalx.index ] 40 console.log("remove_bookmark part=" + part) 41 this.bookmark_mgr.remove( part, Globalx[part].key ) 42 this.rebuild_bookmark_menu(part) 23 43 } 24 44 25 45 bookmark_op() { 26 if( $( this.bookmark_op_sel ).is(':checked') == true ){ 46 let part = Globalx.parts[ Globalx.index ] 47 let bookmark_op_sel = Globalx[part].bookmark_op_sel 48 console.log("bookmark_op part=" + part + " bookmark_op_sel=" + bookmark_op_sel) 49 if( $( bookmark_op_sel ).is(':checked') == true ){ 27 50 this.add_bookmark() 28 51 } … … 32 55 } 33 56 34 set_click_handler() { 35 console.log( "set_click_handler() part=" + this.part + " num=" + this.num ) 36 $( this.bookmark_op_sel ).on( 'click' , () => { this.bookmark_op() } ) 57 set_click_handler(part) { 58 let bookmark_op_sel = Globalx[part].bookmark_op_sel 59 60 console.log( "set_click_handler() part=" + part + " bookmark_op_sel=" + bookmark_op_sel ) 61 $( bookmark_op_sel ).on( 'click' , () => { 62 console.log("bookmark_op_sel clicked") 63 this.bookmark_op() } ) 37 64 } 38 65 39 register_bookmark_( path, displayname ) { 40 this.bookmark_mgr.add( path , displayname ) 41 this.rebuild_bookmark_menu() 66 register_bookmark( path, displayname ) { 67 let part = Globalx.parts[ Globalx.index ] 68 console.log("BookmarkMenu register_bookmark part="+part+" path="+path) 69 this.bookmark_mgr.add( part, path , displayname ) 70 this.rebuild_bookmark_menu(part) 42 71 } 43 72 44 rebuild_bookmark_menu() { 45 $( this.bookmark_sel ).empty() 73 rebuild_bookmark_menu(part) { 74 let num = Globalx.num 75 let bookmark_sel = Globalx[part].bookmark_sel 76 console.log("BookmarkMenu rebuld_bookmark_menu num="+num+ " part="+part) 77 $( bookmark_sel ).empty() 46 78 47 const array = this.bookmark_mgr.get_paths() 79 const array = this.bookmark_mgr.get_paths(part) 80 console.log("BookmarkMenu rebuld_bookmark_menu array=" + array ) 48 81 82 let content = null 83 let item = null 49 84 array.map( ( path ) => { 50 const display_name = this.bookmark_mgr.display_name( path ) 51 content = `<li><a href="#" onclick="this.bookmark_action( '${this.part}' , '${this.path}' )">${display_name}</a></li>`; 52 $( this.bookmark_sel ).append(content); 85 const display_name = this.bookmark_mgr.display_name( part, path ) 86 content = `<li><a href="#" >${display_name}</a></li>`; 87 console.log("BookmarkMenu rebuld_bookmark_menu content=" + content) 88 $( bookmark_sel ).append( content ); 89 console.log( "bookmark_sel="+bookmark_sel) 90 item = $( bookmark_sel ).last() 91 console.log( "item=" + item ) 92 item.on('click' , () => { 93 console.log("BookmarkMenu rebuld_bookmark_menu bookmark_action part="+part + " path" + path ) 94 this.bookmark_action( part , path ) 95 } ) 96 console.log("BookmarkMenu rebuld_bookmark_menu path=" + path ) 53 97 }) 98 } 99 100 set_globalx_item_name( part, item_name ) { 101 Globalx[part].item_name = item_name 102 let dl = $( Globalx[part].download_sel ) 103 dl.attr('download' , Globalx[part].item_name) 104 dl.removeAttr('href') 54 105 } 55 106 … … 62 113 return 63 114 } 64 65 let realData = Globalx.remotex.get_filelist( this.num)115 let num = Globalx.num 116 let jsondata = Globalx.storagex.get_filelist( Globalx.num , part) 66 117 Globalx[part].key = key 67 118 Globalx[part].key_indicate_file = false; 68 119 69 120 this.set_globalx_item_name( part, key ) 70 $( this.key_sel ).val( key )71 121 72 if( realData[Globalx[part].key].length == 0 ){ 122 $( Globalx[part].key_sel ).val( key ) 123 console.log("jsondata=" + jsondata) 124 if( jsondata[key].length == 0 ){ 73 125 Globalx[part].key_indicate_file = true; 74 Globalx.remotex.get_content( this.num, this.part, Globalx[part].key , (content) => {75 this.editor.getSession().setValue( content );76 $( this.textarea_sel ).val( content );126 Globalx.remotex.get_content( num, part, Globalx[part].key , (content) => { 127 Globalx[part].editor.getSession().setValue( content ) 128 $( Globalx[part].textarea_sel ).val( content ) 77 129 }); 78 130 } 79 131 else{ 80 132 Globalx[part].key_indicate_file = false 81 this.editor.getSession().setValue( "" );82 $( this.textarea_sel ).val( "" );133 Globalx[part].editor.getSession().setValue( "" ); 134 $( Globalx[part].textarea_sel ).val( "" ); 83 135 } 84 const bookmark_cb = $( this.bookmark_op_sel )136 const bookmark_cb = $( Globalx[part].bookmark_op_sel ) 85 137 bookmark_cb.prop('checked', true) 86 138 87 $( this.menu_sel ).empty()139 $( Globalx[part].menu_sel ).empty() 88 140 89 this.rebuild_bookmark_menu() 90 // this.make_menu_item_list(realData, Globalx[part].key) 141 this.make_menu_item_list(jsondata, Globalx[part].key) 91 142 } 92 143 }
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)