summaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-07-05 14:29:20 +0200
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 19:20:13 +0100
commit6473b1dcce965374e1ea3076831f5edf41a5e41f (patch)
tree0fd9198829625a41745085844385ab51119496b4 /src/js
parentfae138a4c66f2632e95c29f1137e4649acba9b34 (diff)
OPT Update buttons code
Diffstat (limited to 'src/js')
-rw-r--r--src/js/buttons.js44
1 files changed, 8 insertions, 36 deletions
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