Skip to content

Commit

Permalink
Life: update birth, add death
Browse files Browse the repository at this point in the history
  • Loading branch information
chenglou committed Dec 7, 2023
1 parent d27eac9 commit f443cbc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion demo_life/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

const life = Math.floor(75 * 365.25)
const today = new Date().getDay() // sunday = 0
const age = Math.floor((30 * 365.25 + 6 * 30.5 - 10) / 7) * 7 + today - 1 // rough days, rounded to week, 0-indexed
const age = Math.floor((31 * 365.25 + 6 * 30.5 - 10) / 7) * 7 + today - 1 // rough days, rounded to week, 0-indexed
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

// === generic helpers
Expand Down Expand Up @@ -221,6 +221,10 @@
tooltip.style.display = 'block'
tooltip.disabled = true
tooltip.value = `You're ${Math.floor(age / 365.25)}, born in ${months[Math.floor(age % 365.25 / 30)]}`
} else if (hover === life - 1) {
tooltip.style.display = 'block'
tooltip.disabled = true
tooltip.value = 'Good bye'
} else {
tooltip.style.display = hover != null && hover === newCustomDot ? 'block' : 'none'
tooltip.disabled = false
Expand Down

0 comments on commit f443cbc

Please sign in to comment.