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
File renamed without changes.
20 changes: 20 additions & 0 deletions Sprint-3/alarmclock/alarmClockApp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<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>
</head>
<body>
<div class="centre">
<h1 id="timeRemaining">Time Remaining: 00:00</h1>
<label for="alarmSet">Set time to:</label>
<input id="alarmSet" type="number" onfocus="" />

<button id="set" type="button">Set Alarm</button>
<button id="stop" type="button">Stop Alarm</button>
</div>
<script src="alarmclock.js"></script>
</body>
</html>
34 changes: 33 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
function setAlarm() {}
botton = document.getElementById("set");
//begins the count down
botton.addEventListener("click", setAlarm);

// document.getElementById("set").addEventListener("click", setAlarm);
const timeRemaining = document.getElementById("timeRemaining");
function setAlarm() {
// gets the value of the input field and stores it in a variable
let timeInSeconds = document.getElementById("alarmSet").value;

let clock = setInterval(() => {
function pad(num) {
return num.toString().padStart(2, "0");
}

function formatTimeDisplay(timeInSeconds) {
const remainingSeconds = timeInSeconds % 60;
const totalMinutes = (timeInSeconds - remainingSeconds) / 60;
const remainingMinutes = totalMinutes % 60;
const totalHours = (totalMinutes - remainingMinutes) / 60;

return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
}

timeInSecond = timeInSeconds--;
if (timeInSeconds == 0) {
clearInterval(clock);
playAlarm();
}
timeRemaining.innerHTML =
"time remaining " + formatTimeDisplay(timeInSeconds);
}, 1000);
}

// DO NOT EDIT BELOW HERE

Expand Down
5 changes: 4 additions & 1 deletion Sprint-3/alarmclock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
"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",
"dependencies": {
"jest": "^30.3.0"
}
}
15 changes: 12 additions & 3 deletions Sprint-3/alarmclock/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
body {
min-width: fit-content;
font-size: 20px;
background-color: darkorchid;
color: rgb(113, 48, 48);
}

.centre {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

button {
border-radius: 30px;
}
#alarmSet {
margin: 20px;
margin: 0px;
}

h1 {
text-align: center;
text-align: right;
}
Loading