Files
PageSigner/ui/FileChooser.js
themighty1 79173c511e - use Salsa20 instead of tweetnacl-js's secretbox for a 30% garbling speedup in the browser.
- implement garbled row reduction GRR3 for 25% bandwidth saving
- implement KOS15 OT extension
- linting
2022-01-17 10:18:04 +03:00

36 lines
1.1 KiB
JavaScript

/* global chrome*/
// class FileChooser create a "choose file" button and sends the chosen file
// to the extension
export class FileChooser{
// show is called by extension's Main.openFileChooser()
show(){
const label = document.getElementById('import_label');
label.style.display = '';
const that = this;
document.getElementById('import').addEventListener('change', function(evt) {
const f = evt.target.files[0];
if (f) {
const reader = new FileReader();
reader.onload = that.onload;
reader.readAsArrayBuffer(f);
}
});
}
onload(e) {
const loader = document.getElementById('loader');
loader.classList.toggle('m-fadeIn');
loader.removeAttribute('hidden');
const import_label = document.getElementById('import_label');
import_label.classList.toggle('m-fadeOut');
chrome.runtime.sendMessage({
'destination': 'extension',
'message': 'import',
'args': {
'data': Array.from(new Uint8Array(e.target.result))
}
});
// don't close the window, we reuse it to display html
}
}