Prepare for migration to new site

This commit is contained in:
Fred Boniface 2023-07-01 22:17:07 +01:00
parent 5f710832b0
commit 64be61f62d
9 changed files with 12 additions and 11 deletions

View File

@ -62,7 +62,7 @@
</div>
<div class="text-description">
<p>New feature: <a href="./pis.html">Find PIS by Headcode</a></p>
<p>Coming Soon: Staff Depature Boards &amp; Live Train Data</p>
<p>Later this month: New website &amp; Staff Departure Boards</p>
<p>Customise your quick links on the <a href="./settings.html">Settings</a> page.</p>
</div>
<!-- Footer -->

View File

@ -21,7 +21,7 @@ async function cmdOut(message) {
}
async function registerKey(key) { // Posts key to server and listens for response.
const url = `${window.location.origin}/api/v1/register/register`
const url = `${apiEndpoint}/v1/register/register`
const res = await fetch(url, { // The response will contain the UUID which will be registered
method: 'POST',
headers: {
@ -37,7 +37,7 @@ async function registerKey(key) { // Posts key to server and listens for respons
}
async function checkAuth(key) {
const url = `${window.location.origin}/api/v1/auth/test`
const url = `${apiEndpoint}/v1/auth/test`
const res = await fetch(url, {
method: 'GET',
redirect: 'follow',

View File

@ -51,7 +51,7 @@ async function parseData(values){
async function getData(type, value){
log(`find-code.getData: Looking for: ${type} '${value}'`, 'INFO')
try {
var url = `${window.location.origin}/api/v1/find/${type}/${value}`
var url = `${apiEndpoint}/v1/find/${type}/${value}`
var resp = await fetch(url)
return await resp.json()
} catch (err) {

View File

@ -73,7 +73,7 @@ async function send() {
redirect: 'follow',
body: payload
}
var res = await fetch(`${window.location.origin}/api/v1/issue`, opt)
var res = await fetch(`${apiEndpoint}/v1/issue`, opt)
if (res.status == 200) {
setLoadingDesc('Success')
vibe('ok')

View File

@ -1,7 +1,7 @@
/* eslint-disable no-unused-vars */
/* Fetch Functions */
async function publicLdb(stn) {
var url = `${window.location.origin}/api/v1/ldb/${stn}`
var url = `${apiEndpoint}/v1/ldb/${stn}`
console.time('Time: Fetch LDB Data')
var resp = await fetch(url)
console.timeEnd('Time: Fetch LDB Data')

View File

@ -1,6 +1,7 @@
/* eslint-disable no-unused-vars */
/* All Page Init */
const version = '2023.6.6'
const version = '2023.6.7'
const apiEndpoint = 'https://owlboard.info/api'
/* Feature Detectors */
@ -129,7 +130,7 @@ async function getQuery(param) {
async function getApi(path,auth = false) {
let apiVer = 'v1'
let url = `${window.location.origin}/api/${apiVer}/${path}`
let url = `${apiEndpoint}/${apiVer}/${path}`
log(`getApi: Fetching from endpoint: ${url}, Auth=${auth}`)
let options
if (auth) {

View File

@ -78,7 +78,7 @@ async function isRegistered() { // Check if a device is registered, returns BOOL
async function register() { // Registers a device by sending POST request to API Server
if (! await isRegistered()) {
showLoading()
let url = `${window.location.origin}/api/v1/register/request`
let url = `${apiEndpoint}/v1/register/request`
let email = document.getElementById('eml').value
let res = await fetch(url, {
method: 'POST',

View File

@ -7,7 +7,7 @@ async function init() { // The page init function
}
async function get() { // Fetch data from API
var url = `${window.location.origin}/api/v1/stats`
var url = `${apiEndpoint}/api/v1/stats`
var resp = await fetch(url)
return await resp.json()
}

View File

@ -40,7 +40,7 @@ async function displayOptions(data) {
log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug')
let button = `
<button class='service_button' onclick='displayOne(data[${service}])'>
<span class='service_toc'>GW</span>
<span class='service_toc'>${serviceData?.operator || 'GW'}</span>
<span class='service_origin_time'>${serviceData['stops'][0]['wttDeparture']}</span>
<span class='service_origin_tiploc'>${serviceData['stops'][0]['tiploc']}</span>
to