From 64be61f62d2f17ca8d404220c25c99932d226e73 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 1 Jul 2023 22:17:07 +0100 Subject: [PATCH] Prepare for migration to new site --- index.html | 2 +- js/auth.js | 4 ++-- js/find-code.js | 2 +- js/issue.js | 2 +- js/lib.board.js | 2 +- js/lib.main.js | 5 +++-- js/settings.js | 2 +- js/stats.js | 2 +- js/train-detail.js | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 3029fa5..8cea01c 100644 --- a/index.html +++ b/index.html @@ -62,7 +62,7 @@

New feature: Find PIS by Headcode

-

Coming Soon: Staff Depature Boards & Live Train Data

+

Later this month: New website & Staff Departure Boards

Customise your quick links on the Settings page.

diff --git a/js/auth.js b/js/auth.js index 880949a..0c79a6a 100644 --- a/js/auth.js +++ b/js/auth.js @@ -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', diff --git a/js/find-code.js b/js/find-code.js index a2625aa..9819cf8 100644 --- a/js/find-code.js +++ b/js/find-code.js @@ -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) { diff --git a/js/issue.js b/js/issue.js index 5d6e217..acd5b21 100644 --- a/js/issue.js +++ b/js/issue.js @@ -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') diff --git a/js/lib.board.js b/js/lib.board.js index 2107011..99fd811 100644 --- a/js/lib.board.js +++ b/js/lib.board.js @@ -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') diff --git a/js/lib.main.js b/js/lib.main.js index 456a1a6..772c5ba 100644 --- a/js/lib.main.js +++ b/js/lib.main.js @@ -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) { diff --git a/js/settings.js b/js/settings.js index 4e72216..e1aa409 100644 --- a/js/settings.js +++ b/js/settings.js @@ -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', diff --git a/js/stats.js b/js/stats.js index 8987bc0..baee89d 100644 --- a/js/stats.js +++ b/js/stats.js @@ -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() } diff --git a/js/train-detail.js b/js/train-detail.js index ef7568c..1d37b8d 100644 --- a/js/train-detail.js +++ b/js/train-detail.js @@ -40,7 +40,7 @@ async function displayOptions(data) { log(`displayOptions: data[${service}] = ${serviceData}`, 'dbug') let button = `