import Dialog from "../../tilorswift/js/dialog/Dialog.js"; export class LoadLevelDialog extends Dialog { constructor() { super(); this.setMessage('Level laden'); this.fileInput = this.createFileInput(['json']); this.fileInput.addEventListener( 'change', () => { if (this.fileInput.files.length === 0) { return; } const reader = new FileReader(); reader.addEventListener( 'load', (event) => { this.onClose(); this.onLoad(event.target.result); } ) reader.readAsBinaryString(this.fileInput.files[0]); } ) this.onClose = () => {}; this.onLoad = () => {}; this.buttonCancel = this.createButton('Abbrechen'); this.buttonCancel.addEventListener( 'click', () => { this.onClose(); } ); } openFileBrowser() { this.fileInput.click(); } }