Skip to content

London | May-2025 | Adnaan Abo | Sprint-3 | Alarm Clock App #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
function setAlarm() {}
let countdownInterval;

function setAlarm() {
const input = document.getElementById("alarmSet");
let seconds = Number(input.value);

updateAlarmDisplay(seconds);

// Clear any existing interval
clearInterval(countdownInterval);

countdownInterval = window.setInterval(() => {
seconds--;
if (seconds <= 0) {
clearInterval(countdownInterval);
updateAlarmDisplay(0);
playAlarm();
} else {
updateAlarmDisplay(seconds);
}
}, 1000);
}

function updateAlarmDisplay(seconds) {
const display = document.getElementById("timeRemaining");
const minutes = Math.floor(seconds / 60)
.toString()
.padStart(2, "0");
const secs = (seconds % 60).toString().padStart(2, "0");
display.textContent = `Time Remaining: ${minutes}:${secs}`;
}

window.setAlarm = setAlarm;
window.updateAlarmDisplay = updateAlarmDisplay;
// DO NOT EDIT BELOW HERE

var audio = new Audio("alarmsound.mp3");
Expand Down
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>alarmclock</title>
</head>
<body>
<div class="centre">
Expand Down
2 changes: 1 addition & 1 deletion Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
Expand Down