diff --git a/src/webpage/404.html b/src/webpage/404.html new file mode 100644 index 0000000..7081795 --- /dev/null +++ b/src/webpage/404.html @@ -0,0 +1,54 @@ + + + + + + It seems you're lost + + + + + + + + + + +
+ +
+

It seems you're lost

+

404 Page Not Found

+ Maybe you meant to go to one of these places + +
+

If you found this page within the client please report it:

+ Github +
+
+
+ + + diff --git a/src/webpage/404.ts b/src/webpage/404.ts new file mode 100644 index 0000000..f257a96 --- /dev/null +++ b/src/webpage/404.ts @@ -0,0 +1,26 @@ +import {I18n} from "./i18n"; +import {setTheme} from "./utils/utils"; + +setTheme(); +await I18n.done; +I18n.translatePage(); + +const easterEvents = [ + () => { + window.open("https://youtube.com/watch?v=dQw4w9WgXcQ"); + }, + () => { + window.open("https://youtube.com/watch?v=fC7oUOUEEi4"); + }, + () => { + alert(I18n[404].whatelse()); + }, +]; + +const where = document.getElementById("whereever"); +if (where) { + where.onclick = () => { + const event = easterEvents[Math.floor(Math.random() * easterEvents.length)]; + event(); + }; +} diff --git a/src/webpage/i18n.ts b/src/webpage/i18n.ts index 5a8dca8..85253e2 100644 --- a/src/webpage/i18n.ts +++ b/src/webpage/i18n.ts @@ -27,6 +27,17 @@ class I18n { res(); } + static translatePage() { + const elms = document.querySelectorAll("[i18n]"); + for (const elm of Array.from(elms)) { + const t = elm.getAttribute("i18n") as string; + try { + elm.textContent = this.getTranslation(t); + } catch { + console.error("Couldn't get " + t + "'s translation"); + } + } + } static getTranslation(msg: string, ...params: string[]): string { let str: string | undefined; const path = msg.split("."); diff --git a/src/webpage/style.css b/src/webpage/style.css index d380fad..311b4a4 100644 --- a/src/webpage/style.css +++ b/src/webpage/style.css @@ -929,6 +929,41 @@ textarea { transform: translate(-50%, 0); } } +.errorHTML { + display: flex; + flex-direction: column; + align-items: center; + width: 100%; + height: 100vh; + justify-content: center; + align-content: center; + h3 { + margin-bottom: 15px; + } + > div { + background: var(--primary-bg); + padding: 15px; + border-radius: 10px; + height: 60%; + width: 60%; + box-shadow: 5px 5px 5px black; + display: flex; + flex-direction: column; + + > div { + padding: 10px; + box-shadow: 0px 0px 5px black; + border-radius: 10px; + margin-top: auto; + } + } + img { + background: var(--primary-bg); + padding: 10px; + border-radius: 10px 10px 0 0; + box-shadow: 5px 5px 5px black; + } +} .editMessage { background: var(--typebox-bg); padding: 0.05in; diff --git a/translations/en.json b/translations/en.json index b5caf20..28ba14d 100644 --- a/translations/en.json +++ b/translations/en.json @@ -715,6 +715,19 @@ "errEmjMust": "Must include an emoji with your sticker", "tags": "Associated Emoji: " }, + "404":{ + "home":"Home page", + "title":"It seems you're lost", + "404":"404 Page Not Found", + "listtitle":"Maybe you meant to go to one of these places", + "app":"To the app", + "login":"Login", + "reset":"Password reset page", + "blog":"The Fermi blog", + "whereever":"Wherever this is", + "report":"If you found this page within the client please report it:", + "whatelse":"What else do you think should happen?" + }, "widget": "Guild Widget", "widgetEnabled": "Widget enabled", "incorrectURLS": "## This instance has likely sent the incorrect URLs.\n### If you're the instance owner please see [here](https://docs.spacebar.chat/setup/server/) under *Connecting from remote machines* to correct the issue.\n Would you like Fermi to automatically try to fix this error to let you connect to the instance?",