From 0ba7498c8b7397c579a1c5ade8ad22bcabd1e5cf Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Mon, 25 Mar 2019 21:20:58 +0000
Subject: [PATCH] Fix stop point table - stop table is displayed instead

---
 map.js   |   18 ++++++++++--------
 map.html |    2 +-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/map.html b/map.html
index 7741718..b75bf55 100644
--- a/map.html
+++ b/map.html
@@ -26,6 +26,6 @@
 <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v5.3.0/build/ol.js" integrity="sha384-iQkGyyH4ioz3m+maM3s9MX1Oq67mACa4B9Z3ovUv3Sv37LJ96fx3WnZfLoiC3Wfl" crossorigin="anonymous"></script>
 <script tyle="text/javascript" src="lang_pl.js?v6" id="lang_script"></script>
 <script tyle="text/javascript" src="common.js?v7"></script>
-<script tyle="text/javascript" src="map.js?v17"></script>
+<script tyle="text/javascript" src="map.js?v18"></script>
 </body>
 </html>
diff --git a/map.js b/map.js
index f16133c..a92594a 100644
--- a/map.js
+++ b/map.js
@@ -425,11 +425,9 @@
 	}).fail(fail_ajax_popup);
 }
 
-function stopTable(stopType, stopId, table, featureId) {
+function stopTable(stopType, stopId, table, ttss_type) {
 	if(feature_xhr) feature_xhr.abort();
 	if(feature_timer) clearTimeout(feature_timer);
-	
-	var ttss_type = featureId.substr(1, 1);
 	
 	feature_xhr = $.get(
 		ttss_urls[ttss_type] + '/services/passageInfo/stopPassages/' + stopType
@@ -476,7 +474,7 @@
 			table.appendChild(tr);
 		}
 		
-		feature_timer = setTimeout(function() { stopTable(stopType, stopId, table, featureId); }, ttss_refresh);
+		feature_timer = setTimeout(function() { stopTable(stopType, stopId, table, ttss_type); }, ttss_refresh);
 	}).fail(fail_ajax_popup);
 }
 
@@ -539,16 +537,19 @@
 	}
 	// Stop or stop point
 	else if(['s', 'p'].indexOf(type) >= 0) {
+		var ttss_type = feature.getId().substr(1, 1);
 		if(type == 's') {
 			typeName = lang.type_stop_tram;
 			var second_type = lang.departures_for_buses;
 			var mapping = stops_mapping['sb'];
 			
-			if(feature.getId().startsWith('sb')) {
+			if(ttss_type == 'b') {
 				typeName = lang.type_stop_bus;
 				second_type = lang.departures_for_trams;
 				mapping = stops_mapping['st'];
 			}
+			
+			stopTable('stop', feature.get('shortName'), tbody, ttss_type);
 			
 			if(mapping[feature.get('shortName')]) {
 				additional = document.createElement('p');
@@ -563,16 +564,18 @@
 		} else {
 			typeName = lang.type_stoppoint_tram;
 			
-			if(feature.getId().startsWith('pb')) {
+			if(ttss_type == 'b') {
 				typeName = lang.type_stoppoint_bus;
 			}
+			
+			stopTable('stopPoint', feature.get('stopPoint'), tbody, ttss_type);
 			
 			additional = document.createElement('p');
 			additional.className = 'small';
 			addElementWithText(additional, 'a', lang.departures_for_stop).addEventListener(
 				'click',
 				function() {
-					var mapping = stops_mapping['s' + feature.getId().substr(1,1)];
+					var mapping = stops_mapping['s' + ttss_type];
 					featureClicked(mapping[feature.get('shortName')]);
 				}
 			);
@@ -583,7 +586,6 @@
 		addElementWithText(thead, 'th', lang.header_time);
 		addElementWithText(thead, 'th', lang.header_delay);
 		
-		stopTable('stop', feature.get('shortName'), tbody, feature.getId());
 		markStops([feature], feature.getId().substr(1,1));
 	} else {
 		panel.close();

--
Gitblit v1.9.1