2023-11-24 06:45:09 -06:00
|
|
|
const wait = (t) => new Promise(resolve => setTimeout(resolve, t * 1000));
|
2023-11-23 07:23:48 -06:00
|
|
|
const plurals = {
|
|
|
|
'dni': {
|
|
|
|
1: 'dzień',
|
|
|
|
_: 'dni'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-24 06:45:09 -06:00
|
|
|
const loadingContainer = document.getElementById('loading-container');
|
|
|
|
const container = document.getElementById('container');
|
|
|
|
|
|
|
|
const difference = document.getElementById('difference');
|
|
|
|
const witchDayDate = new Date('11/16/2023');
|
|
|
|
const now = new Date();
|
|
|
|
|
2023-11-23 07:23:48 -06:00
|
|
|
function plural(word, n) {
|
|
|
|
return plurals[word][n] ?? plurals[word]['_']
|
|
|
|
}
|
|
|
|
|
|
|
|
const timeDifference = Math.abs(now - witchDayDate);
|
|
|
|
const daysDifference = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
|
|
|
|
|
|
|
|
difference.textContent = `Ten dzień był ${daysDifference} ${plural('dni', daysDifference)} temu.`;
|
|
|
|
|
2023-11-24 06:45:09 -06:00
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
|
|
await wait(0.5);
|
|
|
|
loadingContainer.style.opacity = 0;
|
|
|
|
await wait(0.2);
|
|
|
|
container.style.opacity = 1;
|
|
|
|
})
|
2023-11-23 07:23:48 -06:00
|
|
|
|
2023-11-24 06:45:09 -06:00
|
|
|
document.addEventListener('contextmenu', e => e.preventDefault())
|