diff --git a/js/lib.main.js b/js/lib.main.js index 16a84b5..c443cdf 100644 --- a/js/lib.main.js +++ b/js/lib.main.js @@ -151,7 +151,7 @@ async function getApi(path,auth = false) { log(`resp.status: ${resp.status}`) log(`resp.json: ${json}`) if (resp.status != 200) { - return false + return resp.status } if (!resp.ok) { return false diff --git a/js/pis.js b/js/pis.js index 97cfb88..66fa9e1 100644 --- a/js/pis.js +++ b/js/pis.js @@ -9,7 +9,9 @@ async function findByOrigDest() { const endpoint = `pis/origdest/${formData.origin}/${formData.destination}` const json = await getApi(endpoint, auth = true) if (json == false) { - await noData() + await displayNoData() + } else if (json == 401) { + await displayUnauthorised() } else { await insertData(json) } @@ -45,11 +47,16 @@ async function insertData(json) { document.getElementById('result-count').textContent = results.toString() } -async function noData() { +async function displayNoData() { const msg = '

No results found

' document.getElementById('result-box').insertAdjacentHTML("beforeend", msg) } +async function displayUnauthorised() { + const msg = '

Unauthorised - please ensure you are logged into the rail staff version

' + document.getElementById('result-box').insertAdjacentHTML("beforeend", msg) +} + async function reset() { document.getElementById('origin').value = "" document.getElementById('destination').value = "" diff --git a/pis.html b/pis.html index be5505a..920f643 100644 --- a/pis.html +++ b/pis.html @@ -45,13 +45,19 @@

Enter a services start and end station CRS codes to see code options and stopping patterns.

-

Currently supported (Beta): GWR Bristol Metro region only.

+

Currently supported (Beta): GWR: Bristol Metro, WOS & CDF Southbound.

You need to be logged into a free rail staff version account for this feature.

-
-

-
-

- +
+
+
+ +
+
+
+

+
+
+
diff --git a/styles/pis.css b/styles/pis.css index 9ad13f0..e486351 100644 --- a/styles/pis.css +++ b/styles/pis.css @@ -1,5 +1,12 @@ -#crs-boxes { - display: block; +#crs-inputs { + display: flex; + justify-content: center; +} + +.pis-input { + width: 55%; + max-width: 200px; + margin: auto; } #result-box { @@ -19,7 +26,7 @@ td, th { } #reset { - margin-top: 25px + margin-top: 15px } #reset {