aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/buttons.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/buttons.js')
-rw-r--r--src/js/buttons.js69
1 files changed, 55 insertions, 14 deletions
diff --git a/src/js/buttons.js b/src/js/buttons.js
index 5fcb521..76d2143 100644
--- a/src/js/buttons.js
+++ b/src/js/buttons.js
@@ -14,25 +14,66 @@
* limitations under the License.
*/
-var buttons = {
+
+
+var values = {
ac: false,
- auto: false,
- circulation: false,
- down: false,
- up: false,
- right: false,
+ recirculation: false,
rear: false,
front: false
};
-function update(node, value) {
- node.setAttribute('value', value);
+var paths = {
+ ac: PATHS.airConditioning,
+ recirculation: PATHS.recirculation,
+ rear: PATHS.rearDefroster,
+ front: PATHS.frontDefroster,
+};
+
+var nodes = {}
+
+export function init() {
+ nodes[PATHS.airConditioning] = document.getElementById('ac');
+ nodes[PATHS.recirculation] = document.getElementById('recirculation');
+ nodes[PATHS.frontDefroster] = document.getElementById('front');
+ nodes[PATHS.rearDefroster] = document.getElementById('rear');
+ nodes['up'] = document.getElementById('up');
+ nodes['down'] = document.getElementById('down');
+ nodes['right'] = document.getElementById('right');
}
-module.exports = {
- toggle: function(node) {
- var key = node.getAttribute('key');
- buttons[key] = !buttons[key];
- update(node, buttons[key]);
+export function update(path, value) {
+ if (path == PATHS.leftAirDistribution) {
+ if (value == 'UP') {
+ nodes['up'].setAttribute('value', true);
+ nodes['down'].setAttribute('value', false);
+ nodes['right'].setAttribute('value', false);
+ } else if (value == 'DOWN') {
+ nodes['down'].setAttribute('value', true);
+ nodes['up'].setAttribute('value', false);
+ nodes['right'].setAttribute('value', false);
+
+ } else if (value == 'MIDDLE') {
+ nodes['right'].setAttribute('value', true);
+ nodes['up'].setAttribute('value', false);
+ nodes['down'].setAttribute('value', false);
+ }
+ } else {
+ var node = nodes[path];
+ node.setAttribute('value', value);
}
-} \ No newline at end of file
+}
+
+export function toggle(node) {
+ var key = node.getAttribute('key');
+ values[key] = !values[key];
+ if (key == 'up') {
+ KUKSA.set(PATHS.leftAirDistribution, 'UP');
+ } else if (key == 'down') {
+ KUKSA.set(PATHS.leftAirDistribution, 'DOWN');
+ } else if (key == 'right') {
+ KUKSA.set(PATHS.leftAirDistribution, 'MIDDLE');
+ } else {
+ KUKSA.set(paths[key], values[key]);
+ }
+}