pis #2

Merged
fred.boniface merged 76 commits from pis into main 2023-05-06 21:53:45 +01:00
3 changed files with 82 additions and 1 deletions
Showing only changes of commit 689340dbb4 - Show all commits

41
auth.html Normal file
View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="description" content="OwlBoard - Live train departures for traincrew."/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="OwlBoard">
<meta name="author" content="Frederick Boniface">
<meta name="theme-color" content="#00b7b7">
<link rel="apple-touch-icon" href="/images/app-icons/any/apple-192.png">
<link rel="stylesheet" type="text/css" href="./styles/main.css"/>
<link rel="icon" type="image/svg+xml" href="./images/icon.svg"/>
<link rel="manifest" type="application/json" href="./manifest.json"/>
<script src="./js/lib.main.js" defer></script>
<script src="./js/auth.js" defer></script>
<title>OwlBoard</title>
</head>
<body>
<!-- Loading Box -->
<div id="loading">
<div class="spinner">
</div>
<p id="loading_desc">Registering</p>
</div>
<!-- Main Content Begins -->
<picture>
<source srcset="./images/logo/wide_logo.svg" type="image/svg+xml">
<source media="(max-height: 739px)" srcset="./images/logo/logo-full-200.png" type="image/png">
<source srcset="./images/logo/logo-full-250.png" type="image/png">
<img class="titleimg" src="./images/logo/logo-full-250.png" alt="OwlBoard Logo">
</picture>
<div>
<p id="cmd"></p>
</div>
<!-- Footer -->
<footer>
<p>Created by <a href="https://fredboniface.co.uk" target="_blank" rel="noreferrer noopener">Fred Boniface</a> - <span id="ver_str">1.2.4</span></p>
</footer>
</body>
</html>

38
js/auth.js Normal file
View File

@ -0,0 +1,38 @@
const cmd = document.getElementById("cmd")
init();
async function sendHome(){
await delay(2000);
location.replace('/')
}
async function cmdOut(message) {
html = "<p>" + message + "</p>"
cmd.insertAdjacentHTML("beforeend", html)
}
async function registerKey(key) {
var url = `${window.location.origin}/api/v1/auth/register`;
let res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
redirect: "follow",
body: JSON.stringify(key)
})
if (res.JSON['result'] == "ok"){
return true;
} else {
return false;
}
}
async function init(){
cmdOut("Reading registration key");
const key = await getQuery("key");
cmdOut(`Key: ${key}`)
cmdOut("Requesting API Key from server");
let res = await registerKey(key);
console.log(JSON.stringify(res))
}

4
sw.js
View File

@ -1,10 +1,11 @@
/* Service Worker */ /* Service Worker */
const appVersion = "1.2.4" const appVersion = "1.3.0"
const cacheName = `owlboard-${appVersion}`; const cacheName = `owlboard-${appVersion}`;
const cacheIDs = [cacheName]; const cacheIDs = [cacheName];
const cacheFiles = [ const cacheFiles = [
"/404.html", "/404.html",
"/auth.html",
"/board.html", "/board.html",
"/conn-err.html", "/conn-err.html",
"/help.html", "/help.html",
@ -28,6 +29,7 @@ const cacheFiles = [
"/js/issue.js", "/js/issue.js",
"/js/lib.board.js", "/js/lib.board.js",
"/js/lib.main.js", "/js/lib.main.js",
"/js/auth.js",
"/js/settings.js", "/js/settings.js",
"/js/simple-board.js", "/js/simple-board.js",
"/images/icon.svg", "/images/icon.svg",