Frontend: Add support for 'No Scheduled Services'
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
9434d7e3a8
commit
f3f514b80d
1
.test-tools/MULTIPLE-NRCC-MSG_API-EG-cdf.json
Normal file
1
.test-tools/MULTIPLE-NRCC-MSG_API-EG-cdf.json
Normal file
File diff suppressed because one or more lines are too long
1
.test-tools/NO-SERVICES_API-EG-pil.json
Normal file
1
.test-tools/NO-SERVICES_API-EG-pil.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"GetStationBoardResult":{"generatedAt":"2023-01-14T11:23:12.6558466+00:00","locationName":"Pilning","crs":"PIL","nrccMessages":{"message":"\nPoor weather affecting services in Wales due to flooding on the railway More details can be found in <a href=\"https://t.co/uBU966PUmX\">Latest Travel News</a>."},"platformAvailable":"true"}}
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<div id="nrcc_notices" class="hidden-while-loading">
|
<div id="nrcc_notices" class="hidden-while-loading">
|
||||||
<p>
|
<p>
|
||||||
Services may be subject to alterations due to heavy rain flooding the railway between Bristol Parkway and Swindon.
|
Example: Services may be subject to alterations due to heavy rain flooding the railway between Bristol Parkway and Swindon.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -33,13 +33,16 @@
|
|||||||
<p>Loading</p>
|
<p>Loading</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="error_notice" class="hidden-unless-error">
|
<div id="error_notice" class="main-notice hidden-while-loading">
|
||||||
<h1 class="error">Oops</h1>
|
<h1 class="error">Oops</h1>
|
||||||
<p class="error">There was an error with your request</p>
|
<p class="error">There was an error with your request</p>
|
||||||
<p id="err_not_found">The station you are searching for cannot be found</p>
|
<p id="err_not_found">The station you are searching for cannot be found</p>
|
||||||
<p id="err_no_data">The station has no data. It may not be in operation yet/anymore.</p>
|
<p id="err_no_data">The station has no data. It may not be in operation yet/anymore.</p>
|
||||||
<p id="err_conn">Connection Error, check your data connection. Retrying.</p>
|
<p id="err_conn">Connection Error, check your data connection. Retrying.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="no_services" class="main-notice hidden-whille-loading">
|
||||||
|
<p>There are no scheduled services from this station</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="output">
|
<div id="output">
|
||||||
|
|
||||||
|
@ -71,11 +71,12 @@ async function parseLdb(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide all loading classes
|
// Hide loading spinner
|
||||||
async function clearLoading() {
|
async function clearLoading() {
|
||||||
document.getElementById("loading").style = "display: none;";
|
document.getElementById("loading").style = "display: none;";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build and Display Functions
|
||||||
async function buildPage(data) {
|
async function buildPage(data) {
|
||||||
var stationName = data.GetStationBoardResult.locationName;
|
var stationName = data.GetStationBoardResult.locationName;
|
||||||
log(`buildPage: Data ready for ${stationName}`);
|
log(`buildPage: Data ready for ${stationName}`);
|
||||||
@ -86,6 +87,11 @@ async function buildPage(data){
|
|||||||
if (data.GetStationBoardResult.nrccMessages) {
|
if (data.GetStationBoardResult.nrccMessages) {
|
||||||
displayNotices(data.GetStationBoardResult.nrccMessages.message)
|
displayNotices(data.GetStationBoardResult.nrccMessages.message)
|
||||||
}
|
}
|
||||||
|
if (typeof data.GetStationBoardResult.trainServices == 'undefined') {
|
||||||
|
displayNoTrains()
|
||||||
|
} else {
|
||||||
|
// Function here to Parse train services and display.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function displayNotices(notices) {
|
async function displayNotices(notices) {
|
||||||
@ -96,6 +102,15 @@ async function displayNotices(notices){
|
|||||||
//document.getElementById("notices").innerHTML = notices;
|
//document.getElementById("notices").innerHTML = notices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function displayNoTrains() {
|
||||||
|
document.getElementById('no_services').style = "display: block;";
|
||||||
|
clearLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function displayTrains() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Log Helper
|
// Log Helper
|
||||||
function log(msg) {
|
function log(msg) {
|
||||||
var time = new Date().toISOString();
|
var time = new Date().toISOString();
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Error Notices: */
|
/* Main Notices: */
|
||||||
.hidden-unless-error {
|
.main-notice {
|
||||||
display: none;
|
display: none;
|
||||||
margin-top: 150px;
|
margin-top: 150px;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user