diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index e69de29..a92f229 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -0,0 +1 @@ +# Build and push docker container to repository \ No newline at end of file diff --git a/js/pis.js b/js/pis.js index b694346..a7efc91 100644 --- a/js/pis.js +++ b/js/pis.js @@ -23,12 +23,55 @@ async function findByOrigDest() { hideLoading() } +async function findByPisCode() { + showLoading() + const formData = await fetchPisCode() + log(`findByPisCode: Searching for PIS Code ${formData}`) + const endpoint = `pis/code/${formData}` + console.time('findByPisCode-GET') + const json = await getApi(endpoint, auth = true) + console.timeEnd('findByPisCode-GET') + if (json == false) { + await displayNoData() + } else if (json == 401) { + await displayUnauthorised() + } else { + await insertData(json) + } + document.getElementById('crs-box').style = 'display:none' + document.getElementById('result-box').style = 'display:block' + hideLoading() +} + +async function findRandomCode() { + showLoading() + log('findRandomCode: Fetching random PIS codes') + const endpoint = 'pis/random' + console.time('findRandomCode-GET') + const json = await getApi(endpoint, auth = true) + console.timeEnd('findRandomCode-GET') + if (json == false) { + await displayNoData() + } else if (json == 401) { + await displayUnauthorised() + } else { + await insertData(json) + } + document.getElementById('crs-box').style = 'display:none' + document.getElementById('result-box').style = 'display:block' + hideLoading() +} + async function fetchOrigDest() { var orig = document.getElementById('origin').value var dest = document.getElementById('destination').value return {origin: orig, destination: dest} } +async function fetchPisCode() { + return document.getElementById('pis').value +} + async function insertData(json) { // Receives the JSON Respose ([{},{}]) containing one or more possible // PIS codes. Display the code and the stops with a method of scrolling between them. @@ -66,6 +109,7 @@ async function reset() { try { document.getElementById('origin').value = '' document.getElementById('destination').value = '' + document.getElementById('pis').value = '' document.getElementById('result-box').style = 'display:none' document.getElementById('result-table').remove() document.getElementById('crs-box').style = 'display:block' diff --git a/pis.html b/pis.html index 5cfb1cc..c383874 100644 --- a/pis.html +++ b/pis.html @@ -43,9 +43,9 @@
-

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

Currently supported (Beta): GWR: ex-Wessex, HEx
Duplicate stopping patterns have been removed.

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

+

Search by CRS Codes

@@ -59,6 +59,16 @@
+

Search by PIS Code

+
+
+
+
+

+
+
+ +