Changeset 36 for branches/testa-single-bookmark/js/remotex.js
- Timestamp:
- Aug 26, 2019 6:15:44 PM (6 years ago)
- File:
-
- 1 edited
-
branches/testa-single-bookmark/js/remotex.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/testa-single-bookmark/js/remotex.js
r29 r36 3 3 constructor( filename ){ 4 4 this.filename = filename 5 // this.num = num6 // this.part = part5 // this.num = num 6 // this.part = part 7 7 } 8 8 … … 17 17 18 18 async get_filelist_from_remote( num, part, func ) { 19 console.log("remotex get_filelist_from_remote num=" + num + " part=" + part )19 console.log("remotex get_filelist_from_remote num=" + num + " part=" + part ) 20 20 let param_array = [['cmd', 'get_filelistx'], ['num', num ], ['part', part ]] 21 21 await this.fetchx( this.filename , param_array, func ) … … 23 23 24 24 async update_filelist( num, part, func ) { 25 console.log("remotex update_filelist num=" + num + " part=" + part )25 console.log("remotex update_filelist num=" + num + " part=" + part ) 26 26 let param_array = [['cmd', 'update_filelistx'], ['num', num ], ['part', part ]] 27 27 await this.fetchx( this.filename , param_array, func ) … … 29 29 30 30 async get_content(num, part, path , func) { 31 console.log("remotex get_content num=" + num + " part=" + part )31 console.log("remotex get_content num=" + num + " part=" + part ) 32 32 console.log("part=" + part) 33 33 let param_array = [['cmd', 'get_content'], ['num', num ], ['part', part ], ['path', path]] … … 35 35 } 36 36 37 async get_output_url(num, func) { 38 console.log("get_output_url") 39 console.log("remotex get_output_url num=" + num ) 40 let param_array = [['cmd', 'get_output_url'], ['num', num ] ] 41 await this.fetchx( this.filename , param_array, func ) 42 } 43 37 44 async fetchx( filename, param_array, func) { 45 console.log("fetchx func" + func) 38 46 let params = this.make_url_params( param_array ) 39 47 fetch(`${filename}?${params}`) 40 48 .then((response) => response.text()) 41 .then((text) => { console.log(func) ; func(text)}) 49 .then((text) => { console.log(func) ; if( func !== undefined ){func(text)} else { console.log("func=undefined")} }) 50 .catch((error) => console.log(error)); 51 } 52 53 upload_to_host(part) { 54 if( Globalx[part].key_indicate_file === true ){ 55 let textarea = $( Globalx[part].textarea_sel ) 56 upload_content(Globalx.num, part, Globalx[part].key, textarea.val()) 57 } 58 } 59 60 upload_content(num, part, path, content) { 61 let form = document.createElement('form'); 62 let req_content = document.createElement('input'); 63 let req_path = document.createElement('input'); 64 let req_cmd = document.createElement('input'); 65 let req_num = document.createElement('input'); 66 67 document.body.appendChild(form); 68 req_content.type = 'hidden'; 69 req_content.name = 'mytext'; 70 req_content.value = content; 71 72 req_path.type = 'hidden'; 73 req_path.name = 'path'; 74 req_path.value = path; 75 76 req_cmd.type = 'hidden'; 77 req_cmd.name = 'cmd'; 78 req_cmd.value = 'upload_content'; 79 80 req_num.type = 'hidden'; 81 req_num.name = 'num'; 82 req_num.value = num + ''; 83 84 form.appendChild(req_content); 85 form.appendChild(req_path); 86 form.appendChild(req_cmd); 87 form.appendChild(req_num); 88 89 // FormDataオブジェクトを作成する 90 var form_data = new FormData(form); 91 92 fetch('php/content.php', { 93 method: 'POST', 94 mode: 'same-origin', /* 'no-cors' 'cors' 'same-origin' */ 95 body: form_data 96 }) 97 .then((response) => response.text()) 98 .then((data) => console.log(data)) 42 99 .catch((error) => console.log(error)); 43 100 } 44 101 45 102 handleDownload(e) { 46 let dl = document.getElementById( "data-down-download")103 let dl = document.getElementById(`${e.data.part}-down-download`) 47 104 48 105 if( Globalx[ e.data.part ].key_indicate_file === true ){
Note: See TracChangeset
for help on using the changeset viewer.
![(trac.ini の [header_logo] セクションを設定してください)](/python/trac/Flist/chrome/common/trac_logo_mini.png)