diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 35a4447287a6db60bdef07716453ebbe4df38c4c..ee703333a6b3de27d556331ed98823b026b4e3e8 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -19,20 +19,23 @@ window.addEventListener("load", () => { for (const op of document.querySelectorAll('.option .preview')) { console.debug(op); const input_id = (op as HTMLElement).dataset.for; - if (!input_id) { - console.error("Missing data-for attribute for", op); - continue; - } - const input = document.getElementById(input_id); - if (!input || input === null) { - console.error("Unable to find input for", op); - continue; - } + let handler: (_: Event) => void; + if (input_id) { + const input = document.getElementById(input_id); + if (!input || input === null) { + console.error("Unable to find input for", op); + continue; + } - const handler = (_: Event) => { - console.log("clicked"); - (input as HTMLInputElement).checked = true; - }; + handler = (_: Event) => { + (input as HTMLInputElement).checked = true; + } + } else { + const p = (op as HTMLElement).parentNode; + handler = (_: Event) => { + window.location.href = (p as HTMLAnchorElement).href; + } + } op.addEventListener('click', handler); (op as HTMLIFrameElement).contentDocument?.addEventListener('click', handler); }