Simplify code a bit

This commit is contained in:
Lewis Dale 2023-09-27 19:07:35 +01:00
parent ad751e11f5
commit aec7a6d227

View File

@ -71,9 +71,6 @@
set: (obj, key, value) => { set: (obj, key, value) => {
obj[key] = value; obj[key] = value;
localStorage.setItem(key, value); localStorage.setItem(key, value);
document.querySelectorAll(`[type="radio"][name="${key}"]`).forEach(radio => {
radio.checked = radio.value === value;
});
document.body.setAttribute(`data-${key}`, value); document.body.setAttribute(`data-${key}`, value);
return true; return true;
@ -88,7 +85,7 @@
radio.addEventListener('change', onRadioChange); radio.addEventListener('change', onRadioChange);
radio.checked = data[radio.name] == radio.value; radio.checked = data[radio.name] == radio.value;
}); });
document.body.setAttribute(`data-color-scheme`, data['color-scheme']); document.body.setAttribute(`data-color-scheme`, localStorage.getItem('color-scheme'));
</script> </script>
</body> </body>
</html> </html>