const BASE_API = "/api"; $("#lines").hide(); $("#line").attr("disabled", true); $("#destinations").attr("disabled", true); $("#stations").attr("disabled", true); $("#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; }); $("#linesFilter").change(function() { if ($("#linesFilter").val().length != 0) { findLines($("#linesFilter").val()); } }); $("#line").change(function() { if ($("#line").val().length != 0) { findDestinations($("#linesFilter").val(), $("#line").val()); findStations($("#linesFilter").val(), $("#line").val()); getTraffic($("#linesFilter").val(), $("#line").val()); } }); $("#stations").change(function() { if ($("#stations").val().length != 0) { $("#lines button").removeAttr("disabled"); } else { $("#lines button").attr("disabled", true); } }); $("#lines").submit(function(event) { event.preventDefault(); window.location.pathname = ["", $("#linesFilter").val(), $("#line").val(), $("#stations").val(), $("#destinations").val().length != 0?$("#destinations").val():""].join("/") }); function findLines(type) { $.getJSON( BASE_API + "/lines/" + type, function( data ) { $("#line").empty(); $("#line").append("