use dynamic heading for formatting

master
lub 2 days ago
parent 892ca9d7c3
commit 7b49a2054e

@ -2,5 +2,4 @@ body {
background-color: black; background-color: black;
color: #0f0; color: #0f0;
font-family: monospace; font-family: monospace;
font-size: 3rem;
} }

@ -3,7 +3,7 @@ const minute = second*60;
const hour = minute*60; const hour = minute*60;
const day = hour*24; const day = hour*24;
const countdown = (target) => { const countdown = (target, heading) => {
const now = new Date(); const now = new Date();
const diff = target - now; const diff = target - now;
@ -21,16 +21,18 @@ const countdown = (target) => {
}); });
return ` return `
${formatted[0]} Days<br> <h${heading}>${formatted[0]} Days</h${heading}>
${formatted[1]} Hours<br> <h${heading}>${formatted[1]} Hours</h${heading}>
${formatted[2]} Minutes<br> <h${heading}>${formatted[2]} Minutes</h${heading}>
${formatted[3]} Seconds<br> <h${heading}>${formatted[3]} Seconds</h${heading}>
`; `;
}; };
const hash_date = new Date(location.hash.substr(1)) const hash_date = new Date(location.hash.substr(1))
const update_all = () => { const update_all = () => {
document.getElementById('output').innerHTML = countdown(hash_date); let i = 1
const date_list = location.hash.split('#').slice(1).map((fragment) => {return new Date(fragment)})
document.getElementById('output').innerHTML = countdown(date_list[0], i);
} }
update_all(); update_all();
setInterval(update_all, 500); setInterval(update_all, 500);

Loading…
Cancel
Save