2021-12-22 16:29:48 -08:00
|
|
|
import {createDeleteEvent, createSubmitEvent} from "retrospring/features/settings/mute";
|
2021-12-22 16:20:47 -08:00
|
|
|
|
|
|
|
export default (): void => {
|
|
|
|
const submit: HTMLButtonElement = document.getElementById('new-rule-submit') as HTMLButtonElement;
|
|
|
|
if (submit.classList.contains('js-initialized')) return;
|
|
|
|
|
|
|
|
const rulesList = document.querySelector<HTMLDivElement>('.js-rules-list');
|
2021-12-22 16:29:48 -08:00
|
|
|
rulesList.querySelectorAll<HTMLDivElement>('.form-group:not(.js-initalized)').forEach(entry => {
|
|
|
|
const button = entry.querySelector('button')
|
|
|
|
button.onclick = createDeleteEvent(entry, button)
|
2021-12-22 16:32:59 -08:00
|
|
|
});
|
2021-12-22 16:20:47 -08:00
|
|
|
const textEntry: HTMLButtonElement = document.getElementById('new-rule-text') as HTMLButtonElement;
|
|
|
|
const template: HTMLTemplateElement = document.getElementById('rule-template') as HTMLTemplateElement;
|
|
|
|
|
|
|
|
submit.form.onsubmit = createSubmitEvent(submit, rulesList, textEntry, template)
|
|
|
|
|
|
|
|
submit.classList.add('js-initialized')
|
|
|
|
}
|