From 2107d19cb1db00c12e32dd76dec63b5c7f482e6b Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 30 Jul 2021 19:35:05 +0000
Subject: [PATCH] [map] Add information on air conditioning in the vehicle

---
 map.js     |    6 ++-
 common.js  |   32 +++++++++++++--
 lang_en.js |    7 +++
 index.html |    4 +-
 map.html   |    6 +-
 lang_pl.js |    7 +++
 6 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/common.js b/common.js
index af26776..3f7be8a 100644
--- a/common.js
+++ b/common.js
@@ -285,22 +285,44 @@
 	var span = document.createElement('span');
 	span.className = 'vehicleInfo';
 	
+	var text = '';
+	
 	var floor_type = '';
 	if(vehicleInfo.low === 0) {
-		setText(span, lang.high_floor_sign);
+		text += lang.high_floor_sign;
 		floor_type = lang.high_floor;
 	} else if(vehicleInfo.low === 1) {
-		setText(span, lang.partially_low_floor_sign);
+		text += lang.partially_low_floor_sign;
 		floor_type = lang.partially_low_floor;
 	} else if(vehicleInfo.low === 2) {
-		setText(span, lang.low_floor_sign);
+		text += lang.low_floor_sign;
 		floor_type = lang.low_floor;
 	}
 	
-	span.title = lang.tram_type_pattern
+	var air_conditioning = '';
+	if(vehicleInfo.ac) {
+		text += lang.air_conditioning_sign;
+		air_conditioning = lang.air_conditioning;
+	}
+	
+	setText(span, text);
+	
+	span.dataset.typeFull = lang.tram_type_pattern
 		.replace('$num', vehicleInfo.num)
 		.replace('$type', vehicleInfo.type)
-		.replace('$floor', floor_type);
+		.replace('$floor', floor_type)
+		.replace('$ac', air_conditioning);
+	span.dataset.typeShort = lang.tram_type_pattern_short
+		.replace('$num', vehicleInfo.num)
+		.replace('$type', vehicleInfo.type)
+		.replace('$floor', floor_type)
+		.replace('$ac', air_conditioning);
+	span.dataset.typeAdditional = lang.tram_type_pattern_additional
+		.replace('$num', vehicleInfo.num)
+		.replace('$type', vehicleInfo.type)
+		.replace('$floor', floor_type)
+		.replace('$ac', air_conditioning);
+	span.title = span.dataset.typeFull;
 	
 	return span;
 }
diff --git a/index.html b/index.html
index f2e1c86..d4523ca 100644
--- a/index.html
+++ b/index.html
@@ -135,8 +135,8 @@
 			</div>
 		</div>
 		<script src="https://polyfill.io/v3/polyfill.min.js?features=Promise,XMLHttpRequest"></script>
-		<script type="text/javascript" src="lang_pl.js?v10" id="lang_script"></script>
-		<script type="text/javascript" src="common.js?v11"></script>
+		<script type="text/javascript" src="lang_pl.js?v11" id="lang_script"></script>
+		<script type="text/javascript" src="common.js?v12"></script>
 		<script type="text/javascript" src="index.js?v8"></script>
 	</body>
 </html>
diff --git a/lang_en.js b/lang_en.js
index 8b94490..cfdbe8d 100644
--- a/lang_en.js
+++ b/lang_en.js
@@ -71,7 +71,9 @@
 	trip_current: 'current',
 	trip_next: 'next \u00BB',
 	
-	tram_type_pattern: '$num $type ($floor)',
+	tram_type_pattern: '$num $type ($floor$ac)',
+	tram_type_pattern_short: '$num $type',
+	tram_type_pattern_additional: '$floor$ac',
 	high_floor: 'high floor',
 	high_floor_sign: '\u2010\u00A0',
 	high_floor_description: 'high-floor vehicle',
@@ -81,6 +83,9 @@
 	low_floor: 'low floor',
 	low_floor_sign: '\u267F',
 	low_floor_description: 'low-floor vehicle',
+	air_conditioning: ', air conditioning',
+	air_conditioning_sign: '\u2744',
+	air_conditioning_description: 'has air conditioning unit',
 	
 	status_departed: 'Departed',
 	status_stopped: 'At stop',
diff --git a/lang_pl.js b/lang_pl.js
index 08ca6b1..b2e6788 100644
--- a/lang_pl.js
+++ b/lang_pl.js
@@ -71,7 +71,9 @@
 	trip_current: 'aktualny',
 	trip_next: 'następny \u00BB',
 	
-	tram_type_pattern: '$num $type ($floor)',
+	tram_type_pattern: '$num $type ($floor$ac)',
+	tram_type_pattern_short: '$num $type',
+	tram_type_pattern_additional: '$floor$ac',
 	high_floor: 'wysokopodłogowy',
 	high_floor_sign: '\u2010\u00A0',
 	high_floor_description: 'pojazd wysokopodłogowy',
@@ -81,6 +83,9 @@
 	low_floor: 'niskopodłogowy',
 	low_floor_sign: '\u267F',
 	low_floor_description: 'pojazd niskopodłogowy',
+	air_conditioning: ', klimatyzacja',
+	air_conditioning_sign: '\u2744',
+	air_conditioning_description: 'posiada klimatyzację',
 	
 	status_departed: 'Odjechał',
 	status_stopped: 'Na przystanku',
diff --git a/map.html b/map.html
index 1d19505..8602b68 100644
--- a/map.html
+++ b/map.html
@@ -20,8 +20,8 @@
 <div id="panel"></div>
 <script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.forEach,Array.prototype.includes,Array.prototype.map,Element.prototype.classList,Promise,String.prototype.startsWith,XMLHttpRequest,requestAnimationFrame"></script>
 <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.6.1/build/ol.js" integrity="sha384-2t8P2Mt0pPrLNwMqTljtykP6hpy7mzd34amfOqUYKK74XwsZgukowi3L4lW4bd3K" crossorigin="anonymous"></script>
-<script tyle="text/javascript" src="lang_pl.js?v10" id="lang_script"></script>
-<script tyle="text/javascript" src="common.js?v11"></script>
-<script tyle="text/javascript" src="map.js?v27"></script>
+<script tyle="text/javascript" src="lang_pl.js?v11" id="lang_script"></script>
+<script tyle="text/javascript" src="common.js?v12"></script>
+<script tyle="text/javascript" src="map.js?v28"></script>
 </body>
 </html>
diff --git a/map.js b/map.js
index a74adfa..29d3d8b 100644
--- a/map.js
+++ b/map.js
@@ -720,8 +720,10 @@
 		var span = displayVehicle(feature.get('type'));
 		
 		additional = document.createElement('p');
-		if(span.title) {
-			setText(additional, span.title);
+		if(span.dataset.typeShort) {
+			setText(additional, span.dataset.typeShort);
+			additional.title = span.dataset.typeAdditional;
+			span.removeAttribute('title');
 		} else {
 			setText(additional, feature.getId());
 		}

--
Gitblit v1.9.1