vector-im-hydrogen-web/index.html

75 lines
3.4 KiB
HTML
Raw Normal View History

2019-02-06 23:04:39 +01:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
2020-08-12 11:42:42 +02:00
<meta name="application-name" content="Hydrogen Chat"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
2020-08-12 11:42:42 +02:00
<meta name="apple-mobile-web-app-title" content="Hydrogen Chat">
<meta name="description" content="A matrix chat application">
2020-10-15 11:17:33 +02:00
<link rel="apple-touch-icon" href="assets/icon-maskable.png">
<link rel="stylesheet" type="text/css" href="src/ui/web/css/main.css">
<link rel="stylesheet" type="text/css" href="src/ui/web/css/themes/element/theme.css" title="Element Theme">
<link rel="alternate stylesheet" type="text/css" href="src/ui/web/css/themes/bubbles/theme.css" title="Bubbles Theme">
2019-02-06 23:04:39 +01:00
</head>
2020-08-12 11:42:42 +02:00
<body class="hydrogen">
<script id="version" type="disabled">
2020-08-12 11:42:42 +02:00
window.HYDROGEN_VERSION = "%%VERSION%%";
window.HYDROGEN_GLOBAL_HASH = "%%GLOBAL_HASH%%";
</script>
<script id="main" type="module">
2020-08-12 11:49:42 +02:00
import {main} from "./src/main.js";
main(document.body, {
worker: "src/worker.js",
olm: {
wasm: "lib/olm/olm.wasm",
legacyBundle: "lib/olm/olm_legacy.js",
wasmBundle: "lib/olm/olm.js",
}
});
2019-02-10 21:25:29 +01:00
</script>
2020-10-15 19:12:16 +02:00
<script id="service-worker" type="module">
function workerMessage(worker, type) {
const body = {type, id: Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)};
let resolve;
const promise = new Promise(r => resolve = r);
const onMessage = function(event) {
if (event.data.replyTo === body.id) {
2020-10-15 21:35:10 +02:00
navigator.serviceWorker.removeEventListener("message", onMessage);
2020-10-15 19:12:16 +02:00
resolve(event.data.content);
}
}
2020-10-15 21:35:10 +02:00
navigator.serviceWorker.addEventListener("message", onMessage);
2020-10-15 19:12:16 +02:00
worker.postMessage(body);
return promise;
}
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js').then(function(registration) {
2020-10-15 11:49:09 +02:00
console.log("Service Worker registered");
2020-10-15 19:12:16 +02:00
async function tryActivateUpdate() {
if (registration.waiting && registration.active) {
2020-10-15 19:12:16 +02:00
const version = await workerMessage(registration.waiting, "version");
if (confirm(`Version ${version.version} (${version.buildHash}) is ready to install. Apply now?`)) {
registration.waiting.postMessage({type: "skipWaiting"}); // will trigger controllerchange event
}
}
}
tryActivateUpdate();
2020-10-15 11:49:09 +02:00
registration.onupdatefound = function() {
const newWorker = registration.installing;
newWorker.onstatechange = function() {
tryActivateUpdate();
2020-10-15 11:49:09 +02:00
}
};
});
2020-10-15 19:12:16 +02:00
navigator.serviceWorker.addEventListener("controllerchange", function() {
document.location.reload();
});
}
2020-08-13 17:59:10 +02:00
</script>
2019-02-06 23:04:39 +01:00
</body>
2019-02-26 22:45:58 +01:00
</html>