Changeset 25 for branches/testa/js
- Timestamp:
- Aug 21, 2019 7:44:47 PM (6 years ago)
- Location:
- branches/testa/js
- Files:
-
- 1 added
- 7 edited
-
bookmark.js (modified) (1 diff)
-
bookmarkmgr.js (modified) (3 diffs)
-
main.js (modified) (4 diffs)
-
menux.js (modified) (5 diffs)
-
remote.js (modified) (5 diffs)
-
storage.js (modified) (2 diffs)
-
tab.js (modified) (2 diffs)
-
topmenu.js (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa/js/bookmark.js
r23 r25 3 3 this.path = path 4 4 if( display_name == null ){ 5 this.display_name = path.substr( 0, max_display_name_length)5 this.display_name = path.substr(-max_display_name_length ) 6 6 } 7 7 else{ 8 this.display_name = display_name 8 this.display_name = display_name.substr( -max_display_name_length ) 9 9 } 10 10 } 11 12 display_name() {13 return this.display_name14 }15 11 } -
branches/testa/js/bookmarkmgr.js
r23 r25 6 6 } 7 7 8 add( path , display_name ){8 add( path , display_name = null){ 9 9 let result = this.paths.indexOf( path ) 10 10 if( result < 0 ){ … … 21 21 delete this.paths[ result ] 22 22 } 23 } 24 25 get( path ){ 26 let ret = null 27 let result = this.paths.indexOf( path ) 28 if( result >= 0 ){ 29 ret = this.items[ path ] 30 } 31 return ret 23 32 } 24 33 … … 46 55 return path.substr( -this.max_display_name_length ) 47 56 } 57 58 get_items() { 59 return this.items 60 } 61 62 max_display_name_length(){ 63 return this.max_display_name_length 64 } 48 65 } -
branches/testa/js/main.js
r24 r25 1 1 let Globalx = {}; 2 let GlobalxInitValue = { 3 editor: null, 4 key_indicate_file: false, 5 key: '/' 6 }; 2 7 3 8 function main() { 4 Globalx.num = 0; 5 Globalx.index = 0; 6 Globalx.parts = ["data", "output", "setting"] 9 restore_info_to_globalx() 7 10 8 Globalx.parts.map( function( value ){ 9 set_globalx_editor(value) 10 } ) 11 editor_func("data"); 12 make_ul_for_menu('data' , '#data-side') 13 menux( "data" ) 11 editor_func("data"); 12 make_ul_for_menu('data' , '#data-side') 13 menux( "data" ) 14 15 editor_func("setting"); 16 make_ul_for_menu("setting" , '#setting-side') 17 18 editor_func("output"); 19 make_ul_for_menu("output" , '#output-side') 14 20 15 $('#down-download').on('click', {part: "data"}, handleDownload)16 $( Globalx['data'].textarea_sel ).val("");21 tab_init() 22 topmenu_init() 17 23 18 editor_func("setting"); 19 make_ul_for_menu("setting" , '#setting-side') 24 rebuild_bookmark_menu("data") 20 25 21 editor_func("output"); 22 make_ul_for_menu("output" , '#output-side') 26 // LocalStorageにまだ保存していない場合を想定して、ここで保存しておく 27 console.log("call save_info_from_globalx()") 28 save_info_from_globalx() 29 30 part = "data" 31 $('#down-download').on('click', {part: part}, handleDownload) 32 $( Globalx['data'].textarea_sel ).val(""); 33 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx[part].bookmark_displayname_max_length) 34 $('#bookmarkDlg').dialog({ 35 autoOpen: false, 36 modal: true, 37 buttons: { 38 "OK": function() { 39 part = Globalx.parts[ Globalx.index ] 40 path = $( '#bookmark_path' ).val() 41 displayname = $( '#bookmark_displayname' ).val() 42 register_bookmark_( part , path, displayname ) 43 $(this).dialog("close")}, 44 "Cancel": function() { 45 bookmark_cb.prop('checked', false) 46 $(this).dialog("close") 47 } 48 } 49 }) 50 } 51 52 function init_globalx() { 53 Globalx.num = 0; 54 Globalx.index = 0; 55 Globalx.parts = ["data", "output", "setting"] 56 57 Globalx.parts.map( function( part ){ 58 console.log("init_globalx part=" + part ) 59 set_globalx_editor(part) 60 } ) 23 61 } 24 62 … … 46 84 Globalx[part].bookmark_mgr = new BookmarkMgr( Globalx[part].bookmark_displayname_max_length ) 47 85 48 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx[part].bookmark_displayname_max_length)49 $('#bookmarkDlg').dialog({50 autoOpen: false,51 modal: true,52 buttons: {53 "OK": function() {54 part = Globalx.parts[ Globalx.index ]55 56 Globalx[part].bookmark_mgr.add( $( '#bookmark_path' ).val() , $( '#bookmark_displayname' ).val() )57 $(this).dialog("close")},58 "Cancel": function() {59 $(this).dislog("close")60 }61 }62 })63 86 } 64 87 65 88 function editor_func(part) { 66 console.log(`Globalx[#{name}].editor_id=` + Globalx[part].editor_id )67 89 let editor = ace.edit( Globalx[part].editor_id ) 68 console.log( editor )69 90 editor.setTheme("ace/theme/monokai"); 70 91 editor.setFontSize(14); … … 74 95 Globalx[part].editor = editor; 75 96 let textarea = $( Globalx[part].textarea_sel ); 76 console.log( "textarea=" + textarea )77 97 Globalx[part].textarea = textarea; 78 98 editor.getSession().on("change", function () { … … 81 101 } 82 102 83 main() -
branches/testa/js/menux.js
r23 r25 12 12 13 13 function menu_action( part, item_name , up_flag = false ) { 14 if( Globalx[part].key != '/' ){ 15 16 } 17 14 18 let realData = get_filelist( Globalx.num ) 15 19 Globalx[part].key_indicate_file = false; … … 121 125 function bookmark_op(part) { 122 126 if( $( Globalx[part].bookmark_op_sel ).is(':checked') == true ){ 123 console.log( Globalx[part].key +" add_bookmark" )124 127 add_bookmark(part) 125 128 } 126 129 else{ 127 console.log( Globalx[part].key +" remove_bookmark")128 130 remove_bookmark(part) 129 131 } … … 131 133 132 134 function add_bookmark( part ) { 133 Globalx[part].bookmark_mgr.add( Globalx[part].key )134 rebuild_bookmark_menu( part )135 135 $( '#bookmark_displayname' ).val( Globalx[part].bookmark_mgr.get_restricted_display_name( Globalx[part].key ) ) 136 136 $( '#bookmark_path' ).val( Globalx[part].key ) 137 137 $('#bookmarkDlg').dialog("open") 138 138 } 139 140 function register_bookmark_( part , path, displayname ) { 141 Globalx[part].bookmark_mgr.add( path , displayname ) 142 rebuild_bookmark_menu( part ) 139 143 } 140 144 … … 162 166 return 163 167 } 168 if(key === Globalx[part].key){ 169 return 170 } 171 164 172 let realData = get_filelist( Globalx.num ) 165 173 Globalx[part].key = key … … 176 184 }); 177 185 } 186 else{ 187 Globalx[part].key_indicate_file = false 188 Globalx[part].editor.getSession().setValue( "" ); 189 $( Globalx[part].textarea_sel ).val( "" ); 190 } 178 191 const bookmark_cb = $( Globalx[part].bookmark_op_sel ) 179 192 bookmark_cb.prop('checked', true) 193 194 $( Globalx[part].menu_sel ).empty() 195 196 make_menu_item_list(part, realData) 180 197 } 198 -
branches/testa/js/remote.js
r23 r25 78 78 79 79 function get_content(path , func) { 80 console.log( "path:" + path )81 80 let param_array = [['cmd', 'get_content'], ['num', Globalx.num ], ['path', path]]; 82 81 let params = make_url_params( param_array ); … … 88 87 } 89 88 90 //91 //92 function restore_filelist(num, key){93 const data = get_filelist(num);94 if( data !== null ){95 // display_filelist( data, '#filelist' );96 // console.log( data['/'] );97 // console.log( data['/rtk'] );98 // console.log( data['/rtk/fmp_kernel'] );99 // console.log( data['/rtk/fmp_kernel/data'] );100 // console.log( data['/rtk/fmp_kernel/data/fmp-kernel.md'] );101 console.log( data[key] );102 }103 else{104 console.log("null returned!");105 }106 }107 89 function handleDownload(e) { 108 90 let dl = document.getElementById("down-download") 109 91 if( Globalx[ e.data.part ].key_indicate_file === true ){ 110 console.log("handleDownload-file")111 console.log(Globalx[ e.data.part ])112 92 113 93 get_content( Globalx[ e.data.part ].key , function(content) { … … 116 96 if (window.navigator.msSaveBlob) { 117 97 window.navigator.msSaveBlob(blob, Globalx[ e.data.part ].item_name); 118 console.log("handleDownload=" + Globalx[ e.data.part ].item_name)119 98 120 99 // msSaveOrOpenBlobの場合はファイルを保存せずに開ける 121 100 window.navigator.msSaveOrOpenBlob(blob, Globalx[ e.data.part ].item_name); 122 101 } else { 123 console.log( "handleDownLoad-1-2" )124 console.log("handleDownload=" + Globalx[ e.data.part ].item_name)125 102 dl.download = Globalx[ e.data.part ].item_name 126 103 dl.href = window.URL.createObjectURL(blob); … … 130 107 else{ 131 108 e.preventDefault() 132 console.log("handleDownload-Not file")133 109 dl.href = "" 134 110 dl.download = "" … … 138 114 function download_cmd(part) { 139 115 if( Globalx[part].key_indicate_file === true ){ 140 console.log("download_cmd filename=" + Globalx[part].filename)141 142 116 let dl = $( Globalx[part].download_sel ) 143 144 console.log( dl.attr('download') )145 117 dl.trigger('click') 146 118 } -
branches/testa/js/storage.js
r23 r25 1 1 let _globalStorage = {} 2 3 const _items = ["num", "index", "parts"] 4 5 function storage_test(){ 6 console.log(_items); 7 } 8 9 function save_info_from_globalx(){ 10 save_info_from_globalx_with_items(_items) 11 } 12 13 function convert_to_array_from_bookmark_mgr(mgr){ 14 return { 15 paths: mgr.get_paths(), 16 items: mgr_to_array(mgr), 17 max_display_name_length: mgr.max_display_name_length() 18 } 19 } 20 21 function save_info_from_globalx_with_items(items){ 22 let info = {} 23 24 copy_object( info, Globalx, items ) 25 /* 26 info.num = Globalx.num 27 info.index = Globalx.index 28 info.parts = Globalx.parts 29 */ 30 Globalx.parts.map( function (part) { 31 save_info_from_globalx_part(info , part) 32 } ) 33 34 save_info_to_local_storage(info) 35 } 36 function convert_to_plain_object_from_bookmark_mgr(mgr){ 37 // console.log( "mgr=" + mgr ) 38 // console.log( "mgr.items()=" + mgr.items ) 39 const paths = mgr.get_paths() 40 const new_bk_items = paths.map( function( path ){ 41 let ret = { 42 path: "", 43 display_name: "" 44 } 45 item = mgr.get(path) 46 if( item != null ){ 47 ret.path = path 48 ret.display_name = item.display_name 49 } 50 return ret 51 } ) 52 53 return { 54 max_display_name_length: mgr.max_display_name_length, 55 items: new_bk_items 56 } 57 } 58 59 function save_info_from_globalx_part(info, part){ 60 info[part] = {} 61 copy_obj_with_part(info, Globalx, part) 62 63 info[part].bookmark_mgr = convert_to_plain_object_from_bookmark_mgr(Globalx[part].bookmark_mgr) 64 } 65 66 function copy_obj_with_part(to_obj, from_obj, part){ 67 /* const items = ["editor_id", "editor", "textarea_sel" , "menu_id", "bookmark_id", "bookmark_op_id", "item_name", "bookmarks", "bookmark_displayname_max_length", "key_indicate_file", "key", "key_sel", "download_sel", "menu_sel", "bookmark_sel", "bookmark_op_sel", "bookmark_mgr" ]*/ 68 const items = ["editor_id", "textarea_sel" , "menu_id", "bookmark_id", "bookmark_op_id", "item_name", "bookmarks", "bookmark_displayname_max_length", "key_sel", "download_sel", "menu_sel", "bookmark_sel", "bookmark_op_sel", "bookmark_mgr" ] 69 const init_value_items = ["editor", "key_indicate_file", "key"] 70 71 if( to_obj[part] === undefined ){ 72 to_obj[part] = {} 73 } 74 copy_object( to_obj[part], from_obj[part], items ) 75 copy_object( to_obj[part], GlobalxInitValue, init_value_items ) 76 } 77 78 function copy_object( to_obj, from_obj, items ){ 79 let x = null 80 items.map( function(item) { 81 x = from_obj[item] 82 to_obj[item] = x 83 } ) 84 } 85 86 function restore_info_to_globalx(){ 87 const info = restore_info() 88 if( info === undefined ){ 89 console.log("call init_globalx()") 90 init_globalx() 91 } 92 else { 93 console.log("call restore_info_to_globalx_with_items") 94 restore_info_to_globalx_with_items(info, _items) 95 } 96 } 97 98 function convert_to_bookmark_mgr_from_plain_object(mgr) { 99 let new_mgr = new BookmarkMgr( mgr.max_display_name_length ) 100 101 const bk_items = mgr.items 102 bk_items.map( function(bk_item) { 103 return new_mgr.add( bk_item.path , bk_item.display_name) 104 }) 105 return new_mgr 106 } 107 108 function restore_info_to_globalx_with_items(info, items){ 109 110 copy_object( Globalx, info, items ) 111 112 info.parts.map( function (part) { 113 restore_info_to_globalx_part(info , part) 114 } ) 115 } 116 117 function restore_info_to_globalx_part(info , part){ 118 info[part].bookmark_mgr = convert_to_bookmark_mgr_from_plain_object(info[part].bookmark_mgr) 119 copy_obj_with_part(Globalx, info, part) 120 } 2 121 3 122 function save_info_to_local_storage(info){ … … 18 137 function get_filelist(num) { 19 138 let num_s = num + '' 20 if( _globalStorage[num_s] === undefined ){ 21 oldData = localStorage.getItem(num_s) 139 return restore_from_localstorage(num_s) 140 } 141 142 143 function restore_info(){ 144 const item_name = "info" 145 return restore_from_localstorage(item_name) 146 } 147 148 function restore_from_localstorage(item_name){ 149 if( _globalStorage[item_name] === undefined ){ 150 oldData = localStorage.getItem(item_name) 22 151 if( oldData ){ 23 _globalStorage[ num_s] = JSON.parse(oldData)152 _globalStorage[item_name] = JSON.parse(oldData) 24 153 } 25 154 } 26 return _globalStorage[ num_s]155 return _globalStorage[item_name] 27 156 } 28 157 158 function reset_info(){ 159 let item_name = 'info' 160 reset_localstorage(item_name) 161 } 162 163 function reset_localstorage(item_name){ 164 delete _globalStorage[item_name] 165 localStorage.removeItem(item_name) 166 } 167 168 function clear_localstorage(){ 169 let keys = Object.keys(_globalStorage) 170 keys.map( (v) => { delete _globalStorage[v] } ) 171 172 localStorage.clear() 173 } -
branches/testa/js/tab.js
r23 r25 1 jQuery(function($){1 function tab_init(){ 2 2 $('.tab').click(function(){ 3 3 $('.is-active').removeClass('is-active'); … … 10 10 // クリックしたタブと同じインデックス番号をもつコンテンツを表示 11 11 $('.panel').eq(index).addClass('is-show'); 12 }) ;13 } );12 }) 13 }
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)