pis #2
41
auth.html
Normal file
41
auth.html
Normal 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
38
js/auth.js
Normal 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
4
sw.js
@ -1,10 +1,11 @@
|
||||
/* Service Worker */
|
||||
|
||||
const appVersion = "1.2.4"
|
||||
const appVersion = "1.3.0"
|
||||
const cacheName = `owlboard-${appVersion}`;
|
||||
const cacheIDs = [cacheName];
|
||||
const cacheFiles = [
|
||||
"/404.html",
|
||||
"/auth.html",
|
||||
"/board.html",
|
||||
"/conn-err.html",
|
||||
"/help.html",
|
||||
@ -28,6 +29,7 @@ const cacheFiles = [
|
||||
"/js/issue.js",
|
||||
"/js/lib.board.js",
|
||||
"/js/lib.main.js",
|
||||
"/js/auth.js",
|
||||
"/js/settings.js",
|
||||
"/js/simple-board.js",
|
||||
"/images/icon.svg",
|
||||
|
Reference in New Issue
Block a user