diff options
author | Humberto Alfonso Díaz <humberto.alfonso@asvito.es> | 2019-07-05 14:29:20 +0200 |
---|---|---|
committer | Lorenzo Tilve <ltilve@igalia.com> | 2020-02-04 19:20:13 +0100 |
commit | 6473b1dcce965374e1ea3076831f5edf41a5e41f (patch) | |
tree | 0fd9198829625a41745085844385ab51119496b4 /src | |
parent | fae138a4c66f2632e95c29f1137e4649acba9b34 (diff) |
OPT Update buttons code
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 16 | ||||
-rw-r--r-- | src/js/buttons.js | 44 |
2 files changed, 16 insertions, 44 deletions
diff --git a/src/index.html b/src/index.html index 17293c9..d045d1d 100644 --- a/src/index.html +++ b/src/index.html @@ -28,7 +28,7 @@ <img class="one" src="../images/HMI_HVAC_ChairIndicator_One.svg"/> <img class="two" src="../images/HMI_HVAC_ChairIndicator_Two.svg"/> </a> - <a id="acbutton" value="false" href="#" class="ac item button" onclick="BUTTON.ac()"> + <a key="ac" value="false" href="#" class="ac item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_Inactive.svg"/> <img class="enabled" src="../images/HMI_HVAC_Active.svg"/> <div class="label"> @@ -46,14 +46,14 @@ <div id="lefttemperature" class="temperatures-container" onscroll="TEMPERATURE.left(this)"></div> </div> <div class="block item"> - <a id="autobutton" value="false" href="#" class="auto item button" onclick="BUTTON.auto()"> + <a key="auto" value="false" href="#" class="auto item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_Inactive.svg"/> <img class="enabled" src="../images/HMI_HVAC_Active.svg"/> <div class="label"> AUTO </div> </a> - <a id="circulationbutton" value="false" href="#" class="circulation item button" onclick="BUTTON.circulation()"> + <a key="circulation" value="false" href="#" class="circulation item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_Circulation_Inactive.svg"/> <img class="enabled" src="../images/HMI_HVAC_Circulation_Active.svg"/> </a> @@ -63,23 +63,23 @@ </div> </div> <div class="bottom"> - <a id="downbutton" value="false" href="#" class="down item button" onclick="BUTTON.down()"> + <a key="down" value="false" href="#" class="down item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_AirDown_Inactive.svg"> <img class="enabled" src="../images/HMI_HVAC_AirDown_Active.svg"> </a> - <a id="upbutton" value="false" href="#" class="up item button" onclick="BUTTON.up()"> + <a key="up" value="false" href="#" class="up item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_AirUp_Inactive.svg"> <img class="enabled" src="../images/HMI_HVAC_AirUp_Active.svg"> </a> - <a id="rightbutton" value="false" href="#" class="right item button" onclick="BUTTON.right()"> + <a key="right" value="false" href="#" class="right item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_AirRight_Inactive.svg"> <img class="enabled" src="../images/HMI_HVAC_AirRight_Active.svg"> </a> - <a id="rearbutton" value="false" href="#" class="rear item button" onclick="BUTTON.rear()"> + <a key="rear" value="false" href="#" class="rear item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_Rear_Inactive.svg"> <img class="enabled" src="../images/HMI_HVAC_Rear_Active.svg"> </a> - <a id="frontbutton" value="false" href="#" class="front item button" onclick="BUTTON.front()"> + <a key="front" value="false" href="#" class="front item button" onclick="BUTTON.toggle(this)"> <img class="disabled" src="../images/HMI_HVAC_Front_Inactive.svg"> <img class="enabled" src="../images/HMI_HVAC_Front_Active.svg"> </a> diff --git a/src/js/buttons.js b/src/js/buttons.js index 3730d9f..76c3ef4 100644 --- a/src/js/buttons.js +++ b/src/js/buttons.js @@ -9,42 +9,14 @@ var buttons = { front: false }; +function update(node, value) { + node.setAttribute('value', value); +} + module.exports = { - update: function() { - for( var button in buttons ) { - document.getElementById(button+'button').setAttribute('value', buttons[button]); - } - }, - ac: function() { - buttons.ac = !buttons.ac; - this.update(); - }, - auto: function() { - buttons.auto = !buttons.auto; - this.update(); - }, - circulation: function() { - buttons.circulation = !buttons.circulation; - this.update(); - }, - down: function() { - buttons.down = !buttons.down; - this.update(); - }, - up: function() { - buttons.up = !buttons.up; - this.update(); - }, - right: function() { - buttons.right = !buttons.right; - this.update(); - }, - rear: function() { - buttons.rear = !buttons.rear; - this.update(); - }, - front: function() { - buttons.front = !buttons.front; - this.update(); + toggle: function(node) { + var key = node.getAttribute('key'); + buttons[key] = !buttons[key]; + update(node, buttons[key]); } }
\ No newline at end of file |