UpdateSettingItemVisibility() now works recursively

This commit is contained in:
nuttylmao
2025-08-25 20:44:19 +10:00
parent c045c502c2
commit 84fe98bee4
+17 -4
View File
@@ -227,10 +227,23 @@ function LoadJSON(settingsJson) {
function UpdateSettingItemVisibility() { function UpdateSettingItemVisibility() {
data.settings.forEach(setting => { data.settings.forEach(setting => {
if (setting.showIf) { if (setting.showIf) {
if (!document.getElementById(setting.showIf).checked) const parentElement = document.getElementById(setting.showIf);
document.getElementById(`item-${setting.id}`).style.display = 'none' let shouldShow = true;
else
document.getElementById(`item-${setting.id}`).style.display = 'flex' // Walk up the chain of showIf dependencies
let currentSetting = setting;
while (currentSetting.showIf) {
const parentInput = document.getElementById(currentSetting.showIf);
if (!parentInput || !parentInput.checked) {
shouldShow = false;
break;
}
// Find the parent setting object (to keep walking up)
currentSetting = data.settings.find(s => s.id === currentSetting.showIf) || {};
}
document.getElementById(`item-${setting.id}`).style.display = shouldShow ? 'flex' : 'none';
} }
}); });
} }