mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
UpdateSettingItemVisibility() now works recursively
This commit is contained in:
@@ -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';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user