summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-07-05 14:21:47 +0200
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 09:42:15 +0100
commit37c75cb3709d41149381f96f095e72e2ac8169d4 (patch)
tree04538c586f042fb63c8f77cef28ed5dfcac3cb81
parent7c3999c0457e5cc9a273b2ae5029c35ecab0792c (diff)
OPT Improve chair and fan code
-rw-r--r--src/index.html8
-rw-r--r--src/js/chair.js18
-rw-r--r--src/js/fan_speed.js17
3 files changed, 22 insertions, 21 deletions
diff --git a/src/index.html b/src/index.html
index 45a53d0..17293c9 100644
--- a/src/index.html
+++ b/src/index.html
@@ -12,8 +12,8 @@
</div>
<div class="fanSpeed">
<div class="fanSpeedContainer">
- <input id="FanSpeedInput" type="range" min="1" value="1" max="100" onchange="FANSPEED.update(this.value)">
- <progress id="FanSpeedProgress" value="1" max="100"></progress>
+ <input id="FanSpeed" type="range" min="1" value="1" max="100" onchange="FANSPEED.set(this)">
+ <progress value="1" max="100"></progress>
</div>
<div class="label">
FAN SPEED
@@ -21,7 +21,7 @@
</div>
</div>
<div class="center">
- <a id="LeftChair" value="0" href="#" class="seat left item button" onclick="CHAIR.left()">
+ <a id="LeftChair" value="0" href="#" class="seat left item button" onclick="CHAIR.left(this)">
<img class="off" src="../images/HMI_HVAC_Left_Chair_OFF.svg"/>
<img class="one two" src="../images/HMI_HVAC_Left_Chair_ON.svg"/>
<img class="off" src="../images/HMI_HVAC_ChairIndicator_OFF.svg"/>
@@ -35,7 +35,7 @@
A/C
</div>
</a>
- <a id="RightChair" value="0" href="#" class="seat right item button" onclick="CHAIR.right()">
+ <a id="RightChair" value="0" href="#" class="seat right item button" onclick="CHAIR.right(this)">
<img class="off" src="../images/HMI_HVAC_Right_Chair_OFF.svg"/>
<img class="one two" src="../images/HMI_HVAC_Right_Chair_ON.svg"/>
<img class="off" src="../images/HMI_HVAC_ChairIndicator_OFF.svg"/>
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
diff --git a/src/js/fan_speed.js b/src/js/fan_speed.js
index cc81fe0..4c8349e 100644
--- a/src/js/fan_speed.js
+++ b/src/js/fan_speed.js
@@ -1,10 +1,13 @@
-module.exports = {
- set: function(value) {
- document.getElementById('FanSpeedProgress').value = value;
- document.getElementById('FanSpeedInput').value = value;
- },
- update: function( value ) {
- this.set(value);
+var value = 0;
+
+function update(node, value) {
+ node.value = value;
+ node.parentNode.getElementsByTagName('progress')[0].value = value;
+}
+module.exports = {
+ set: function(node) {
+ value = node.value;
+ update(node, value);
}
} \ No newline at end of file
ght: bold } /* Literal.Number.Integer.Long */ }
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
	<!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">
	<!ENTITY ns_ai "http://ns.adobe.com/AdobeIllustrator/10.0/">
	<!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">
	<!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">
	<!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
	<!ENTITY ns_sfw "http://ns.adobe.com/SaveForWeb/1.0/">
	<!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">
	<!ENTITY ns_adobe_xpath "http://ns.adobe.com/XPath/1.0/">
]>
<svg version="1.1" id="Layer_2" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 350 155"
	 style="enable-background:new 0 0 350 155;" xml:space="preserve">
<style type="text/css">
	.st0{fill:#FFFFFF;}
	.st1{font-family:'Roboto-Regular';}
	.st2{font-size:20.4887px;}
	.st3{letter-spacing:3;}
	.st4{fill:#0DF9FF;}
	.st5{fill:none;stroke:url(#SVGID_1_);stroke-miterlimit:10;}
	.st6{fill:none;stroke:url(#SVGID_2_);stroke-miterlimit:10;}
</style>
<switch>
	<g i:extraneous="self">
		<g>
			<g>
				<g>
					<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="44.7964" y1="74.6998" x2="45.7964" y2="74.6998">
						<stop  offset="0" style="stop-color:#00ADDC"/>
						<stop  offset="1" style="stop-color:#6BFBFF"/>
					</linearGradient>
					<line class="st5" x1="45.3" y1="21.5" x2="45.3" y2="127.9"/>
					<circle class="st0" cx="45.3" cy="76.7" r="4.8"/>
					<circle class="st0" cx="45.3" cy="26.3" r="4.8"/>
					<circle class="st0" cx="45.3" cy="127.4" r="4.8"/>
				</g>
			</g>
			<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="45.2964" y1="26.5846" x2="45.2964" y2="26.5846">
				<stop  offset="0" style="stop-color:#8BC53F"/>
				<stop  offset="1" style="stop-color:#0DF9FF"/>
			</linearGradient>
			<path class="st6" d="M45.3,26.6"/>
		</g>
	</g>
</switch>
</svg>