aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/buttons.js
diff options
context:
space:
mode:
authorRoger Zanoni <rzanoni@igalia.com>2022-11-02 10:16:03 +0100
committerRoger Zanoni <rzanoni@igalia.com>2022-11-02 14:51:15 +0100
commitb0c869c0461741413af9e6a24f6e156717b6362f (patch)
tree1e7efd54e4c426d1b50dd7676e1186857b88802f /src/js/buttons.js
parent6abbe876aee09b225af9329e28b4fa2cc4d4c220 (diff)
Adapt the demo to use kuksa.val service
- The "AUTO" element was removed because there's no compatible VSS signal. - Removed the indicators below the seats and now they work only to toggle the state of the seat warmer. - The air distribution buttons now work as a radio group as there is only one AirDistribution setting per cabin. Bug-AGL: SPEC-4599 Signed-off-by: Roger Zanoni <rzanoni@igalia.com> Change-Id: Ibfaa477a7c27627ac524f39dd809b7a2195c7c9f
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]);
+ }
+}