Compare commits

...

2 Commits

Author SHA1 Message Date
a607318eff Added URL fragment support for tabs 2026-06-12 05:44:43 +01:00
99131cea6f Addeded to "I'm a" text 2026-06-12 05:44:09 +01:00

View File

@ -18,9 +18,15 @@ const imaTexts = shuffle([
'I\'m an $ice skater', 'I\'m an $ice skater',
'I\'m a $masochist', 'I\'m a $masochist',
'I\'m a $professional alcoholic', 'I\'m a $professional alcoholic',
'I\'m a $Vim addict' 'I\'m a $Vim addict',
'I\'m an $accidental UK shock collar provider',
'I play $Beat Saber',
'I play $VRChat',
'I\'m a $Blender user'
]); ]);
var currentTab = null;
function shuffle(array) { function shuffle(array) {
return array return array
.map(value => ({ value, sort: Maths.random() })) .map(value => ({ value, sort: Maths.random() }))
@ -38,6 +44,12 @@ function switchTab(tabID, playAnimation=true) {
tabID = tabID.id.split('button-')[1]; tabID = tabID.id.split('button-')[1];
} }
if (currentTab == tabID) { return; }
console.log(`Switching from ${currentTab} to ${tabID}...`);
currentTab = tabID;
location.hash = `#${tabID}`;
let tabTransitionTime = Number(getComputedStyle(document.body).getPropertyValue('--tab-transition-time').slice(0, -2)); let tabTransitionTime = Number(getComputedStyle(document.body).getPropertyValue('--tab-transition-time').slice(0, -2));
let tabs = document.getElementsByTagName('main')[0].children; let tabs = document.getElementsByTagName('main')[0].children;
let tab = document.getElementById(`tab-${tabID}`); let tab = document.getElementById(`tab-${tabID}`);
@ -88,6 +100,10 @@ function switchTab(tabID, playAnimation=true) {
button.classList.add('buttonHighlight'); button.classList.add('buttonHighlight');
} }
window.addEventListener('hashchange', (e) => {
switchTab(location.hash.slice(1));
});
window.addEventListener('load', (e) => { window.addEventListener('load', (e) => {
switchTab('home', false); switchTab('home', false);