Skip to content

LONDON-JAN-25 | GIOSEF FERRARO | Module-Data groups | SPRINT 3 #392

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 1 commit 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
55 changes: 53 additions & 2 deletions Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
function setAlarm() {}
function setAlarm() {
let timeInput = document.getElementById("alarmSet").value;
let timeRemaining = document.getElementById("timeRemaining");
let seconds = parseInt(timeInput);

if (isNaN(seconds) || seconds <= 0) {
alert("Please enter a valid number of seconds.");
return;
}

let countdown;

function updateDisplay() {
let minutes = Math.floor(seconds / 60);
let secs = seconds % 60;
timeRemaining.innerText = `Time Remaining: ${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
}

updateDisplay();

countdown = setInterval(() => {
seconds--;
updateDisplay();

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

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

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

document.getElementById("resume").addEventListener("click", () => {
countdown = setInterval(() => {
seconds--;
updateDisplay();

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


// DO NOT EDIT BELOW HERE

Expand All @@ -22,4 +73,4 @@ function pauseAlarm() {
audio.pause();
}

window.onload = setup;
window.onload = setup;
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/alarmclock.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ======= TESTS - DO NOT MODIFY =====
/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
*/

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 @@ -17,4 +17,4 @@ <h1 id="timeRemaining">Time Remaining: 00:00</h1>
</div>
<script src="alarmclock.js"></script>
</body>
</html>
</html>
1 change: 1 addition & 0 deletions Sprint-3/alarmclock/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require("@testing-library/jest-dom");

2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "CC-BY-SA-4.0",
"description": "You must update this package",
"scripts": {
"scripts": {
"test": "jest"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ When the `Time Remaining` reaches `00:00` the alarm should play a sound. You can

You can stop the alarm sound by pressing the `Stop Alarm` button.

## Need Help?
## Need Help?

Only read this section if you really need to! It's good to work this out for yourself.

Expand Down
1 change: 1 addition & 0 deletions Sprint-3/alarmclock/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
h1 {
text-align: center;
}

2 changes: 1 addition & 1 deletion Sprint-3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "jest --testMatch='**/*.js'",
"format": "prettier --write ."
},
"jest": {
"jest": {
"testPathIgnorePatterns": [
"alarmclock",
"highlight-words",
Expand Down
27 changes: 17 additions & 10 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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>
<link rel="stylesheet" href="style.css">
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</body>
</html>
</head>
<body>
<div class="quote-container">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div>
<label for="auto-generate">Auto-generate quotes:</label>
<input type="checkbox" id="auto-generate" />
<span id="auto-play-status">Auto-play: OFF</span>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions Sprint-3/quote-generator/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require("@testing-library/jest-dom");

2 changes: 1 addition & 1 deletion Sprint-3/quote-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "CC-BY-SA-4.0",
"description": "You must update this package",
"scripts": {
"test": "jest"
"test": "jest"
},
"repository": {
"type": "git",
Expand Down
Loading