Changeset 41
- Timestamp:
- Aug 30, 2019 7:54:52 AM (6 years ago)
- Location:
- branches/testa-single-bookmark
- Files:
-
- 4 added
- 5 edited
-
bin (added)
-
bin/a.sh (added)
-
bin/b.sh (added)
-
bin/build.sh (added)
-
js/bookmarkmenu.js (modified) (9 diffs)
-
js/main.js (modified) (6 diffs)
-
js/remotex.js (modified) (5 diffs)
-
js/sidemenu.js (modified) (7 diffs)
-
js/storagex.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa-single-bookmark/js/bookmarkmenu.js
r36 r41 6 6 7 7 dlg(){ 8 console.log("BookmarkMenu dlg()")9 8 $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx.bookmark_displayname_max_length) 10 9 $('#bookmarkDlg').dialog({ … … 30 29 add_bookmark() { 31 30 let part = Globalx.parts[ Globalx.index ] 32 console.log("add_bookmark part=" + part)33 31 $( '#bookmark_displayname' ).val( this.bookmark_mgr.get_restricted_display_name( Globalx[part].key ) ) 34 32 $( '#bookmark_path' ).val( Globalx[part].key ) … … 38 36 remove_bookmark() { 39 37 let part = Globalx.parts[ Globalx.index ] 40 console.log("remove_bookmark part=" + part)41 38 this.bookmark_mgr.remove( part, Globalx[part].key ) 42 39 this.rebuild_bookmark_menu(part) … … 46 43 let part = Globalx.parts[ Globalx.index ] 47 44 let bookmark_op_sel = Globalx[part].bookmark_op_sel 48 console.log("bookmark_op part=" + part + " bookmark_op_sel=" + bookmark_op_sel)49 45 if( $( bookmark_op_sel ).is(':checked') == true ){ 50 46 this.add_bookmark() … … 58 54 let bookmark_op_sel = Globalx[part].bookmark_op_sel 59 55 60 console.log( "set_click_handler() part=" + part + " bookmark_op_sel=" + bookmark_op_sel )61 56 $( bookmark_op_sel ).on( 'click' , () => { 62 57 console.log("bookmark_op_sel clicked") … … 74 69 let num = Globalx.num 75 70 let bookmark_sel = Globalx[part].bookmark_sel 76 console.log("BookmarkMenu rebuld_bookmark_menu num="+num+ " part="+part)77 71 $( bookmark_sel ).empty() 78 72 79 73 const array = this.bookmark_mgr.get_paths(part) 80 console.log("BookmarkMenu rebuld_bookmark_menu array=" + array )81 74 82 75 let content = null … … 88 81 $( bookmark_sel ).append( content ); 89 82 console.log( "bookmark_sel="+bookmark_sel) 90 item = $( bookmark_sel ). last()83 item = $( bookmark_sel ).children().last() 91 84 console.log( "item=" + item ) 92 85 item.on('click' , () => { … … 105 98 } 106 99 107 bookmark_action = ( part, key ) =>{100 bookmark_action ( part, key ) { 108 101 if( key === null || key === "" ){ 109 102 alert("illeagal key=" + key ) … … 121 114 122 115 $( Globalx[part].key_sel ).val( key ) 123 console.log("jsondata=" + jsondata)124 116 if( jsondata[key].length == 0 ){ 125 117 Globalx[part].key_indicate_file = true; -
branches/testa-single-bookmark/js/main.js
r36 r41 10 10 function init_globalx_storagex() { 11 11 Globalx.storagex = new Storagex(); 12 Globalx.build = { 13 'contest2011.md': { 14 path: '/attempt/contest2011/data/contest2011.md', 15 target: 'cont', 16 subtarget: '2011', 17 category: 'attempt', 18 output_html: 'contest2011.html', 19 alias_html: 'contest.html', 20 } 21 } 22 12 23 } 24 13 25 14 26 function init_globalx() { 15 27 Globalx.num = 0 16 28 Globalx.index = 0 17 Globalx.parts = ["data" , "output", "setting"]29 Globalx.parts = ["data" , "output", "setting"] 18 30 Globalx.bookmark_displayname_max_length = 18 19 31 Globalx.output_url = null 32 Globalx.remote_filename = 'php/content3.php' 33 Globalx.build = new Build() 20 34 21 35 tab_init() 22 36 topmenu_init() 23 Globalx.remotex = new Remotex('php/content.php') 24 console.log( "init_globalx 1 : Globalx.bookmark_mgr=" + Globalx.bookmark_mgr ) 37 Globalx.remotex = new Remotex( Globalx.remote_filename ) 25 38 if( Globalx.bookmark_mgr === null || Globalx.bookmark_mgr === undefined ){ 26 39 Globalx.bookmark_mgr = new BookmarkMgr(Globalx.bookmark_displayname_max_length, Globalx.parts) 27 40 } 28 console.log( "init_globalx 2 : Globalx.bookmark_mgr=" + Globalx.bookmark_mgr )29 41 Globalx.bookmarkmenu = null 42 43 Globalx.build.setup() 30 44 } 31 45 32 async function get_output_url_async( func ){ 46 async function update_all_filelist( ) { 47 Globalx.parts.map( ( part ) => { 48 Globalx[ part ].sidemenu.update(`#${part}-side`) 49 } ) 50 } 51 52 async function get_output_url_async( num, func ){ 33 53 let realData = Globalx.storagex.get_output_url() 34 54 35 55 if( realData === undefined || realData === null ){ 36 await Globalx.remotex.get_output_url( func )56 await Globalx.remotex.get_output_url( num, func ) 37 57 } 38 58 else{ 39 const obj = Globalx.storagex.get_output_url( num , part)59 const obj = Globalx.storagex.get_output_url( num ) 40 60 Globalx.output_url = obj.output_url 41 61 Globalx.storagex.save_as_info_from_globalx() … … 44 64 45 65 async function setup(){ 46 get_output_url_async( (text) => {66 get_output_url_async( Globalx.num, (text) => { 47 67 let str = text 48 68 let obj … … 65 85 setup() 66 86 67 console.log("##### Globalx.bookmarkmenu=" + Globalx.bookmarkmenu)68 console.log("##### Globalx.bookmark_mgr=" + Globalx.bookmark_mgr)69 87 Globalx.bookmarkmenu = new BookmarkMenu( Globalx.bookmark_displayname_max_length , Globalx.bookmark_mgr ) 70 88 Globalx.bookmarkmenu.dlg() … … 73 91 set_globalx_editor(part) 74 92 93 Globalx[ part ].menu = null 75 94 Globalx[ part ].sidemenu = new SideMenu( Globalx.num, part ) 76 95 Globalx[ part ].sidemenu.setup(`#${part}-side`) … … 84 103 if( need_to_save ){ 85 104 // LocalStorageにまだ保存していない場合、ここで保存しておく 86 //console.log("call save_as_info_from_globalx()")87 105 Globalx.storagex.save_as_info_from_globalx( (data) => { console.log( "data=" + data ) } ) 88 106 } 89 /*90 Object.keys(Globalx).forEach((key) => {91 console.log(key)92 }) */93 107 } 94 108 … … 130 144 131 145 let textarea = $( Globalx[part].textarea_sel ) 132 editor.getSession().on("change", (textarea) => { 133 textarea.val(editor.getSession().getValue()); 146 editor.getSession().on("change", () => { 147 /* textarea.val(editor.getSession().getValue()) */ 148 $( Globalx[part].textarea_sel ).val(editor.getSession().getValue()) 134 149 }); 135 150 } 151 152 function upload_to_host( part ){ 153 Globalx.remotex.upload_to_host( part ) 154 } -
branches/testa-single-bookmark/js/remotex.js
r36 r41 7 7 } 8 8 9 make_url_params ( arrayx ){9 make_url_params0( arrayx ){ 10 10 let params = new URLSearchParams(); 11 11 arrayx.reduce(function(acc, element, index, array) { … … 13 13 return acc; 14 14 }, params) 15 return params; 15 return params.toString(); 16 } 17 18 make_url_params( arrayx , num ){ 19 let params = new URLSearchParams(); 20 for(let i=0; i<num; i++ ){ 21 params.append(arrayx[i][0], arrayx[i][1]) 22 } 23 const pa = params.toString() 24 return pa 16 25 } 17 26 18 27 async get_filelist_from_remote( num, part, func ) { 19 console.log("remotex get_filelist_from_remote num=" + num + " part=" + part )20 28 let param_array = [['cmd', 'get_filelistx'], ['num', num ], ['part', part ]] 21 await this.fetchx( this.filename , param_array, func )29 await this.fetchx( this.filename , param_array, 3, func ) 22 30 } 23 31 24 32 async update_filelist( num, part, func ) { 25 console.log("remotex update_filelist num=" + num + " part=" + part )26 33 let param_array = [['cmd', 'update_filelistx'], ['num', num ], ['part', part ]] 27 await this.fetchx( this.filename , param_array, func )34 await this.fetchx( this.filename , param_array, 3, func ) 28 35 } 29 36 30 37 async get_content(num, part, path , func) { 31 console.log("remotex get_content num=" + num + " part=" + part )32 console.log("part=" + part)33 38 let param_array = [['cmd', 'get_content'], ['num', num ], ['part', part ], ['path', path]] 34 await this.fetchx( this.filename , param_array, func )39 await this.fetchx( this.filename , param_array, 4, func ) 35 40 } 36 41 37 42 async get_output_url(num, func) { 38 console.log("get_output_url")39 console.log("remotex get_output_url num=" + num )40 43 let param_array = [['cmd', 'get_output_url'], ['num', num ] ] 41 await this.fetchx( this.filename , param_array, func )44 await this.fetchx( this.filename , param_array, 2, func ) 42 45 } 43 46 44 async fetchx( filename, param_array, func) { 45 console.log("fetchx func" + func) 46 let params = this.make_url_params( param_array ) 47 async fetchx( filename, param_array, num, func) { 48 let params = this.make_url_params( param_array , num ) 47 49 fetch(`${filename}?${params}`) 48 .then((response) => response.text())49 .then((text) => { console.log(func) ; if( func !== undefined ){func(text)} else { console.log("func=undefined")}})50 .catch((error) => console.log( error));50 .then((response) => { return response.text() }) 51 .then((text) => { func(text) }) 52 .catch((error) => console.log("error=" + error)); 51 53 } 52 54 … … 54 56 if( Globalx[part].key_indicate_file === true ){ 55 57 let textarea = $( Globalx[part].textarea_sel ) 56 upload_content(Globalx.num, part, Globalx[part].key, textarea.val())58 this.upload_content(Globalx.num, part, Globalx[part].key, textarea.val()) 57 59 } 60 } 61 62 async build( cmd, num, part, path, content, func = null ) { 63 await this.upload_file( cmd, num, part, path, content, func = null ) 64 } 65 66 async upload_file(cmd, num, part, path, content, func = null) { 67 let form = document.createElement('form') 68 let req_cmd = document.createElement('input') 69 let req_num = document.createElement('input') 70 let req_part = document.createElement('input') 71 let req_path = document.createElement('input') 72 let req_content = document.createElement('input') 73 74 document.body.appendChild(form) 75 76 req_cmd.type = 'hidden' 77 req_cmd.name = 'cmd' 78 req_cmd.value = cmd 79 80 req_num.type = 'hidden' 81 req_num.name = 'num' 82 req_num.value = num + '' 83 84 req_part.type = 'hidden' 85 req_part.name = 'part' 86 req_part.value = part 87 88 req_path.type = 'hidden' 89 req_path.name = 'path' 90 req_path.value = path 91 92 req_content.type = 'hidden' 93 req_content.name = 'mytext' 94 req_content.value = content 95 96 form.appendChild(req_cmd) 97 form.appendChild(req_num) 98 form.appendChild(req_part) 99 form.appendChild(req_path) 100 form.appendChild(req_content) 101 102 // FormDataオブジェクトを作成する 103 var form_data = new FormData(form); 104 console.log("remotex.js filename=" + this.filename ) 105 fetch( this.filename , { 106 method: 'POST', 107 mode: 'same-origin', /* 'no-cors' 'cors' 'same-origin' */ 108 body: form_data 109 }) 110 .then((response) => { 111 return response.text() 112 }) 113 .then((data) => {console.log( "data=" + data) 114 if( func !== null ){ 115 func(data) 116 } 117 }) 118 .catch((error) => {console.log("error=" + error)}) 58 119 } 59 120 … … 64 125 let req_cmd = document.createElement('input'); 65 126 let req_num = document.createElement('input'); 127 let req_part = document.createElement('input'); 66 128 67 129 document.body.appendChild(form); … … 82 144 req_num.value = num + ''; 83 145 146 req_part.type = 'hidden'; 147 req_part.name = 'part'; 148 req_part.value = part; 149 84 150 form.appendChild(req_content); 85 151 form.appendChild(req_path); 86 152 form.appendChild(req_cmd); 87 153 form.appendChild(req_num); 154 form.appendChild(req_part); 88 155 89 156 // FormDataオブジェクトを作成する 90 157 var form_data = new FormData(form); 91 92 fetch( 'php/content.php', {158 console.log("remotex.js filename=" + this.filename ) 159 fetch( this.filename , { 93 160 method: 'POST', 94 161 mode: 'same-origin', /* 'no-cors' 'cors' 'same-origin' */ 95 162 body: form_data 96 163 }) 97 .then((response) => response.text())98 .then((data) => console.log(data))99 .catch((error) => console.log(error));164 .then((response) => { return response.text()}) 165 .then((data) => {console.log( "data=" + data)}) 166 .catch((error) => {console.log("error=" + error)}); 100 167 } 101 168 -
branches/testa-single-bookmark/js/sidemenu.js
r36 r41 12 12 } 13 13 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({ 35 34 classes: { 36 35 "ui-menu": "highlight" 37 36 } 38 37 }) 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 } ) 40 59 } 41 60 42 61 async get_filelist_async( num , part , func){ 43 if( part == "setting" ){44 console.log( "get_filelist_async START part="+ part)45 }46 62 let realData = Globalx.storagex.get_filelist( num , part ) 47 63 48 if( part == "setting" ){49 console.log( "get_filelist_async 2 part=" + part)50 }51 64 if( realData === undefined || realData === null ){ 52 if( part == "setting" ){53 console.log( "get_filelist_async 3 part=" + part)54 }55 65 await Globalx.remotex.get_filelist_from_remote( num, part, func ) 56 if( part == "setting" ){57 console.log( "get_filelist_async 4 part=" + part)58 }59 66 } 60 67 else{ 61 68 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 ) 68 70 } 69 71 } … … 121 123 if( jsondata[Globalx[part].key].length == 0 ){ 122 124 Globalx[part].key_indicate_file = true; 125 console.log("Globalx[" + part + "].key_indicate_file = " + Globalx[part].key_indicate_file) 123 126 let url = "" 124 127 $( Globalx[part].download_url_sel ).val( Globalx[part].key ) … … 128 131 $( Globalx[part].download_partial_url_sel ).attr('href' , url ) 129 132 Globalx.remotex.get_content( this.num, this.part, Globalx[part].key , (content) => { 130 //console.log("content=" + content)131 133 Globalx[part].editor.getSession().setValue( content ); 132 134 $( Globalx[part].textarea_sel ).val( content ); … … 143 145 let name = '..(Up)' 144 146 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>`;147 147 $( this.menu_sel ).append(content); 148 item = $( this.menu_sel ). last()148 item = $( this.menu_sel ).children().last() 149 149 item.on('click' , () => { 150 150 this.menu_action( key , true ) … … 154 154 ary.map( ( item_name ) => { 155 155 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>`;158 156 $( this.menu_sel ).append(content); 159 item = $( this.menu_sel ). last()157 item = $( this.menu_sel ).children().last() 160 158 item.on('click' , () => { 161 159 this.menu_action( item_name ) … … 165 163 } 166 164 167 set_globalx_item_name( item_name ) {168 Globalx[ this.part].item_name = item_name169 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) 171 169 dl.removeAttr('href') 172 170 } … … 190 188 } 191 189 192 /*193 function menu_action(part, item_name , up_flag = false) {194 Globalx[part].sidemenu.menu_action(item_name , up_flag)195 }196 */ -
branches/testa-single-bookmark/js/storagex.js
r36 r41 216 216 } 217 217 218 reset_info = () => { 219 let item_name = 'info' 220 reset_localstorage(item_name) 218 reset_info() { 219 reset_localstorage('info') 221 220 } 222 221 … … 226 225 } 227 226 228 clear_localstorage = () =>{227 clear_localstorage() { 229 228 let keys = Object.keys(this._globalStorage) 230 229 keys.map( (v) => { delete this._globalStorage[v] } )
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)