Implement all platforms display

This commit is contained in:
RunasSudo 2019-01-12 11:15:59 +11:00
parent 813e5bc0f9
commit 6f7f778312
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 13 additions and 6 deletions

View File

@ -182,7 +182,11 @@ def latest():
result = {} result = {}
result['time_offset'] = timenow.utcoffset().total_seconds() result['time_offset'] = timenow.utcoffset().total_seconds()
departures = do_request('/v3/departures/route_type/{}/stop/{}'.format(ROUTE_TYPE, flask.request.args['stop_id']), {'platform_numbers': flask.request.args['plat_id'], 'max_results': '5', 'expand': 'all'}, cachetime=60) args = {'max_results': '5', 'expand': 'all'}
if flask.request.args['plat_id'] != '0':
args['platform_numbers'] = flask.request.args['plat_id']
departures = do_request('/v3/departures/route_type/{}/stop/{}'.format(ROUTE_TYPE, flask.request.args['stop_id']), args, cachetime=60)
departures['departures'].sort(key=lambda x: x['scheduled_departure_utc']) departures['departures'].sort(key=lambda x: x['scheduled_departure_utc'])
if len(departures['departures']) == 0: if len(departures['departures']) == 0:

View File

@ -37,7 +37,7 @@
</style> </style>
</head> </head>
<body> <body>
<div id="topbar">Stop <span id="stopinfo">?</span> [<a href="stations">change</a>] Platform <span id="platinfo">?</span> [<a href="#" onclick="return changePlatform();">change</a>] Style <span id="styleinfo">?</span> [change: <a href="#" onclick="return changeStyle(1);">1</a>, <a href="#" onclick="return changeStyle(2);">2</a>]</div> <div id="topbar">Stop <span id="stopinfo">?</span> [<a href="stations">change</a>] <span id="platinfo">Platform ?</span> [<a href="#" onclick="return changePlatform();">change</a>] Style <span id="styleinfo">?</span> [change: <a href="#" onclick="return changeStyle(1);">1</a>, <a href="#" onclick="return changeStyle(2);">2</a>]</div>
<div id="botbar">By RunasSudo · AGPLv3 · <a href="https://gitlab.com/RunasSudo/virtual-metro">Source Code</a> · Data from PTV licensed under CC BY 4.0</div> <div id="botbar">By RunasSudo · AGPLv3 · <a href="https://gitlab.com/RunasSudo/virtual-metro">Source Code</a> · Data from PTV licensed under CC BY 4.0</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/nunjucks/3.0.1/nunjucks.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/nunjucks/3.0.1/nunjucks.min.js"></script>
<script> <script>
@ -57,7 +57,7 @@
var template_id = parseInt(getQueryVariable("template_id", 1)); var template_id = parseInt(getQueryVariable("template_id", 1));
document.getElementById("stopinfo").innerText = stop_id; document.getElementById("stopinfo").innerText = stop_id;
document.getElementById("platinfo").innerText = plat_id; document.getElementById("platinfo").innerText = (plat_id == 0) ? "All Platforms" : ("Platform " + plat_id);
document.getElementById("styleinfo").innerText = template_id; document.getElementById("styleinfo").innerText = template_id;
var svg = null; var svg = null;
@ -107,9 +107,12 @@
} }
function changePlatform() { function changePlatform() {
var new_plat = parseInt(window.prompt("Enter new platform number:", plat_id)); var new_plat = window.prompt("Enter new platform number, or 0 for all platforms:", plat_id);
window.location = "?stop_id=" + stop_id + "&plat_id=" + new_plat + "&template_id=" + template_id; if (new_plat !== null) {
return false; new_plat = parseInt(new_plat);
window.location = "?stop_id=" + stop_id + "&plat_id=" + new_plat + "&template_id=" + template_id;
return false;
}
} }
function changeStyle(new_style) { function changeStyle(new_style) {