mirror of
https://github.com/NotXia/notxia.github.io.git
synced 2025-12-14 19:01:51 +01:00
Migration to Nuxt3
This commit is contained in:
28
utils/easteregg_handler.ts
Normal file
28
utils/easteregg_handler.ts
Normal file
@ -0,0 +1,28 @@
|
||||
const EASTER_EGGS = ["cookie", "future", "change-something", "picture-bright", "picture-nolights"];
|
||||
|
||||
export function addFoundEasterEgg(name:string):void {
|
||||
if (!EASTER_EGGS.includes(name)) { return; }
|
||||
|
||||
let found_eastereggs = new Set( JSON.parse(localStorage.getItem("eastereggs") ?? "[]") );
|
||||
const is_new = !found_eastereggs.has(name);
|
||||
|
||||
found_eastereggs.add(name);
|
||||
localStorage.setItem("eastereggs", JSON.stringify([...found_eastereggs]));
|
||||
|
||||
if (is_new) {
|
||||
// To trigger the banner
|
||||
document.dispatchEvent(new CustomEvent("easteregg", { detail: name }));
|
||||
}
|
||||
}
|
||||
|
||||
export function getFoundEasterEggs():string[] {
|
||||
return JSON.parse(localStorage.getItem("eastereggs") ?? "[]");
|
||||
}
|
||||
|
||||
export function getFoundEasterEggsCount():number {
|
||||
return getFoundEasterEggs().length;
|
||||
}
|
||||
|
||||
export function getTotalEasterEggsCount():number {
|
||||
return EASTER_EGGS.length;
|
||||
}
|
||||
Reference in New Issue
Block a user