diff --git a/static/juice.js b/static/juice.js index df52676..275310d 100644 --- a/static/juice.js +++ b/static/juice.js @@ -338,8 +338,7 @@ function state_solid_amount(radio) { } function state_select(select) { - let device = select.parentElement.parentElement.parentElement; - let sub_devices = device.querySelector('.sub_devices'); + let device = select.closest('.device'); if (select.value === 'solid') { select.parentElement.querySelector('.state_solid').style.display = 'block'; select.parentElement.querySelector('.state_rainbow').style.display = 'none'; @@ -348,19 +347,17 @@ function state_select(select) { select.parentElement.querySelector('.state_solid').style.display = 'none'; select.parentElement.querySelector('.state_rainbow').style.display = 'block'; select.parentElement.querySelector('.state_america').style.display = 'none'; - for (let sub_device of sub_devices.children) { - let input = sub_device.firstElementChild.firstElementChild; - input.disabled = true; - } } else if (select.value === 'america') { select.parentElement.querySelector('.state_solid').style.display = 'none'; select.parentElement.querySelector('.state_rainbow').style.display = 'none'; select.parentElement.querySelector('.state_america').style.display = 'block'; - for (let sub_device of sub_devices.children) { - let input = sub_device.firstElementChild.firstElementChild; - input.disabled = true; - } } + let sub_devices = device.querySelector('.sub_devices'); + for (let sub_device of sub_devices.children) { + let input = sub_device.firstElementChild.firstElementChild; + input.disabled = true; + } + neopixel_state(device); } /* Misc */