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