Also refresh traffic info

This commit is contained in:
nemunaire 2018-06-06 19:27:14 +02:00
parent 69a5fa5a8a
commit 64d578c3ba

10
app.js
View File

@ -8,6 +8,7 @@ $("#traffic").hide();
$("#schedule").hide();
$("#loading").hide();
var nextSchedule = null;
var nextTraffic = null;
var uri = window.location.pathname.split("/").filter(function(v) {
return v.length > 0;
@ -80,10 +81,19 @@ function findStations(type, code) {
function getTraffic(type, code) {
$("#traffic").hide();
if (nextTraffic != null) {
clearTimeout(nextTraffic);
nextTraffic = null;
}
$.getJSON( BASE_API + "/traffic/" + type + "/" + code, function( data ) {
$("#traffic h3").text(data["result"]["line"] + " : " + data["result"]["title"]);
$("#traffic p").text(data["result"]["message"]);
$("#traffic").show();
nextTraffic = setTimeout(function() {
getSchedule(type, code);
}, 150000);
});
}