From 03b3d2993726a9e0c93a25df098989c289f33fae Mon Sep 17 00:00:00 2001 From: Humberto Alfonso Díaz Date: Fri, 5 Jul 2019 14:29:20 +0200 Subject: OPT Update buttons code --- src/index.html | 16 ++++++++-------- 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 @@ - +
@@ -46,14 +46,14 @@
- +
AUTO
- + @@ -63,23 +63,23 @@
- + - + - + - + - + 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 -- cgit 1.2.3-korg