Skip to content
Closed
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
29 changes: 28 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
function setAlarm() {}
function setAlarm() {
const time = document.getElementById("alarmSet").value;
const heading = document.getElementById("timeRemaining");

let remainingTime = Number(time);

const timer = setInterval(() => {
if (remainingTime <= 0) {
clearInterval(timer);
heading.textContent = "Time Remaining: 00:00";
playAlarm();
return;
}

remainingTime--;

const minutes = Math.floor(remainingTime / 60);
const seconds = remainingTime % 60;

heading.textContent = `Time Remaining: ${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
}, 1000);


const minutes = Math.floor(remainingTime / 60);
const seconds = remainingTime % 60;

heading.textContent = `Time Remaining: ${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
}

// DO NOT EDIT BELOW HERE

Expand Down
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<link rel="stylesheet" href="style.css" />
<title>Quote Generator</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<h1>Quote Generator</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
Expand Down
31 changes: 31 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,34 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

const newQuote = document.querySelector("#new-quote");
const quoteTxt = document.querySelector("#quote");
const quoteAuthor = document.querySelector("#author");
const autoPlay = document.querySelector("#auto-play");
const autoPlayTxt = document.querySelector("#auto-play-txt");
const autoPlayTime = 60000;
let autoPlayInterval = null;
newQuote.addEventListener("click", displayQuote);

initaliseSite();
autoPlay.addEventListener("change", () => {
if (autoPlay.checked) {
console.log("ON");
autoPlayTxt.textContent = `Auto-Play: ON, changing quote every ${autoPlayTime / 1000} seconds.`;
autoPlayInterval = setInterval(displayQuote, autoPlayTime);
} else {
console.log("OFF");
autoPlayTxt.textContent = "Auto-Play: OFF";
clearInterval(autoPlayInterval);
}
});
function initaliseSite() {
displayQuote();
}

function displayQuote() {
const quote = pickFromArray(quotes);
quoteTxt.innerHTML = `${quote.quote}`;
quoteAuthor.textContent = `- ${quote.author}`;
}
14 changes: 14 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: aqua;


}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: aquamarine;
}
Loading