oliverbooth.dev/src/ts/app.ts

73 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-08-10 13:19:11 +00:00
import UI from "./UI";
2023-08-10 21:47:28 +00:00
import Input from "./Input";
import Callout from "./Callout";
declare const Handlebars: any;
declare const Prism: any;
declare const lucide: any;
2023-08-04 11:55:16 +00:00
(() => {
Callout.foldAll();
lucide.createIcons();
Prism.languages.extend('markup', {});
Prism.languages.hex = {
'number': {
2023-08-16 14:17:05 +00:00
pattern: /(?:[a-fA-F0-9]{3}){1,2}\b/i,
lookbehind: true
}
};
Prism.languages.binary = {
'number': {
pattern: /[10]+/i,
lookbehind: true
}
};
Prism.languages.insertBefore('custom', 'tag', {
'mark': {
pattern: /<\/?mark(?:\s+\w+(?:=(?:"[^"]*"|'[^']*'|[^\s'">=]+))?\s*|\s*)\/?>/,
greedy: true
}
});
2023-08-11 01:08:48 +00:00
Handlebars.registerHelper("urlEncode", encodeURIComponent);
2023-08-10 21:47:28 +00:00
Input.registerShortcut(Input.KONAMI_CODE, () => {
window.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ", "_blank");
});
2023-08-10 14:15:06 +00:00
UI.updateUI();
2024-02-19 22:44:28 +00:00
let avatarType = 0;
const headshot = document.getElementById("index-headshot") as HTMLImageElement;
2024-03-02 05:32:27 +00:00
if (headshot) {
headshot.addEventListener("click", (ev: MouseEvent) => {
if (avatarType === 0) {
headshot.classList.add("headshot-spin", "headshot-spin-start");
setTimeout(() => {
2024-03-02 05:32:27 +00:00
headshot.classList.remove("headshot-spin-start");
headshot.src = "/img/avatar_512x512.jpg"
headshot.classList.add("headshot-spin", "headshot-spin-end");
setTimeout(() => {
headshot.classList.remove("headshot-spin", "headshot-spin-end");
avatarType = 1;
}, 800);
}, 400);
} else if (avatarType === 1) {
headshot.classList.add("headshot-spin", "headshot-spin-start");
setTimeout(() => {
2024-03-02 05:32:27 +00:00
headshot.classList.remove("headshot-spin-start");
headshot.src = "/img/headshot_512x512_2023.jpg"
headshot.classList.add("headshot-spin", "headshot-spin-end");
setTimeout(() => {
headshot.classList.remove("headshot-spin", "headshot-spin-end");
avatarType = 0;
}, 800);
}, 400);
}
});
}
2023-08-04 11:55:16 +00:00
})();