Add NG3K DXpedition calendar #17

This commit is contained in:
Ian Renton
2025-10-09 17:03:42 +01:00
parent 277743dac7
commit b27d0f826c
6 changed files with 103 additions and 16 deletions

View File

@@ -108,10 +108,10 @@ function saveSettings() {
// Find all storeable UI elements, store a key of "element id:property name" mapped to the value of that
// property. For a checkbox, that's the "checked" property.
$(".storeable-checkbox").each(function() {
localStorage.setItem($(this)[0].id + ":checked", $(this)[0].checked);
localStorage.setItem("#" + $(this)[0].id + ":checked", $(this)[0].checked);
});
$(".storeable-select").each(function() {
localStorage.setItem($(this)[0].id + ":value", $(this)[0].value);
localStorage.setItem("#" + $(this)[0].id + ":value", $(this)[0].value);
});
}
@@ -119,8 +119,10 @@ function saveSettings() {
function loadSettings() {
// Find all local storage entries and push their data to the corresponding UI element
Object.keys(localStorage).forEach(function(key) {
// Split the key back into an element ID and a property
var split = key.split(":");
$("#" + split[0]).prop(split[1], JSON.parse(localStorage.getItem(key)));
if (key.startsWith("#") && key.includes(":")) {
// Split the key back into an element ID and a property
var split = key.split(":");
$(split[0]).prop(split[1], JSON.parse(localStorage.getItem(key)));
}
});
}