From a62589e05103b60e7d478de86345cc4c4cfc9036 Mon Sep 17 00:00:00 2001 From: Humberto Alfonso Díaz Date: Fri, 5 Jul 2019 11:15:05 +0200 Subject: FUNCT Add buttons, fan speed and chair functionality --- src/index.html | 72 +++++++++++++++++++++++++++++++--------------------- src/js/buttons.js | 50 ++++++++++++++++++++++++++++++++++++ src/js/chair.js | 19 ++++++++++++++ src/js/fan_speed.js | 10 ++++++++ src/styles/main.scss | 53 ++++++++++++++++++++++++++++++++++++++ webpack.config.js | 14 +++++++--- 6 files changed, 186 insertions(+), 32 deletions(-) create mode 100644 src/js/buttons.js create mode 100644 src/js/chair.js create mode 100644 src/js/fan_speed.js diff --git a/src/index.html b/src/index.html index 4541301..4ffbb28 100644 --- a/src/index.html +++ b/src/index.html @@ -12,8 +12,8 @@
- - + +
FAN SPEED @@ -22,20 +22,27 @@
-
- - -
- -
- - -
+
+ + + + + + +
@@ -92,15 +99,17 @@
@@ -159,20 +168,25 @@
diff --git a/src/js/buttons.js b/src/js/buttons.js new file mode 100644 index 0000000..3730d9f --- /dev/null +++ b/src/js/buttons.js @@ -0,0 +1,50 @@ +var buttons = { + ac: false, + auto: false, + circulation: false, + down: false, + up: false, + right: false, + rear: false, + front: false +}; + +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(); + } +} \ No newline at end of file diff --git a/src/js/chair.js b/src/js/chair.js new file mode 100644 index 0000000..ceed88c --- /dev/null +++ b/src/js/chair.js @@ -0,0 +1,19 @@ +var left = 0; +var right = 0; + +module.exports = { + update_left: function() { + document.getElementById('LeftChair').setAttribute('value', left); + }, + left: function() { + left = (left + 1) % 3; + this.update_left(); + }, + update_right: function() { + document.getElementById('RightChair').setAttribute('value', right); + }, + right: function() { + right = (right + 1) % 3; + this.update_right(); + }, +} \ No newline at end of file diff --git a/src/js/fan_speed.js b/src/js/fan_speed.js new file mode 100644 index 0000000..cc81fe0 --- /dev/null +++ b/src/js/fan_speed.js @@ -0,0 +1,10 @@ +module.exports = { + set: function(value) { + document.getElementById('FanSpeedProgress').value = value; + document.getElementById('FanSpeedInput').value = value; + }, + update: function( value ) { + this.set(value); + + } +} \ No newline at end of file diff --git a/src/styles/main.scss b/src/styles/main.scss index d0867c4..698d3ee 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -61,6 +61,31 @@ body { color: map-get($colors, font); margin: 5%; + a { + color: map-get($colors, font); + } + + .button { + &[value="true"] { + color: map-get($colors, primary); + .disabled { + display: none; + } + .enabled { + display: block; + } + } + &[value="false"] { + color: map-get($colors, grey); + .disabled { + display: block; + } + .enabled { + display: none; + } + } + } + .top { display: flex; flex-direction: row; @@ -114,6 +139,34 @@ body { width: 50%; margin: 0 25%; } + + &[value="0"] { + .one, .two { + display: none; + } + .off { + display: block; + } + } + + &[value="1"] { + .off, .two { + display: none; + } + .one { + display: block; + } + } + + &[value="2"] { + .one, .off { + display: none; + } + .two { + display: block; + } + } + } &.circulation { diff --git a/webpack.config.js b/webpack.config.js index e6baeb2..ed7e0a3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,10 +9,18 @@ const ZipPlugin = require('zip-webpack-plugin'); module.exports = { mode: 'production', - entry: './src/index.js', + entry: { + index: './src/index.js', + FANSPEED: './src/js/fan_speed.js', + CHAIR: './src/js/chair.js', + BUTTON: './src/js/buttons.js' + }, output: { - filename: 'index.js', - path: __dirname + '/dist' + path: __dirname + '/dist', + filename: '[name].js', + libraryTarget: 'var', + // `library` determines the name of the global variable + library: '[name]' }, optimization: { minimizer: [new UglifyJsPlugin()], -- cgit 1.2.3-korg