mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-12 01:01:32 -04:00
Stores inputs in memory instead of in textareas.
Allow selecting multiple files. Allow drag and dropping multiple files. Clear all IO button will close all tabs. Will now spawn multiple loaderworkers simultaneously. Improve tab logic to break less and work in Firefox.
This commit is contained in:
parent
37218c1e81
commit
c0c83c5cdc
5 changed files with 300 additions and 230 deletions
|
@ -12,8 +12,10 @@
|
|||
*/
|
||||
self.addEventListener("message", function(e) {
|
||||
const r = e.data;
|
||||
if (r.hasOwnProperty("file")) {
|
||||
self.loadFile(r.file);
|
||||
if (r.hasOwnProperty("file") && (r.hasOwnProperty("inputNum"))) {
|
||||
self.loadFile(r.file, r.inputNum);
|
||||
} else if (r.hasOwnProperty("file")) {
|
||||
self.loadFile(r.file, "");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -22,8 +24,9 @@ self.addEventListener("message", function(e) {
|
|||
* Loads a file object into an ArrayBuffer, then transfers it back to the parent thread.
|
||||
*
|
||||
* @param {File} file
|
||||
* @param {string} inputNum
|
||||
*/
|
||||
self.loadFile = function(file) {
|
||||
self.loadFile = function(file, inputNum) {
|
||||
const reader = new FileReader();
|
||||
const data = new Uint8Array(file.size);
|
||||
let offset = 0;
|
||||
|
@ -31,11 +34,11 @@ self.loadFile = function(file) {
|
|||
|
||||
const seek = function() {
|
||||
if (offset >= file.size) {
|
||||
self.postMessage({"progress": 100});
|
||||
self.postMessage({"fileBuffer": data.buffer}, [data.buffer]);
|
||||
self.postMessage({"progress": 100, "inputNum": inputNum});
|
||||
self.postMessage({"fileBuffer": data.buffer, "inputNum": inputNum}, [data.buffer]);
|
||||
return;
|
||||
}
|
||||
self.postMessage({"progress": Math.round(offset / file.size * 100)});
|
||||
self.postMessage({"progress": Math.round(offset / file.size * 100), "inputNum": inputNum});
|
||||
const slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||
reader.readAsArrayBuffer(slice);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue