2021-05-12 16:01:04 +01:00
|
|
|
"use strict";
|
2021-04-15 13:01:58 +01:00
|
|
|
|
2021-04-18 11:28:55 +01:00
|
|
|
// JS & CSS
|
|
|
|
|
2021-05-10 11:35:14 +01:00
|
|
|
/* eslint-disable */
|
2022-01-07 14:11:14 +00:00
|
|
|
import UIkit from "uikit";
|
2021-05-12 15:25:25 +01:00
|
|
|
// Don't Sort These!
|
2022-01-07 14:11:14 +00:00
|
|
|
import Icons from "uikit/dist/js/uikit-icons";
|
2021-05-10 11:35:14 +01:00
|
|
|
// @ts-ignore
|
2021-04-15 13:01:58 +01:00
|
|
|
UIkit.use(Icons);
|
|
|
|
|
2021-05-08 03:28:37 +01:00
|
|
|
import Prism from "prismjs";
|
2021-05-12 15:22:08 +01:00
|
|
|
// Don't Sort These!
|
2021-05-26 12:38:40 +01:00
|
|
|
import "prismjs/components/prism-hcl";
|
2022-01-13 18:09:03 +00:00
|
|
|
import "prismjs/components/prism-javascript";
|
2022-01-06 23:02:34 +00:00
|
|
|
import "prismjs/components/prism-json";
|
2021-05-12 15:22:08 +01:00
|
|
|
|
2021-04-15 13:01:58 +01:00
|
|
|
Prism.highlightAll();
|
2021-05-03 09:30:22 +01:00
|
|
|
/* eslint-enable */
|
2021-04-15 13:01:58 +01:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
// @ts-ignore
|
|
|
|
import translations from "./translations/index.mjs";
|
2021-05-14 13:38:29 +01:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
// Actual Imports
|
2021-05-14 13:38:29 +01:00
|
|
|
import { formatDistance } from "./formatDistance";
|
2022-01-06 18:53:38 +00:00
|
|
|
//import { pageList } from "./allPages";
|
2022-01-07 15:55:15 +00:00
|
|
|
import { Main } from "./pages";
|
2022-01-06 23:02:34 +00:00
|
|
|
import { NavBar } from "./ui/elements/NavBar";
|
2022-01-11 12:45:35 +00:00
|
|
|
import { ThemeLoader } from "./ThemeLoader";
|
2022-01-07 15:27:10 +00:00
|
|
|
import { api } from "./globalAPI";
|
2022-01-07 15:55:15 +00:00
|
|
|
import { getCurrentUrl, route } from "preact-router";
|
2022-01-06 23:02:34 +00:00
|
|
|
import { playground } from "./playground";
|
2022-01-07 15:55:15 +00:00
|
|
|
import { render } from "preact";
|
|
|
|
import { settings } from "./globalSettings";
|
2022-01-06 23:02:34 +00:00
|
|
|
import i18next from "i18next";
|
2021-05-12 15:25:25 +01:00
|
|
|
|
2021-05-12 17:37:09 +01:00
|
|
|
async function onLoad(): Promise<void> {
|
2022-01-07 14:26:21 +00:00
|
|
|
document.documentElement.dir = settings.pageDirection;
|
2022-01-06 22:57:12 +00:00
|
|
|
|
2021-05-24 09:48:13 +01:00
|
|
|
render(
|
|
|
|
<>
|
2022-01-11 10:57:30 +00:00
|
|
|
<ThemeLoader />
|
2022-01-06 18:53:38 +00:00
|
|
|
<NavBar />
|
2021-05-24 09:48:13 +01:00
|
|
|
<div class="uk-container uk-container-medium uk-align-center">
|
|
|
|
<div class="uk-card uk-card-body">
|
2022-01-06 18:53:38 +00:00
|
|
|
<Main />
|
2021-05-24 09:48:13 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>,
|
|
|
|
document.body,
|
2021-05-12 16:01:04 +01:00
|
|
|
);
|
2021-04-17 10:56:44 +01:00
|
|
|
|
2021-05-07 20:41:40 +01:00
|
|
|
if (process.env.NODE_ENV == "development") {
|
2022-01-07 13:14:25 +00:00
|
|
|
await playground();
|
2021-05-07 20:41:40 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 15:27:10 +00:00
|
|
|
setInterval(async () => {
|
|
|
|
console.log(getCurrentUrl());
|
|
|
|
if (getCurrentUrl() != "/unseal") {
|
|
|
|
// TODO: check if api is accessable, not if its not set
|
|
|
|
if (settings.apiURL.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const sealStatus = await api.getSealStatus();
|
|
|
|
if (sealStatus.sealed) {
|
|
|
|
route("/unseal", false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 5000);
|
2021-04-24 16:26:31 +01:00
|
|
|
}
|
2021-04-18 11:28:55 +01:00
|
|
|
|
2021-05-12 16:01:04 +01:00
|
|
|
document.addEventListener(
|
|
|
|
"DOMContentLoaded",
|
2021-05-16 12:37:23 +01:00
|
|
|
async () => {
|
2021-05-12 16:01:04 +01:00
|
|
|
console.log("Loading...");
|
|
|
|
// @ts-expect-error
|
|
|
|
console.log("Build Data:", BUILD_STRING);
|
2021-05-16 12:37:23 +01:00
|
|
|
await i18next.init({
|
2022-01-07 14:26:21 +00:00
|
|
|
lng: settings.language,
|
2021-05-16 12:37:23 +01:00
|
|
|
fallbackLng: "en",
|
|
|
|
debug: true,
|
|
|
|
// @ts-ignore
|
|
|
|
resources: Object.fromEntries(
|
|
|
|
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
|
|
|
|
),
|
|
|
|
interpolation: {
|
2021-05-22 09:50:55 +01:00
|
|
|
escape: (str) => {
|
|
|
|
return str;
|
|
|
|
},
|
2021-05-16 12:37:23 +01:00
|
|
|
format: function (value: unknown, format, _): string {
|
|
|
|
if (format === "until_date" && value instanceof Date)
|
2022-01-07 14:26:21 +00:00
|
|
|
return formatDistance(new Date(), new Date(value), settings.language);
|
2021-05-16 12:37:23 +01:00
|
|
|
return value as string;
|
2021-05-12 16:01:04 +01:00
|
|
|
},
|
2021-05-16 12:37:23 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
await onLoad();
|
2021-05-12 16:01:04 +01:00
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|