From 57d618a3e0ec5a1f725f49bf455fea2f1701146e Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 21 Nov 2019 09:39:35 -0500 Subject: [PATCH] changing state select dropdown activates state --- static/juice.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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 */