From 46c3042294147466aeaf562ef5d92aa8937a16cb Mon Sep 17 00:00:00 2001 From: Enkumicahel Date: Mon, 26 Jul 2021 09:23:30 +0300 Subject: [PATCH 1/3] some minor changes including added logo and star-bg.js and modification on the webrepl.html for destination of file --- logo.png | Bin 0 -> 4913 bytes stars-bg.js | 27 +++++++++++++++++++++++++++ webrepl.html | 23 ++++++++++++++++------- 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 logo.png create mode 100644 stars-bg.js diff --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..fe3feaa25bbd176b267974b7e3553737557684d8 GIT binary patch literal 4913 zcmeAS@N?(olHy`uVBq!ia0y~yVA%k|94tT)M~!M1AjOjI=FMGaQgQ3;t=+zd6C_$6GIvENNH-i2iwSGwT;T7^ z8M5X8-xME5SNG-#Cyo}rYm_?4sP=_PA3E4U%MMxn66eX+(DMUb8v71DyB2c6eGzm!&C}xoyj$|EnMMzk@N*{)SH(?1;NUOKVSZA#_ZpNASJ z3PyxjpY9f9NQnJ+khHu_RH{LWq0s~ZPg*E(O;my)LJ?AC1DTJMevqs~QiPP*XcCo! zBfgO`8&P?iWf~`GjLp>QTODhEY;BiCs})w4t?LaH5!s*FjE zZ=@m&q!r0JB$H4SjkbAV$rCBC21(oy5rIe*)u1R=X;LqeoELFN<^HQij29-9@n!D^ zcIq1Hmrm{zY`FWRQ(zD@yn#8iA!>^c14GCz&-&zjPmPWPli`gz{>s}k@-6SLJMhVc z14l;`sa-PYT8~KO4lq`bV-hKnNL7SVf(?RPg1yE%;FmR%fni0-r2gKY)3yOScV!0` zbA~+~EQt*%sSu79QbQaRqu3)D$)tfPybiqk#r9L$Gj{)fA8p{cl4^--L`h0wNvc(H zQ7VvPFfuT-)HSfwH8Kn_GOz+76C-T{11kfATbCYNqiD#@PsvQH#I0d Send a file + Destination path +
@@ -85,6 +86,7 @@ var connected = false; var binary_state = 0; var put_file_name = null; +var put_file_path = null; var put_file_data = null; var get_file_name = null; var get_file_data = null; @@ -273,7 +275,9 @@ function put_file() { var dest_fname = put_file_name; + var dest_fpath = document.getElementById('put_filepath').value; var dest_fsize = put_file_data.length; + var dest_full_fname = dest_fpath + '/' + dest_fname; // WEBREPL_FILE = "<2sBBQLH64s" var rec = new Uint8Array(2 + 1 + 1 + 8 + 4 + 2 + 64); @@ -281,12 +285,17 @@ rec[1] = 'A'.charCodeAt(0); rec[2] = 1; // put rec[3] = 0; - rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; rec[10] = 0; rec[11] = 0; - rec[12] = dest_fsize & 0xff; rec[13] = (dest_fsize >> 8) & 0xff; rec[14] = (dest_fsize >> 16) & 0xff; rec[15] = (dest_fsize >> 24) & 0xff; - rec[16] = dest_fname.length & 0xff; rec[17] = (dest_fname.length >> 8) & 0xff; + rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; + rec[10] = 0; rec[11] = 0; + rec[12] = dest_fsize & 0xff; + rec[13] = (dest_fsize >> 8) & 0xff; + rec[14] = (dest_fsize >> 16) & 0xff; + rec[15] = (dest_fsize >> 24) & 0xff; + rec[16] = dest_full_fname.length & 0xff; + rec[17] = (dest_full_fname.length >> 8) & 0xff; for (var i = 0; i < 64; ++i) { - if (i < dest_fname.length) { - rec[18 + i] = dest_fname.charCodeAt(i); + if (i < dest_full_fname.length) { + rec[18 + i] = dest_full_fname.charCodeAt(i); } else { rec[18 + i] = 0; } @@ -365,4 +374,4 @@ - + \ No newline at end of file From 4dbeba7c0a606dc94ad7ebb8e73e1e9918bf8439 Mon Sep 17 00:00:00 2001 From: Enkumicahel Date: Fri, 30 Jul 2021 12:39:25 +0300 Subject: [PATCH 2/3] added multiple file sending option --- webrepl.html | 113 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 41 deletions(-) diff --git a/webrepl.html b/webrepl.html index bf45f2e..a47de77 100644 --- a/webrepl.html +++ b/webrepl.html @@ -56,10 +56,14 @@
Send a file - + + Destination path + +
+
@@ -90,6 +94,8 @@ var put_file_data = null; var get_file_name = null; var get_file_data = null; +var put_file_names_list = []; +var put_files_data_list = []; function calculate_size(win) { var cols = Math.max(80, Math.min(150, (win.innerWidth - 280) / 7)) | 0; @@ -248,6 +254,8 @@ console.log('GET_VER', data); binary_state = 0; break; + default: + console.log('default: \nbinary_state ' + binary_state) } } term.write(event.data); @@ -273,38 +281,49 @@ } } +var counter = 0; function put_file() { - var dest_fname = put_file_name; - var dest_fpath = document.getElementById('put_filepath').value; - var dest_fsize = put_file_data.length; - var dest_full_fname = dest_fpath + '/' + dest_fname; - - // WEBREPL_FILE = "<2sBBQLH64s" - var rec = new Uint8Array(2 + 1 + 1 + 8 + 4 + 2 + 64); - rec[0] = 'W'.charCodeAt(0); - rec[1] = 'A'.charCodeAt(0); - rec[2] = 1; // put - rec[3] = 0; - rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; - rec[10] = 0; rec[11] = 0; - rec[12] = dest_fsize & 0xff; - rec[13] = (dest_fsize >> 8) & 0xff; - rec[14] = (dest_fsize >> 16) & 0xff; - rec[15] = (dest_fsize >> 24) & 0xff; - rec[16] = dest_full_fname.length & 0xff; - rec[17] = (dest_full_fname.length >> 8) & 0xff; - for (var i = 0; i < 64; ++i) { - if (i < dest_full_fname.length) { - rec[18 + i] = dest_full_fname.charCodeAt(i); - } else { - rec[18 + i] = 0; + setTimeout(function() { + if (counter < put_file_names_list.length) { + console.log(put_file_names_list[counter], put_files_data_list[counter], counter, put_files_data_list[counter].length) + put_file_name = put_file_names_list[counter]; + put_file_data = put_files_data_list[counter]; + + var dest_fname = put_file_name; + var dest_fpath = document.getElementById('put_filepath').value; + var dest_fsize = put_file_data.length; + var dest_full_fname = dest_fpath + '/' + dest_fname; + + // WEBREPL_FILE = "<2sBBQLH64s" + var rec = new Uint8Array(2 + 1 + 1 + 8 + 4 + 2 + 64); + rec[0] = 'W'.charCodeAt(0); + rec[1] = 'A'.charCodeAt(0); + rec[2] = 1; // put + rec[3] = 0; + rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; + rec[10] = 0; rec[11] = 0; + rec[12] = dest_fsize & 0xff; + rec[13] = (dest_fsize >> 8) & 0xff; + rec[14] = (dest_fsize >> 16) & 0xff; + rec[15] = (dest_fsize >> 24) & 0xff; + rec[16] = dest_full_fname.length & 0xff; + rec[17] = (dest_full_fname.length >> 8) & 0xff; + for (var i = 0; i < 64; ++i) { + if (i < dest_full_fname.length) { + rec[18 + i] = dest_full_fname.charCodeAt(i); + } else { + rec[18 + i] = 0; + } + } + // initiate put + binary_state = 11; + update_file_status('Sending ' + put_file_name + '...'); + ws.send(rec); + counter++; + put_file() } - } - - // initiate put - binary_state = 11; - update_file_status('Sending ' + put_file_name + '...'); - ws.send(rec); + }, 3000); + // counter = 0 } function get_file() { @@ -353,16 +372,28 @@ // but we only support single file selection at the moment. var files = evt.target.files; - // Get the file info and load its data. - var f = files[0]; - put_file_name = f.name; - var reader = new FileReader(); - reader.onload = function(e) { - put_file_data = new Uint8Array(e.target.result); - document.getElementById('put-file-list').innerHTML = '' + escape(put_file_name) + ' - ' + put_file_data.length + ' bytes'; - document.getElementById('put-file-button').disabled = false; - }; - reader.readAsArrayBuffer(f); + // addition for multiple file support + // setTimeout(setupReader(files[i]), 3000) + // console.log('put_file_data', put_file_data) + // for (var i = files.length - 1; i >= 0; i--) { + for (let i = 0; i < files.length; i++) { + // Get the file info and load its data. + counter = 0 + var f = files[i]; + // put_file_name = f.name; + put_file_names_list.push(f.name); + var reader = new FileReader(); + reader.onload = function(e) { + // put_file_data = new Uint8Array(e.target.result); + put_files_data_list.push(new Uint8Array(e.target.result)) + // document.getElementById('put-file-list').innerHTML = '' + escape(put_file_name) + ' - ' + put_file_data.length + ' bytes'; + document.getElementById('put-file-list').innerHTML = '' + escape(put_file_names_list[i]) + ' - ' + put_files_data_list[i].length + ' bytes'; + document.getElementById('put-file-button').disabled = false; + }; + reader.readAsArrayBuffer(f); + } + // console.log(put_file_names_list) + // console.log(put_files_data_list) } document.getElementById('put-file-select').addEventListener('click', function(){ From cb6ad44bfeb3e91ca0113d02f8de3d7acd6dd9b6 Mon Sep 17 00:00:00 2001 From: Enkumicahel Date: Wed, 4 Aug 2021 12:03:29 +0300 Subject: [PATCH 3/3] some modification on the globals and timing while sending --- webrepl.html | 101 +++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/webrepl.html b/webrepl.html index a47de77..7c5d2f6 100644 --- a/webrepl.html +++ b/webrepl.html @@ -255,7 +255,7 @@ binary_state = 0; break; default: - console.log('default: \nbinary_state ' + binary_state) + console.log('default: \nbinary_state ' + binary_state) } } term.write(event.data); @@ -281,49 +281,57 @@ } } -var counter = 0; +var counter = 0; +var delayTime = 0; + function put_file() { - setTimeout(function() { - if (counter < put_file_names_list.length) { - console.log(put_file_names_list[counter], put_files_data_list[counter], counter, put_files_data_list[counter].length) - put_file_name = put_file_names_list[counter]; - put_file_data = put_files_data_list[counter]; - - var dest_fname = put_file_name; - var dest_fpath = document.getElementById('put_filepath').value; - var dest_fsize = put_file_data.length; - var dest_full_fname = dest_fpath + '/' + dest_fname; - - // WEBREPL_FILE = "<2sBBQLH64s" - var rec = new Uint8Array(2 + 1 + 1 + 8 + 4 + 2 + 64); - rec[0] = 'W'.charCodeAt(0); - rec[1] = 'A'.charCodeAt(0); - rec[2] = 1; // put - rec[3] = 0; - rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; - rec[10] = 0; rec[11] = 0; - rec[12] = dest_fsize & 0xff; - rec[13] = (dest_fsize >> 8) & 0xff; - rec[14] = (dest_fsize >> 16) & 0xff; - rec[15] = (dest_fsize >> 24) & 0xff; - rec[16] = dest_full_fname.length & 0xff; - rec[17] = (dest_full_fname.length >> 8) & 0xff; - for (var i = 0; i < 64; ++i) { - if (i < dest_full_fname.length) { - rec[18 + i] = dest_full_fname.charCodeAt(i); - } else { - rec[18 + i] = 0; - } + setTimeout(function() { + put_file_name = put_file_names_list[counter]; + put_file_data = put_files_data_list[counter]; + delayTime = Math.floor(put_file_data.length/2); + console.log(counter, delayTime) + + var dest_fname = put_file_name; + var dest_fpath = document.getElementById('put_filepath').value; + var dest_fsize = put_file_data.length; + var dest_full_fname = dest_fpath + '/' + dest_fname; + + // WEBREPL_FILE = "<2sBBQLH64s" + var rec = new Uint8Array(2 + 1 + 1 + 8 + 4 + 2 + 64); + rec[0] = 'W'.charCodeAt(0); + rec[1] = 'A'.charCodeAt(0); + rec[2] = 1; // put + rec[3] = 0; + rec[4] = 0; rec[5] = 0; rec[6] = 0; rec[7] = 0; rec[8] = 0; rec[9] = 0; + rec[10] = 0; rec[11] = 0; + rec[12] = dest_fsize & 0xff; + rec[13] = (dest_fsize >> 8) & 0xff; + rec[14] = (dest_fsize >> 16) & 0xff; + rec[15] = (dest_fsize >> 24) & 0xff; + rec[16] = dest_full_fname.length & 0xff; + rec[17] = (dest_full_fname.length >> 8) & 0xff; + for (var i = 0; i < 64; ++i) { + if (i < dest_full_fname.length) { + rec[18 + i] = dest_full_fname.charCodeAt(i); + } else { + rec[18 + i] = 0; } - // initiate put - binary_state = 11; - update_file_status('Sending ' + put_file_name + '...'); - ws.send(rec); - counter++; + } + // initiate put + binary_state = 11; + update_file_status('Sending ' + put_file_name + '...'); + ws.send(rec); + + counter++; + if(counter < put_file_names_list.length){ put_file() } - }, 3000); - // counter = 0 + else if(counter == put_file_names_list.length){ + counter = 0 + delayTime = 0 + } + + }, delayTime); } function get_file() { @@ -373,12 +381,8 @@ var files = evt.target.files; // addition for multiple file support - // setTimeout(setupReader(files[i]), 3000) - // console.log('put_file_data', put_file_data) - // for (var i = files.length - 1; i >= 0; i--) { for (let i = 0; i < files.length; i++) { // Get the file info and load its data. - counter = 0 var f = files[i]; // put_file_name = f.name; put_file_names_list.push(f.name); @@ -388,16 +392,19 @@ put_files_data_list.push(new Uint8Array(e.target.result)) // document.getElementById('put-file-list').innerHTML = '' + escape(put_file_name) + ' - ' + put_file_data.length + ' bytes'; document.getElementById('put-file-list').innerHTML = '' + escape(put_file_names_list[i]) + ' - ' + put_files_data_list[i].length + ' bytes'; - document.getElementById('put-file-button').disabled = false; + if(i === files.length-1){ + document.getElementById('put-file-button').disabled = false; + } }; reader.readAsArrayBuffer(f); } - // console.log(put_file_names_list) - // console.log(put_files_data_list) } document.getElementById('put-file-select').addEventListener('click', function(){ this.value = null; + document.getElementById('put-file-button').disabled = true; + put_file_names_list = [] + put_files_data_list = [] }, false); document.getElementById('put-file-select').addEventListener('change', handle_put_file_select, false);