Skip to content
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
24 changes: 23 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
function setAlarm() {}
function setAlarm() {
let time = Number(document.getElementById("alarmSet").value);
let heading = document.getElementById("timeRemaining");

function updateClock() {
let minutes = Math.floor(time / 60);
let seconds = time % 60;

minutes = String(minutes).padStart(2, "0");
seconds = String(seconds).padStart(2, "0");

heading.innerText = `Time Remaining: ${minutes}:${seconds}`;

if (time === 0) {
clearInterval(timer);
playAlarm();
}

time--;
}

updateClock();
let timer = setInterval(updateClock, 1000);
}
// 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 numberDiff line numberDiff 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>Alarm Clock</title>
</head>
<body>
<div class="centre">
Expand Down
7 changes: 6 additions & 1 deletion Sprint-3/alarmclock/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,5 +13,10 @@
"bugs": {
"url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues"
},
"homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme"
"homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme",
"devDependencies": {
"@testing-library/jest-dom": "^6.9.1",
"jest-environment-jsdom": "^30.4.1",
"jsdom": "^20.0.3"
}
}
Loading