Last active
June 26, 2024 23:09
-
-
Save cferdinandi/9842dbe5f7286f0ed1edbb7203453a61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Timer</title> | |
<style type="text/css"> | |
body { | |
margin: 0 auto; | |
max-width: 40em; | |
width: 88%; | |
} | |
#app { | |
font-size: 2em; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Timer</h1> | |
<div id="app" aria-live="polite">5</div> | |
<script> | |
// Get the #app element | |
let app = document.querySelector('#app'); | |
// Track the count | |
let count = 5; | |
/** | |
* Play the chime sound | |
*/ | |
function playSound () { | |
let ding = new Audio('ding.mp3'); | |
ding.play(); | |
} | |
// Run a callback function once every second | |
let timer = setInterval(function () { | |
// Reduce count by 1 | |
count--; | |
// Update the UI | |
if (count > 0) { | |
app.textContent = count; | |
} else { | |
app.textContent = '⏰'; | |
clearInterval(timer); | |
playSound(); | |
} | |
}, 1000); | |
</script> | |
</body> | |
</html> |
Gib9368
commented
Jun 26, 2024
via email
Not sure what you want. My comment too succinct? Ding in file folder. Fails in Chrome, Safari, Opera, and Firefox. No error messages in any case
… On Jun 26, 2024, at 4:00 PM, Chris Ferdinandi ***@***.***> wrote:
@cferdinandi commented on this gist.
See above
—
Reply to this email directly, view it on GitHub <https://gist.github.com/cferdinandi/9842dbe5f7286f0ed1edbb7203453a61#gistcomment-5102699> or unsubscribe <https://github.com/notifications/unsubscribe-auth/A7WH54TDIBW3NUBXBVMUT6TZJNBXBBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCMBXGU4TMMRYU52HE2LHM5SXFJTDOJSWC5DF>.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment