summaryrefslogtreecommitdiffstats
path: root/src/js/chair.js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-07-05 14:21:47 +0200
committerHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-07-05 14:21:47 +0200
commite1cbac3034100e26ff02ee6c094fde16b90337cf (patch)
tree04538c586f042fb63c8f77cef28ed5dfcac3cb81 /src/js/chair.js
parent286ee56101e1538e8cca0b23032332a8f4d686f2 (diff)
OPT Improve chair and fan code
Diffstat (limited to 'src/js/chair.js')
-rw-r--r--src/js/chair.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/js/chair.js b/src/js/chair.js
index ceed88c..b1a3dbb 100644
--- a/src/js/chair.js
+++ b/src/js/chair.js
@@ -1,19 +1,17 @@
var left = 0;
var right = 0;
+function update(node, value){
+ node.setAttribute('value', value);
+}
+
module.exports = {
- update_left: function() {
- document.getElementById('LeftChair').setAttribute('value', left);
- },
- left: function() {
+ left: function(node) {
left = (left + 1) % 3;
- this.update_left();
- },
- update_right: function() {
- document.getElementById('RightChair').setAttribute('value', right);
+ update(node, left);
},
- right: function() {
+ right: function(node) {
right = (right + 1) % 3;
- this.update_right();
+ update(node, right);
},
} \ No newline at end of file