From 6f0c9211f4af9f55615ad8b460f3e74a398929d2 Mon Sep 17 00:00:00 2001 From: ZacAttack Date: Fri, 10 May 2024 02:02:43 -0700 Subject: [PATCH] add getLocaalization and make background use the actual options available --- index.html | 434 +++++++++++++++++++++-------------------------- js/background.ts | 13 +- js/settings.ts | 11 ++ 3 files changed, 210 insertions(+), 248 deletions(-) diff --git a/index.html b/index.html index 0e90665..222068a 100755 --- a/index.html +++ b/index.html @@ -22,255 +22,201 @@ - - Dexrn's Hell Hole - - - - - - - - - - - - - - - -
-
- Loading... - Loading... -

-
-
+ + + Dexrn's Hell Hole + + + + + + + + + + + + + + + + +
+
+ Loading... + Loading... +

+
-
-
-
- - - - -
- -
-
- -
- - -
- -
-
-
-
- - - -
-
-
-
-
-
-
-
+
+
+
+
+ + + + +
+ +
+
+ + Mastodon + + + + \ No newline at end of file diff --git a/js/background.ts b/js/background.ts index b3d7dca..0a92dc8 100644 --- a/js/background.ts +++ b/js/background.ts @@ -23,7 +23,9 @@ SOFTWARE. const bgElement: HTMLDivElement = document.querySelector(".bg")!; const loadingScreen: HTMLDivElement = document.querySelector(".loadingScreen")!; -function setBGTime(hour: number): void { +function setBGTime(): void { + let now = new Date(); + let hour = now.getHours(); if (hour >= 6 && hour < 20 ) { bgElement.style.backgroundImage = "url('https://dexrn.duckdns.org/panorama?time=day')"; @@ -35,10 +37,13 @@ function setBGTime(hour: number): void { export function fadeBG(bgload: boolean | Event): void { if (bgload == true) { - let now = new Date(); - let hour = now.getHours(); if (bgElement) { - setBGTime(hour); + // now we can use timezone stuffs to get time which should be more accurate I think? + // if not then I can exclude timestamp iirc and the server should localize it's timestamp to the provided timezone automatically + if (Date?.now() && Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone) + bgElement.style.backgroundImage = `url("https://dexrn.duckdns.org/panorama?timestamp=${Date.now()}&timezone=${Intl.DateTimeFormat().resolvedOptions().timeZone}")`; + else + setBGTime(); const bg = new Image(); bg.src = bgElement.style.backgroundImage.slice(5, -2); diff --git a/js/settings.ts b/js/settings.ts index ac8a3c5..2cbce73 100644 --- a/js/settings.ts +++ b/js/settings.ts @@ -159,6 +159,17 @@ function setLang(langFilePath: string): void { .catch((error) => console.error("Error whilst loading lang file:", error)); } +export function getLocalization(langFilePath: string, code: string) { + fetch(langFilePath) + .then((response) => response.json()) + .then((data) => { + if (data[code]) { + return data[code]; + } + }) + .catch((error) => console.error("Error whilst loading lang file:", error)); +} + // Dexrn: This makes sure that the element exists before setting it... otherwise it will throw an error. function checkIfExists(elementId: string, value: string): void { const element = document.getElementById(elementId);