import Dialog from "./Dialog.js"; import TilorswiftEffectsUpdatedEvent from "../events/TilorswiftEffectsUpdatedEvent.js"; export default class DialogEffects extends Dialog { constructor(effects, checked, translations) { super(); this.setMessage('Effekte'); this.effects = []; for (const effect of effects) { const checkbox = this.createCheckbox( translations[effect], effect, checked.indexOf(effect) !== -1, () => { console.log(checkbox.name, 'is', checkbox.isChecked()); } ); this.effects.push(checkbox); this.inputAreaElement.appendChild(checkbox.htmlElement); } this.createButton('Abbrechen'); this.buttonOk = this.createButton('OK'); this.buttonOk.addEventListener( 'click', () => { const effectNames = []; for (const effect of this.effects) { if (effect.isChecked()) { effectNames.push(effect.name); } } window.dispatchEvent( new TilorswiftEffectsUpdatedEvent(effectNames) ); } ) } }