diff --git a/Sprint-3/alarmclock/Module-Data-Groups.code-workspace b/Sprint-3/alarmclock/Module-Data-Groups.code-workspace new file mode 100644 index 000000000..58a849908 --- /dev/null +++ b/Sprint-3/alarmclock/Module-Data-Groups.code-workspace @@ -0,0 +1,39 @@ +{ + "folders": [ + { + "path": "../.." + }, + { + "name": "Sprint-1", + "path": "../../Sprint-1" + }, + { + "name": "Sprint-2", + "path": "../../Sprint-2" + }, + { + "name": "Sprint-3", + "path": ".." + }, + { + "name": "slideshow", + "path": "../slideshow" + }, + { + "name": "reading-list", + "path": "../reading-list" + }, + { + "name": "alarmclock", + "path": "." + }, + { + "name": "todo-list", + "path": "../todo-list" + }, + { + "name": "quote-generator", + "path": "../quote-generator" + } + ] +} \ No newline at end of file diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..d7d733176 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,35 @@ -function setAlarm() {} +let countdown; +let remainingTime = 0; + +function setAlarm() { +const input = document.getElementById("alarmSet"); +const seconds = parseInt(input.value, 10); +if (isNaN(seconds) || seconds <= 0) return; + +clearInterval(countdown); +remainingTime = seconds; + +const display = document.getElementById("timeRemaining"); +display.textContent = `Time Remaining: ${formatTime(remainingTime)}`; + +countdown = setInterval(() => { + remainingTime--; + display.textContent = `Time Remaining: ${formatTime(remainingTime)}`; + + if (remainingTime <= 0) { + clearInterval(countdown); + if (typeof playAlarm === "function") { + window.playAlarm(); + } + } +}, 1000); +} + +function formatTime(seconds) { +const mins = String(Math.floor(seconds / 60)).padStart(2, "0"); +const secs = String(seconds % 60).padStart(2, "0"); +return `${mins}:${secs}`; +} // DO NOT EDIT BELOW HERE diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..4a91379d3 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ -