fix some web stuff

This commit is contained in:
eta 2023-01-14 00:55:43 +00:00
parent 4924b13893
commit e06ba28b42
2 changed files with 21 additions and 4 deletions

View File

@ -7,6 +7,7 @@
<link rel="stylesheet" href="./govuk.css"/>
</head>
<body class="govuk-template__body">
<script src="./bootstrap.js"></script>
<a href="#main-content" class="govuk-skip-link">Skip to main content</a>
<header class="govuk-header" role="banner">
<div class="govuk-header__container govuk-width-container" style="border-bottom: 10px solid #1d70b8;">
@ -155,6 +156,5 @@
</div>
</div>
</footer>
<script src="./bootstrap.js"></script>
</body>
</html>

View File

@ -1,3 +1,8 @@
// To do before release:
// - fix double scan bug
// - reservations!!
// - minification
console.log("[+] Wow, JavaScript!");
import * as wasm from "rsp6-decoder";
import { BrowserAztecCodeReader } from '@zxing/library';
@ -6,8 +11,13 @@ let stations = require("./stations.json");
let fares = require("./fares.json");
window.stations = stations;
window.fares = fares;
let loaded = false;
window.addEventListener('load', function () {
function onload() {
if (loaded) {
return;
}
loaded = true;
console.log("[+] initialising wasm");
window.wasm = wasm;
window.wasm.init();
@ -188,7 +198,7 @@ window.addEventListener('load', function () {
error_banner.style.display = "none";
handleTicket(result);
}).catch((err) => {
error("Scanner failed", "Couldn't start the camera.<br/><pre>" + err + "</pre>");
error("Scanner failed", "Looks like the barcode scanner failed in some way. If this keeps happening, try reloading the page or using one of the alternative options.<br/><pre>" + err + "</pre>");
console.error(err);
});
video_div.style.display = "block";
@ -242,5 +252,12 @@ window.addEventListener('load', function () {
});
}
});
}
})
if (document.readyState == 'complete') {
console.log("[+] Loaded already!");
onload();
}
else {
window.addEventListener('load', onload);
}