Compare commits
No commits in common. "a7b8fb36d4ca72e77708d129ced0fe2d156b5f41" and "218e95b0487e5c2c84f82ea2aa1a2a3147e38c2f" have entirely different histories.
a7b8fb36d4
...
218e95b048
|
@ -151,7 +151,7 @@ async function getApi(path,auth = false) {
|
||||||
log(`resp.status: ${resp.status}`)
|
log(`resp.status: ${resp.status}`)
|
||||||
log(`resp.json: ${json}`)
|
log(`resp.json: ${json}`)
|
||||||
if (resp.status != 200) {
|
if (resp.status != 200) {
|
||||||
return resp.status
|
return false
|
||||||
}
|
}
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
return false
|
return false
|
||||||
|
|
13
js/pis.js
13
js/pis.js
|
@ -7,11 +7,9 @@ async function findByOrigDest() {
|
||||||
const formData = await fetchOrigDest()
|
const formData = await fetchOrigDest()
|
||||||
log(`findByOrigDest: Searching for PIS Code for ${JSON.stringify(formData)}`)
|
log(`findByOrigDest: Searching for PIS Code for ${JSON.stringify(formData)}`)
|
||||||
const endpoint = `pis/origdest/${formData.origin}/${formData.destination}`
|
const endpoint = `pis/origdest/${formData.origin}/${formData.destination}`
|
||||||
const json = await getApi(endpoint, auth = true)
|
const json = await getApi(endpoint)
|
||||||
if (json == false) {
|
if (json == false) {
|
||||||
await displayNoData()
|
await noData()
|
||||||
} else if (json == 401) {
|
|
||||||
await displayUnauthorised()
|
|
||||||
} else {
|
} else {
|
||||||
await insertData(json)
|
await insertData(json)
|
||||||
}
|
}
|
||||||
|
@ -47,16 +45,11 @@ async function insertData(json) {
|
||||||
document.getElementById('result-count').textContent = results.toString()
|
document.getElementById('result-count').textContent = results.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function displayNoData() {
|
async function noData() {
|
||||||
const msg = '<p id="result-table">No results found</p>'
|
const msg = '<p id="result-table">No results found</p>'
|
||||||
document.getElementById('result-box').insertAdjacentHTML("beforeend", msg)
|
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() {
|
async function reset() {
|
||||||
document.getElementById('origin').value = ""
|
document.getElementById('origin').value = ""
|
||||||
document.getElementById('destination').value = ""
|
document.getElementById('destination').value = ""
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
init();
|
init();
|
||||||
|
|
||||||
async function init() { // The page init function
|
async function init() { // The page init function
|
||||||
versionDisplay()
|
|
||||||
display(await get())
|
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('meta').textContent = dat.meta || "0";
|
||||||
document.getElementById('pis').textContent = dat.pis
|
document.getElementById('pis').textContent = dat.pis
|
||||||
document.getElementById('ver-dbman').textContent = ver.dbmanager || "Unknown";
|
document.getElementById('ver-dbman').textContent = ver.dbmanager || "Unknown";
|
||||||
|
document.getElementById('ver-web').textContent = localStorage.getItem('ver-web') || "Unknown";
|
||||||
}
|
}
|
18
pis.html
18
pis.html
|
@ -45,19 +45,13 @@
|
||||||
<div id="crs-box">
|
<div id="crs-box">
|
||||||
<p>Enter a services start and end station CRS codes to see code options and
|
<p>Enter a services start and end station CRS codes to see code options and
|
||||||
stopping patterns.</p>
|
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>
|
<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();">
|
<label for="origin">Origin:</label><br>
|
||||||
<div class="crs-input">
|
<input type="text" class="small-lookup-box" id="origin" name="origin" maxlength="3"><br><br>
|
||||||
<label for="origin">From:</label><br>
|
<label for="destination">Destination:</label><br>
|
||||||
<input type="text" class="small-lookup-box pis-input" id="origin" name="origin" maxlength="3">
|
<input type="text" class="small-lookup-box" id="destination" name="destination" maxlength="3"><br><br>
|
||||||
</div>
|
<input type="submit" value="Find" class="lookup-button" onclick="findByOrigDest()">
|
||||||
<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">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="result-box">
|
<div id="result-box">
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
web-frontend
|
web-frontend
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td id="ver_str">Unknown</td>
|
<td id="ver-web"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p>The statistics represent hits & queries from all instances in the stack.</p>
|
<p>The statistics represent hits & queries from all instances in the stack.</p>
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
#crs-inputs {
|
#crs-boxes {
|
||||||
display: flex;
|
display: block;
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pis-input {
|
|
||||||
width: 55%;
|
|
||||||
max-width: 200px;
|
|
||||||
margin: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#result-box {
|
#result-box {
|
||||||
|
@ -26,7 +19,7 @@ td, th {
|
||||||
}
|
}
|
||||||
|
|
||||||
#reset {
|
#reset {
|
||||||
margin-top: 15px
|
margin-top: 25px
|
||||||
}
|
}
|
||||||
|
|
||||||
#reset {
|
#reset {
|
||||||
|
|
2
sw.js
2
sw.js
|
@ -1,6 +1,6 @@
|
||||||
/* Service Worker */
|
/* Service Worker */
|
||||||
|
|
||||||
const appVersion = "PIS-DEV-23043001"
|
const appVersion = "PIS-DEV-23042502"
|
||||||
const cacheName = `owlboard-${appVersion}`;
|
const cacheName = `owlboard-${appVersion}`;
|
||||||
const cacheIDs = [cacheName];
|
const cacheIDs = [cacheName];
|
||||||
const cacheFiles = [
|
const cacheFiles = [
|
||||||
|
|
Reference in New Issue