diff --git a/.test-tools/MULTIPLE-NRCC-MSG_API-EG-cdf.json b/.test-tools/MULTIPLE-NRCC-MSG_API-EG-cdf.json new file mode 100644 index 0000000..f8a42d0 --- /dev/null +++ b/.test-tools/MULTIPLE-NRCC-MSG_API-EG-cdf.json @@ -0,0 +1 @@ +{"GetStationBoardResult":{"generatedAt":"2023-01-14T11:24:26.042096+00:00","locationName":"Cardiff Central","crs":"CDF","nrccMessages":{"message":["

\nThe lifts are out of order between Platforms 1 & 2 and the station at Cardiff Central station.

","\nDisruption in the Bristol area due to a number of incidents. More details can be found in Latest Travel News.","\nBuses replace trains between Radyr and Cardiff Central. More details can be found in Latest Travel News.","\nPoor weather affecting services in Wales due to flooding on the railway More details can be found in Latest Travel News.","Poor weather affecting services across the South West of England. More details can be found in Latest Travel News"]},"platformAvailable":"true","trainServices":{"service":[{"sta":"11:10","eta":"11:17","std":"11:11","platform":"6","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","cancelReason":"This train has been cancelled because of vandalism of railway equipment","delayReason":"This train has been delayed by vandalism of railway equipment","serviceID":"5004425CRDFCEN_","rsid":"AW892100","origin":{"location":{"locationName":"Barry Island","crs":"BYI"}},"destination":{"location":{"locationName":"Cardiff Central","crs":"CDF"}}},{"sta":"11:16","eta":"11:38","std":"11:18","etd":"11:39","platform":"2","operator":"Great Western Railway","operatorCode":"GW","serviceType":"train","delayReason":"This train has been delayed by heavy rain flooding the railway","serviceID":"4987206CRDFCEN_","origin":{"location":{"locationName":"Swansea","crs":"SWA"}},"destination":{"location":{"locationName":"London Paddington","crs":"PAD"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Swansea","crs":"SWA","st":"10:22","at":"10:45"},{"locationName":"Neath","crs":"NTH","st":"10:34","at":"10:57"},{"locationName":"Port Talbot Parkway","crs":"PTA","st":"10:42","at":"11:05"},{"locationName":"Bridgend","crs":"BGN","st":"10:55","at":"11:17"}]}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Newport (South Wales)","crs":"NWP","st":"11:30","et":"11:50"},{"locationName":"Bristol Parkway","crs":"BPW","st":"11:54","et":"12:11"},{"locationName":"Swindon","crs":"SWI","st":"12:19","et":"12:33"},{"locationName":"Reading","crs":"RDG","st":"12:46","et":"12:57"},{"locationName":"London Paddington","crs":"PAD","st":"13:11","et":"13:20"}]}}},{"sta":"11:20","eta":"Delayed","platform":"7","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","serviceID":"4999894CRDFCEN_","rsid":"AW888600","origin":{"location":{"locationName":"Radyr","crs":"RDR"}},"destination":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Radyr","crs":"RDR","st":"11:03","et":"Delayed"},{"locationName":"Llandaf","crs":"LLN","st":"11:06","et":"Delayed"},{"locationName":"Cathays","crs":"CYS","st":"11:10","et":"Delayed"},{"locationName":"Cardiff Queen Street","crs":"CDQ","st":"11:15","et":"Delayed"}]}}},{"sta":"11:22","eta":"Cancelled","operator":"Great Western Railway","operatorCode":"GW","isCancelled":"true","serviceType":"train","cancelReason":"This train has been cancelled because of heavy rain flooding the railway","delayReason":"This train has been delayed by heavy rain flooding the railway","serviceID":"4986922CRDFCEN_","rsid":"GW875200","origin":{"location":{"locationName":"Penzance","crs":"PNZ"}},"destination":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"currentDestinations":{"location":{"locationName":"Weston-super-Mare","crs":"WSM"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Penzance","crs":"PNZ","st":"05:40","at":"On time"},{"locationName":"St Erth","crs":"SER","st":"05:49","at":"On time"},{"locationName":"Hayle","crs":"HYL","st":"05:53","at":"On time"},{"locationName":"Camborne","crs":"CBN","st":"06:02","at":"On time"},{"locationName":"Redruth","crs":"RED","st":"06:08","at":"On time"},{"locationName":"Truro","crs":"TRU","st":"06:20","at":"On time"},{"locationName":"St Austell","crs":"SAU","st":"06:36","at":"06:39"},{"locationName":"Par","crs":"PAR","st":"06:43","at":"06:45"},{"locationName":"Lostwithiel","crs":"LOS","st":"06:49","at":"06:52"},{"locationName":"Bodmin Parkway","crs":"BOD","st":"06:55","at":"06:58"},{"locationName":"Liskeard","crs":"LSK","st":"07:08","at":"07:10"},{"locationName":"Menheniot","crs":"MEN","st":"07:13","at":"07:15"},{"locationName":"St Germans","crs":"SGM","st":"07:20","at":"07:23"},{"locationName":"Saltash","crs":"STS","st":"07:27","at":"07:31"},{"locationName":"St Budeaux Ferry Road","crs":"SBF","st":"07:32","at":"07:35"},{"locationName":"Keyham","crs":"KEY","st":"07:35","at":"07:38"},{"locationName":"Dockyard","crs":"DOC","st":"07:38","at":"07:41"},{"locationName":"Devonport","crs":"DPT","st":"07:41","at":"07:43"},{"locationName":"Plymouth","crs":"PLY","st":"07:47","at":"07:48"},{"locationName":"Ivybridge","crs":"IVY","st":"08:01","at":"08:04"},{"locationName":"Totnes","crs":"TOT","st":"08:15","at":"08:19"},{"locationName":"Newton Abbot","crs":"NTA","st":"08:28","at":"08:31"},{"locationName":"Teignmouth","crs":"TGM","st":"08:35","at":"08:37"},{"locationName":"Dawlish","crs":"DWL","st":"08:40","at":"08:42"},{"locationName":"Exeter St Davids","crs":"EXD","st":"08:55","at":"On time"},{"locationName":"Taunton","crs":"TAU","st":"09:19","at":"On time"},{"locationName":"Bridgwater","crs":"BWT","st":"09:29","at":"On time"},{"locationName":"Highbridge & Burnham","crs":"HIG","st":"09:37","at":"On time"},{"locationName":"Weston-super-Mare","crs":"WSM","st":"09:46","at":"09:48"},{"locationName":"Worle","crs":"WOR","st":"09:54","et":"Cancelled"},{"locationName":"Yatton","crs":"YAT","st":"10:00","et":"Cancelled"},{"locationName":"Nailsea & Backwell","crs":"NLS","st":"10:06","et":"Cancelled"},{"locationName":"Bristol Temple Meads","crs":"BRI","st":"10:30","et":"Cancelled"},{"locationName":"Filton Abbey Wood","crs":"FIT","st":"10:40","et":"Cancelled"},{"locationName":"Patchway","crs":"PWY","st":"10:44","et":"Cancelled"},{"locationName":"Severn Tunnel Junction","crs":"STJ","st":"10:55","et":"Cancelled"},{"locationName":"Newport (South Wales)","crs":"NWP","st":"11:08","et":"Cancelled"}]}}},{"std":"11:23","etd":"On time","platform":"1","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","cancelReason":"This train has been cancelled because of flooding","delayReason":"This train has been delayed by flooding","serviceID":"4986816CRDFCEN_","origin":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"destination":{"location":{"locationName":"Holyhead","crs":"HHD","via":"via Shrewsbury"}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Newport (South Wales)","crs":"NWP","st":"11:36","et":"On time"},{"locationName":"Cwmbran","crs":"CWM","st":"11:47","et":"On time"},{"locationName":"Pontypool & New Inn","crs":"PPL","st":"11:52","et":"Cancelled"},{"locationName":"Abergavenny","crs":"AGV","st":"12:02","et":"On time"},{"locationName":"Hereford","crs":"HFD","st":"12:27","et":"On time"},{"locationName":"Ludlow","crs":"LUD","st":"12:48","et":"On time"},{"locationName":"Craven Arms","crs":"CRV","st":"12:57","et":"On time"},{"locationName":"Church Stretton","crs":"CTT","st":"13:07","et":"On time"},{"locationName":"Shrewsbury","crs":"SHR","st":"13:22","et":"On time"},{"locationName":"Gobowen","crs":"GOB","st":"13:44","et":"On time"},{"locationName":"Chirk","crs":"CRK","st":"13:50","et":"On time"},{"locationName":"Ruabon","crs":"RUA","st":"13:56","et":"On time"},{"locationName":"Wrexham General","crs":"WRX","st":"14:04","et":"On time"},{"locationName":"Chester","crs":"CTR","st":"14:24","et":"On time"},{"locationName":"Flint","crs":"FLN","st":"14:41","et":"On time"},{"locationName":"Prestatyn","crs":"PRT","st":"14:54","et":"On time"},{"locationName":"Rhyl","crs":"RHL","st":"15:01","et":"On time"},{"locationName":"Colwyn Bay","crs":"CWB","st":"15:13","et":"On time"},{"locationName":"Llandudno Junction","crs":"LLJ","st":"15:20","et":"On time"},{"locationName":"Bangor (Gwynedd)","crs":"BNG","st":"15:41","et":"On time"},{"locationName":"Llanfairpwll","crs":"LPG","st":"15:48","et":"On time"},{"locationName":"Bodorgan","crs":"BOR","st":"15:59","et":"On time"},{"locationName":"Ty Croes","crs":"TYC","st":"16:03","et":"On time"},{"locationName":"Rhosneigr","crs":"RHO","st":"16:06","et":"On time"},{"locationName":"Valley","crs":"VAL","st":"16:12","et":"On time"},{"locationName":"Holyhead","crs":"HHD","st":"16:21","et":"On time"}]}}},{"sta":"11:24","eta":"11:26","std":"11:25","platform":"BUS","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","cancelReason":"This train has been cancelled because of flooding earlier today","delayReason":"This train has been delayed by flooding earlier today","serviceID":"5004671CRDFCEN_","rsid":"AW875000","origin":{"location":{"locationName":"Barry Island","crs":"BYI"}},"destination":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Barry Island","crs":"BYI","st":"10:56","at":"11:06"},{"locationName":"Barry","crs":"BRY","st":"11:00","at":"11:11"},{"locationName":"Barry Docks","crs":"BYD","st":"11:03","at":"Cancelled"},{"locationName":"Cadoxton","crs":"CAD","st":"11:06","at":"Cancelled"},{"locationName":"Dinas Powys","crs":"DNS","st":"11:10","at":"Cancelled"},{"locationName":"Eastbrook","crs":"EBK","st":"11:13","at":"Cancelled"},{"locationName":"Cogan","crs":"CGN","st":"11:15","at":"Cancelled"},{"locationName":"Grangetown","crs":"GTN","st":"11:19","at":"Cancelled"}]}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Cardiff Queen Street","crs":"CDQ","st":"11:28","et":"Cancelled"},{"locationName":"Cathays","crs":"CYS","st":"11:30","et":"Cancelled"},{"locationName":"Llandaf","crs":"LLN","st":"11:35","et":"Cancelled"},{"locationName":"Radyr","crs":"RDR","st":"11:39","et":"Cancelled"}]}}},{"sta":"11:25","std":"11:26","etd":"On time","platform":"8","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","cancelReason":"This train has been cancelled because of flooding earlier today","delayReason":"This train has been delayed by flooding earlier today","serviceID":"5004715CRDFCEN_","rsid":"AW734400","origin":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"destination":{"location":{"locationName":"Barry Island","crs":"BYI"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Radyr","crs":"RDR","st":"11:11","et":"Cancelled"},{"locationName":"Llandaf","crs":"LLN","st":"11:13","et":"Cancelled"},{"locationName":"Cathays","crs":"CYS","st":"11:17","et":"Cancelled"},{"locationName":"Cardiff Queen Street","crs":"CDQ","st":"11:21","et":"Cancelled"}]}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Grangetown","crs":"GTN","st":"11:30","et":"On time"},{"locationName":"Cogan","crs":"CGN","st":"11:33","et":"On time"},{"locationName":"Eastbrook","crs":"EBK","st":"11:36","et":"On time"},{"locationName":"Dinas Powys","crs":"DNS","st":"11:38","et":"On time"},{"locationName":"Cadoxton","crs":"CAD","st":"11:42","et":"On time"},{"locationName":"Barry Docks","crs":"BYD","st":"11:44","et":"On time"},{"locationName":"Barry","crs":"BRY","st":"11:48","et":"On time"},{"locationName":"Barry Island","crs":"BYI","st":"11:54","et":"On time"}]}}},{"sta":"11:30","eta":"On time","std":"11:31","etd":"On time","platform":"6","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","serviceID":"5005593CRDFCEN_","origin":{"location":{"locationName":"Penarth","crs":"PEN"}},"destination":{"location":{"locationName":"Bargoed","crs":"BGD"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Penarth","crs":"PEN","st":"11:18","at":"On time"},{"locationName":"Dingle Road","crs":"DGL","st":"11:20","et":"On time"},{"locationName":"Grangetown","crs":"GTN","st":"11:24","et":"On time"}]}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Cardiff Queen Street","crs":"CDQ","st":"11:35","et":"On time"},{"locationName":"Heath High Level","crs":"HHL","st":"11:40","et":"On time"},{"locationName":"Llanishen","crs":"LLS","st":"11:43","et":"On time"},{"locationName":"Lisvane & Thornhill","crs":"LVT","st":"11:46","et":"On time"},{"locationName":"Caerphilly","crs":"CPH","st":"11:52","et":"On time"},{"locationName":"Aber","crs":"ABE","st":"11:55","et":"On time"},{"locationName":"Llanbradach","crs":"LNB","st":"11:59","et":"On time"},{"locationName":"Ystrad Mynach","crs":"YSM","st":"12:06","et":"On time"},{"locationName":"Hengoed","crs":"HNG","st":"12:09","et":"On time"},{"locationName":"Pengam","crs":"PGM","st":"12:13","et":"On time"},{"locationName":"Bargoed","crs":"BGD","st":"12:20","et":"On time"}]}}},{"sta":"11:30","eta":"On time","std":"11:32","etd":"On time","platform":"8","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","delayReason":"This train has been delayed by flooding","serviceID":"5005918CRDFCEN_","origin":{"location":{"locationName":"Rhymney","crs":"RHY"}},"destination":{"location":{"locationName":"Penarth","crs":"PEN"}},"previousCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Rhymney","crs":"RHY","st":"10:27","at":"10:32"},{"locationName":"Pontlottyn","crs":"PLT","st":"10:30","at":"10:36"},{"locationName":"Tir-phil","crs":"TIR","st":"10:35","at":"10:40"},{"locationName":"Brithdir","crs":"BHD","st":"10:37","at":"10:43"},{"locationName":"Bargoed","crs":"BGD","st":"10:44","at":"10:47"},{"locationName":"Pengam","crs":"PGM","st":"10:49","at":"10:51"},{"locationName":"Hengoed","crs":"HNG","st":"10:53","at":"10:55"},{"locationName":"Ystrad Mynach","crs":"YSM","st":"10:56","at":"On time"},{"locationName":"Llanbradach","crs":"LNB","st":"11:00","at":"11:03"},{"locationName":"Energlyn & Churchill Park","crs":"ECP","st":"11:04","at":"No report"},{"locationName":"Aber","crs":"ABE","st":"11:06","at":"11:09"},{"locationName":"Caerphilly","crs":"CPH","st":"11:10","at":"11:12"},{"locationName":"Lisvane & Thornhill","crs":"LVT","st":"11:14","at":"11:17"},{"locationName":"Llanishen","crs":"LLS","st":"11:16","at":"11:20"},{"locationName":"Heath High Level","crs":"HHL","st":"11:19","at":"11:23"},{"locationName":"Cardiff Queen Street","crs":"CDQ","st":"11:26","et":"On time"}]}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Grangetown","crs":"GTN","st":"11:37","et":"On time"},{"locationName":"Dingle Road","crs":"DGL","st":"11:41","et":"On time"},{"locationName":"Penarth","crs":"PEN","st":"11:46","et":"On time"}]}}},{"std":"11:34","etd":"On time","platform":"0","operator":"Transport for Wales","operatorCode":"AW","serviceType":"train","serviceID":"4987205CRDFCEN_","origin":{"location":{"locationName":"Cardiff Central","crs":"CDF"}},"destination":{"location":{"locationName":"Ebbw Vale Town","crs":"EBB"}},"subsequentCallingPoints":{"callingPointList":{"callingPoint":[{"locationName":"Pye Corner","crs":"PYE","st":"11:53","et":"On time"},{"locationName":"Rogerstone","crs":"ROR","st":"11:57","et":"On time"},{"locationName":"Risca & Pontymister","crs":"RCA","st":"12:01","et":"On time"},{"locationName":"Crosskeys","crs":"CKY","st":"12:06","et":"On time"},{"locationName":"Newbridge","crs":"NBE","st":"12:14","et":"On time"},{"locationName":"Llanhilleth","crs":"LTH","st":"12:20","et":"On time"},{"locationName":"Ebbw Vale Parkway","crs":"EBV","st":"12:29","et":"On time"},{"locationName":"Ebbw Vale Town","crs":"EBB","st":"12:35","et":"On time"}]}}}]}}} \ No newline at end of file diff --git a/.test-tools/NO-SERVICES_API-EG-pil.json b/.test-tools/NO-SERVICES_API-EG-pil.json new file mode 100644 index 0000000..fa88406 --- /dev/null +++ b/.test-tools/NO-SERVICES_API-EG-pil.json @@ -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 Latest Travel News."},"platformAvailable":"true"}} \ No newline at end of file diff --git a/static/board.html b/static/board.html index ed658ce..ca6b3dd 100644 --- a/static/board.html +++ b/static/board.html @@ -23,7 +23,7 @@

- 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.

@@ -33,13 +33,16 @@

Loading

-
+

Oops

There was an error with your request

The station you are searching for cannot be found

The station has no data. It may not be in operation yet/anymore.

Connection Error, check your data connection. Retrying.

+
+

There are no scheduled services from this station

+
diff --git a/static/js/board.js b/static/js/board.js index 5034f1c..b5b0c4b 100644 --- a/static/js/board.js +++ b/static/js/board.js @@ -40,7 +40,7 @@ async function publicLdb(stn) { return await resp.json(); } -async function setHeaders(title,time){ +async function setHeaders(title,time) { var prefix = `OwlBoard - ` document.title = `${prefix}${title}` document.getElementById("station_name").innerHTML = title @@ -71,12 +71,13 @@ async function parseLdb(data) { } } -// Hide all loading classes -async function clearLoading(){ +// Hide loading spinner +async function clearLoading() { document.getElementById("loading").style = "display: none;"; } -async function buildPage(data){ +// Build and Display Functions +async function buildPage(data) { var stationName = data.GetStationBoardResult.locationName; log(`buildPage: Data ready for ${stationName}`); var generateTime = new Date(await data.GetStationBoardResult.generatedAt); @@ -86,9 +87,14 @@ async function buildPage(data){ if (data.GetStationBoardResult.nrccMessages) { 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) { // Input: data.GetStationBoardResult.nrccMessages.messages // Processing: For each message, create a

inside #notices. // If there is more than one notice, scroll between them. @@ -96,6 +102,15 @@ async function displayNotices(notices){ //document.getElementById("notices").innerHTML = notices; } +async function displayNoTrains() { + document.getElementById('no_services').style = "display: block;"; + clearLoading(); +} + +async function displayTrains() { + return +} + // Log Helper function log(msg) { var time = new Date().toISOString(); diff --git a/static/styles/boards.css b/static/styles/boards.css index f94db6a..0c43496 100644 --- a/static/styles/boards.css +++ b/static/styles/boards.css @@ -39,8 +39,8 @@ font-weight: bolder; } -/* Error Notices: */ -.hidden-unless-error { +/* Main Notices: */ +.main-notice { display: none; margin-top: 150px; }