mirror of
https://github.com/tlsnotary/PageSigner.git
synced 2026-01-08 22:27:57 -05:00
- implement garbled row reduction GRR3 for 25% bandwidth saving - implement KOS15 OT extension - linting
36 lines
1.1 KiB
JavaScript
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
|
|
}
|
|
} |