From 3dd66f8955393dfd5a6f8cd1dd86f8281b517b40 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 14 Apr 2019 10:20:40 +0000
Subject: [PATCH] Switching between tram and bus stops in timetables (limited)

---
 index.js   |   21 +++++++++++++++++++++
 index.html |    2 +-
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/index.html b/index.html
index 315a798..b9c9fa1 100644
--- a/index.html
+++ b/index.html
@@ -129,7 +129,7 @@
 					
 					<p class="small" data-translate="help_text">Względne czasy (np. 3 min) są podawane na podstawie faktycznej lokalizacji pojazdów. Czasy bezwzględne (np. 8:01) to odjazdy rozkładowe, pokazywane gdy pojazd nie może być zlokalizowany. "?" oznacza nieznane opóźnienie.</p>
 					
-					<p class="small">&copy; 2016-2017 Jacek Kowalski - <a href="https://github.com/jacekkow/mpk-ttss" data-translate="help_source">Źródło</a> - <a href="https://raw.githubusercontent.com/jacekkow/mpk-ttss/master/LICENSE" data-translate="help_license">Licencja</a></p>
+					<p class="small">&copy; 2016-2019 Jacek Kowalski - <a href="https://github.com/jacekkow/mpk-ttss" data-translate="help_source">Źródło</a> - <a href="https://raw.githubusercontent.com/jacekkow/mpk-ttss/master/LICENSE" data-translate="help_license">Licencja</a></p>
 				</div>
 			</div>
 		</div>
diff --git a/index.js b/index.js
index 6c74d57..469a6ab 100644
--- a/index.js
+++ b/index.js
@@ -99,6 +99,16 @@
 	window.location.hash = '#!' + language + stopId;
 	refresh_button.removeAttribute('disabled');
 	
+	var alternative_stop = null;
+	var candidate = null;
+	for(var i = 0; i < stop_name_autocomplete.options.length; i++) {
+		candidate = stop_name_autocomplete.options[i].value;
+		if(candidate.substr(0, 1) != prefix && candidate.substr(1) == stop) {
+			alternative_stop = candidate;
+			break;
+		}
+	}
+	
 	times_xhr = $.get(
 		url + '/services/passageInfo/stopPassages/stop'
 			+ '?stop=' + encodeURIComponent(stop)
@@ -111,6 +121,17 @@
 		deleteChildren(times_table);
 		//deleteChildren(times_lines);
 		
+		if(alternative_stop !== null) {
+			var a = addParaWithText(times_alerts, '');
+			a = addElementWithText(a, 'a', (prefix == 'b' ? lang.departures_for_trams : lang.departures_for_buses));
+			a.href = '';
+			a.onclick = function(e) {
+				e.preventDefault();
+				loadTimes(alternative_stop);
+			};
+			
+		}
+		
 		for(var i = 0, il = data.generalAlerts.length; i < il; i++) {
 			addParaWithText(times_alerts, data.generalAlerts[i].title);
 		}

--
Gitblit v1.9.1