Compare commits

..

No commits in common. "a7b8fb36d4ca72e77708d129ced0fe2d156b5f41" and "218e95b0487e5c2c84f82ea2aa1a2a3147e38c2f" have entirely different histories.

7 changed files with 16 additions and 36 deletions

View File

@ -151,7 +151,7 @@ async function getApi(path,auth = false) {
log(`resp.status: ${resp.status}`)
log(`resp.json: ${json}`)
if (resp.status != 200) {
return resp.status
return false
}
if (!resp.ok) {
return false

View File

@ -7,11 +7,9 @@ async function findByOrigDest() {
const formData = await fetchOrigDest()
log(`findByOrigDest: Searching for PIS Code for ${JSON.stringify(formData)}`)
const endpoint = `pis/origdest/${formData.origin}/${formData.destination}`
const json = await getApi(endpoint, auth = true)
const json = await getApi(endpoint)
if (json == false) {
await displayNoData()
} else if (json == 401) {
await displayUnauthorised()
await noData()
} else {
await insertData(json)
}
@ -47,16 +45,11 @@ async function insertData(json) {
document.getElementById('result-count').textContent = results.toString()
}
async function displayNoData() {
async function noData() {
const msg = '<p id="result-table">No results found</p>'
document.getElementById('result-box').insertAdjacentHTML("beforeend", msg)
}
async function displayUnauthorised() {
const msg = '<p id="result-table">Unauthorised - please ensure you are logged into the <a href="./settings.html">rail staff version</a></p>'
document.getElementById('result-box').insertAdjacentHTML("beforeend", msg)
}
async function reset() {
document.getElementById('origin').value = ""
document.getElementById('destination').value = ""

View File

@ -1,7 +1,6 @@
init();
async function init() { // The page init function
versionDisplay()
display(await get())
}
@ -27,4 +26,5 @@ async function display(data) { // Parses and displays data from API
document.getElementById('meta').textContent = dat.meta || "0";
document.getElementById('pis').textContent = dat.pis
document.getElementById('ver-dbman').textContent = ver.dbmanager || "Unknown";
document.getElementById('ver-web').textContent = localStorage.getItem('ver-web') || "Unknown";
}

View File

@ -45,19 +45,13 @@
<div id="crs-box">
<p>Enter a services start and end station CRS codes to see code options and
stopping patterns.</p>
<p>Currently supported (Beta): GWR: Bristol Metro, WOS & CDF Southbound.</p>
<p>Currently supported (Beta): GWR Bristol Metro region only.</p>
<p id="auth-required">You need to be logged into a free <a href="./settings.html">rail staff version</a> account for this feature.</p>
<form id = "crs-inputs" action="javascript:findByOrigDest();">
<div class="crs-input">
<label for="origin">From:</label><br>
<input type="text" class="small-lookup-box pis-input" id="origin" name="origin" maxlength="3">
</div>
<div class="crs-input">
<label for="destination">To:</label><br>
<input type="text" class="small-lookup-box pis-input" id="destination" name="destination" maxlength="3"><br><br>
</div>
</form>
<input type="submit" value="Find" class="lookup-button">
<label for="origin">Origin:</label><br>
<input type="text" class="small-lookup-box" id="origin" name="origin" maxlength="3"><br><br>
<label for="destination">Destination:</label><br>
<input type="text" class="small-lookup-box" id="destination" name="destination" maxlength="3"><br><br>
<input type="submit" value="Find" class="lookup-button" onclick="findByOrigDest()">
</div>
<div id="result-box">

View File

@ -78,7 +78,7 @@
web-frontend
</a>
</td>
<td id="ver_str">Unknown</td>
<td id="ver-web"></td>
</tr>
</table>
<p>The statistics represent hits & queries from all instances in the stack.</p>

View File

@ -1,12 +1,5 @@
#crs-inputs {
display: flex;
justify-content: center;
}
.pis-input {
width: 55%;
max-width: 200px;
margin: auto;
#crs-boxes {
display: block;
}
#result-box {
@ -26,7 +19,7 @@ td, th {
}
#reset {
margin-top: 15px
margin-top: 25px
}
#reset {

2
sw.js
View File

@ -1,6 +1,6 @@
/* Service Worker */
const appVersion = "PIS-DEV-23043001"
const appVersion = "PIS-DEV-23042502"
const cacheName = `owlboard-${appVersion}`;
const cacheIDs = [cacheName];
const cacheFiles = [