63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
const APP_VERSION = __APP_VERSION__;
|
|
const APP_BUILD_TIME = __APP_BUILD_TIME__;
|
|
|
|
import "./styles.css";
|
|
|
|
import Typed from "typed.js";
|
|
|
|
import Tippy from 'tippy.js';
|
|
|
|
import 'tippy.js/dist/tippy.css';
|
|
import 'tippy.js/animations/scale.css';
|
|
|
|
window.addEventListener("DOMContentLoaded", (_ev) => {
|
|
new Typed(document.querySelector("description") ?? "description", {
|
|
stringsElement: "#description-list",
|
|
shuffle: true,
|
|
typeSpeed: 60,
|
|
backDelay: 2000,
|
|
fadeOut: true,
|
|
loop: true,
|
|
showCursor: true,
|
|
smartBackspace: true,
|
|
});
|
|
|
|
document.querySelectorAll("[alt]").forEach((Elem) => {
|
|
Tippy(Elem, {
|
|
content: Elem.getAttribute("alt") ?? "",
|
|
})
|
|
});
|
|
|
|
// @ts-expect-error
|
|
document.querySelector(
|
|
"#footer > div"
|
|
).innerHTML += `<a alt="Update Commit" href="https://git.186526.xyz/186526/home-app/src/commit/${APP_VERSION}"><img alt="Update Commit" src="https://186526.xyz/shields.io/badge/commit-${APP_VERSION}-blue" /></a> <img alt="Latest Update" src="https://186526.xyz/shields.io/date/${APP_BUILD_TIME}?color=sucessful&label=latest%20update" />`;
|
|
|
|
// @ts-expect-error
|
|
document.querySelector("#footer").innerHTML = document.querySelector("#footer")?.innerHTML.replaceAll("unknown",__APP_BUILD_MACHINE__);
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
navigator.serviceWorker
|
|
.register("./sw.js", {
|
|
scope: "/",
|
|
})
|
|
.then(function (registration) {
|
|
console.log(
|
|
"ServiceWorker registration successful with scope: ",
|
|
registration.scope
|
|
);
|
|
})
|
|
.catch(function (err) {
|
|
console.warn("ServiceWorker registration failed: ", err);
|
|
});
|
|
let refreshing = false;
|
|
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
if (refreshing) {
|
|
return;
|
|
}
|
|
refreshing = true;
|
|
window.location.reload();
|
|
});
|
|
}
|
|
});
|