summaryrefslogtreecommitdiff
path: root/public/static/scripts/options.js
blob: 7e4b4e4bc15b5fc5fec7efc2894ea58e54dd8b28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
let options = JSON.parse(localStorage.getItem('options') ?? '{}');

const checkboxes = document.querySelectorAll('input[type=checkbox]');

checkboxes.forEach((c) => {
    const id = c.getAttribute('name');

    c.addEventListener('change', () => {
        options[id] = c.checked;
        localStorage.setItem('options', JSON.stringify(options));
    });

    if (options[id] !== undefined) {
        c.checked = options[id];
    }
});