Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
45 changes: 40 additions & 5 deletions Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
function setAlarm() {}
let countdown;
let ispaused = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image There is an error here, Please check your spelling.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else is fine. Please just fix this one line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you sir,Kindly review

let timeRemaining;

function setAlarm(){
const inputField = document.getElementById("alarmSet");
timeRemaining = parseInt(inputField.value);

const updateTitle = () => {
const minutes = String(Math.floor(timeRemaining/60)).padStart(2, '0'); // minutes
const seconds = String(timeRemaining % 60).padStart(2, '0'); // seconds
document.getElementById("timeRemaining").innerText = `Time Remaining: ${minutes}:${seconds}`;
};

updateTitle();

countdown = setInterval(() => {
if (!isPaused){
timeRemaining = timeRemaining - 1;
updateTitle();

if (timeRemaining <= 0) {
clearInterval(countdown);
playAlarm();
}
}
}, 1000);
}

function pauseTimer() {
isPaused = !isPaused;
document.getElementById("pause").innerText = isPaused ? "Resume Timer" : "Pause Timer";
}

// DO NOT EDIT BELOW HERE

var audio = new Audio("alarmsound.mp3");

function setup() {
document.getElementById("set").addEventListener("click", () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the code connected to the buttons back in. Currently they are not working.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you kindly review so that i can submit

setAlarm();
});

document.getElementById("stop").addEventListener("click", () => {
pauseAlarm();
});

document.getElementById("pause").addEventListener("click", () => {
pauseTimer();
});
}

function playAlarm() {
Comment thread
InnocentNiwatwine marked this conversation as resolved.
audio.play();
}

function pauseAlarm() {
audio.pause();
}

window.onload = setup;



3 changes: 2 additions & 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>Alarm Clock App</title>
</head>
<body>
<div class="centre">
Expand All @@ -13,6 +13,7 @@ <h1 id="timeRemaining">Time Remaining: 00:00</h1>
<input id="alarmSet" type="number" />

<button id="set" type="button">Set Alarm</button>
<button id="pause" type="button">Pause Timer</button>
<button id="stop" type="button">Stop Alarm</button>
</div>
<script src="alarmclock.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/user-event": "^13.5.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2"
"jest-environment-jsdom": "^30.0.4"
},
"jest": {
"setupFilesAfterEnv": [
Expand Down
46 changes: 33 additions & 13 deletions Sprint-3/alarmclock/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
.centre {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

#alarmSet {
margin: 20px;
}
margin: 20px 40px;
padding: 20px;
max-width: 400px;
height: 100px;
font-size: clamp(1rem, 2vw, 2rem);
box-shadow: #1b58db66 10px 10px;

#alarmSet:focus {
outline: none;
box-shadow: rgba(29, 240, 103, 0.871) 20px 20px;
transform: translate(-10px, -10px);
}

h1 {
text-align: center;
}
button {
background-color: #1b58db66;
border: none;
color: white;
padding: 15px 32px;
display: inline-block;
font-size: clamp(1rem, 2vw, 2rem);
margin-top: 60px;
margin-left: 20px;
margin-right: 20px;
cursor: pointer;
box-shadow: rgba(0, 0, 0, 0.114) 10px 10px;
border-radius: 3px;
transition: all cubic-bezier(0.165, 0.84, 0.44, 1) 0.9s;

}

button:hover {
box-shadow: #042b7ec4 20px 20px;
transform: translate(-10px, -10px);
}