From 5e635272b620c58dd4b66f978a2e67062dfb4350 Mon Sep 17 00:00:00 2001 From: Mathium05 Date: Sat, 12 Sep 2026 14:35:42 -0500 Subject: [PATCH] winter banner --- src/webpage/utils/bannerController.ts | 7 ++++++ src/webpage/utils/banners/timedBanners.ts | 26 ++++++++++++++++------- translations/en.json | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/webpage/utils/bannerController.ts b/src/webpage/utils/bannerController.ts index f5acd8b..79f2212 100644 --- a/src/webpage/utils/bannerController.ts +++ b/src/webpage/utils/bannerController.ts @@ -2,10 +2,13 @@ import "./banners/index.js"; export interface banner { text: string | (() => string); url?: string; + id?: string; priority: number; } let winner = null as null | banner; +const seen = new Set(JSON.parse(localStorage.getItem("seenBanners") || "[]") as string[]); export function submitBanner(banner: banner) { + if (banner.id && seen.has(banner.id)) return; if (!winner) winner = banner; if (winner.priority < banner.priority) winner = banner; } @@ -13,6 +16,10 @@ export function submitBanner(banner: banner) { let shown = false; export function showBanner() { if (shown || !winner) return; + if (winner.id) { + seen.add(winner.id); + localStorage.setItem("seenBanners", JSON.stringify([...seen])); + } shown = true; const noti = document.getElementById("noti")!; noti.textContent = ""; diff --git a/src/webpage/utils/banners/timedBanners.ts b/src/webpage/utils/banners/timedBanners.ts index 782e2f8..4c775a2 100644 --- a/src/webpage/utils/banners/timedBanners.ts +++ b/src/webpage/utils/banners/timedBanners.ts @@ -1,10 +1,20 @@ import {I18n} from "../../i18n"; -//import {submitBanner} from "../bannerController"; +import {SnowFlake} from "../../snowflake"; +import {submitBanner} from "../bannerController"; +import {getBulkUsers, Specialuser} from "../utils"; await I18n.done; -/* -submitBanner({ - text: I18n.donateMessage, - url: "/donate", - priority: 100, -}); -*/ +const oldest = (Object.values(getBulkUsers().users) as Specialuser[]).reduce((prev, cur) => { + console.log(cur.id); + if (!cur.id) return prev; + const t = SnowFlake.stringToUnixTime(cur.id); + if (t < prev) return t; + return prev; +}, Infinity); +//Only show in December and if the account is over a month old +if (new Date().getMonth() === 11 && Date.now() - oldest > 1000 * 60 * 60 * 24 * 30) + submitBanner({ + text: I18n.donateMessage, + url: "/donate", + priority: 100, + id: "winter" + new Date().getFullYear(), + }); diff --git a/translations/en.json b/translations/en.json index 5f3e4ce..83e25f5 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1,6 +1,6 @@ { "2faCode": "2FA code:", - "donateMessage": "Donate to Fermi today!", + "donateMessage": "Fermi survives on donations, please think about donating! Anything helps!", "404": { "404": "error:404 - Page Not Found", "app": "To the app",