Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d3adbf9
add music effects
Grajales-K Apr 1, 2026
a067260
feat: add meta description and favicon to alarm clock page
Grajales-K Apr 6, 2026
97a40d0
feat: implement alarm countdown display in setAlarm function
Grajales-K Apr 6, 2026
14a0278
feat: add countdown functionality to alarm clock display
Grajales-K Apr 6, 2026
3b04b19
feat: refactor setAlarm function and add display update logic
Grajales-K Apr 6, 2026
13ef67d
feat: add placeholder text for alarm time input field
Grajales-K Apr 6, 2026
e89fc7d
feat: update alarm sound and add stop audio functionality
Grajales-K Apr 6, 2026
088efa0
feat: add step attribute to alarm time input for precise time setting
Grajales-K Apr 6, 2026
2e8d9f5
feat: enhance alarm functionality with input validation and random ba…
Grajales-K Apr 6, 2026
b0b40a3
feat: update placeholder text for alarm time input field
Grajales-K Apr 6, 2026
b33fd6a
feat: add styling for alarm clock interface with new layout and butto…
Grajales-K Apr 6, 2026
063968e
feat: reset audio playback position when pausing alarm
Grajales-K Apr 6, 2026
3a3a9d0
feat: refactor countdown variable to countdownInterval for clarity
Grajales-K Apr 14, 2026
3537c04
feat: add resetApp function to restore initial app state
Grajales-K Apr 14, 2026
011f069
feat: improve input validation and enhance countdown logic in setAlar…
Grajales-K Apr 14, 2026
928b976
feat: refactor setAlarm function for improved readability and maintai…
Grajales-K Apr 14, 2026
582e497
feat: add background color animation on alarm trigger for enhanced us…
Grajales-K Apr 14, 2026
325c4b4
feat: improve input validation in setAlarm function by removing empty…
Grajales-K Apr 14, 2026
88b277b
feat: initialize audio elements for alarm and stop sounds
Grajales-K Apr 14, 2026
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
84 changes: 81 additions & 3 deletions Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,85 @@
function setAlarm() {}
let countdownInterval;
let flashInterval;

let audio = new Audio("assets/trebolClan.mp3");
let stopAudio = new Audio("assets/stopAlarm.mp3");

// helper to reset the app to its initial state
function resetApp() {
clearInterval(countdownInterval);
clearInterval(flashInterval);
document.body.style.backgroundColor = "white";


if(audio){
audio.pause();
audio.currentTime = 0;
}
}

//function to changing colors animation.
function startBackgroundAnimation() {
let repetitions = 0;
flashInterval = setInterval(() => {
document.body.style.backgroundColor = `rgb(
${Math.floor(Math.random() * 256)},
${Math.floor(Math.random() * 256)},
${Math.floor(Math.random() * 256)})`;

repetitions++;
if (repetitions > 100) {
clearInterval(flashInterval);
document.body.style.backgroundColor = "white";
}
}, 200);
}


function setAlarm() {
resetApp();

const rawValue = document.getElementById("alarmSet").value;
const inputTime = Number(rawValue);

if (!Number.isInteger(inputTime) || inputTime <= 0) {
alert("Please type or select a valid positive time in seconds 👇⏰");
return;
}

let timeLeft = inputTime;
updateDisplay(timeLeft);

countdownInterval = setInterval(() => {
timeLeft--;

if (timeLeft <= 0) {
clearInterval(countdownInterval);
updateDisplay(0);
playAlarm();

startBackgroundAnimation();

} else {
updateDisplay(timeLeft);
}
}, 1000);
}

function updateDisplay(seconds) {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;

const formattedMinutes = minutes < 10 ? `0${minutes}` : minutes;
const formattedSeconds =
remainingSeconds < 10 ? `0${remainingSeconds}` : remainingSeconds;

const display = `Time Remaining: ${formattedMinutes}:${formattedSeconds}`;

document.getElementById("timeRemaining").innerText = display;
}

// DO NOT EDIT BELOW HERE

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

function setup() {
document.getElementById("set").addEventListener("click", () => {
Expand All @@ -19,7 +96,8 @@ function playAlarm() {
}

function pauseAlarm() {
audio.pause();
resetApp();
stopAudio.play();
}

window.onload = setup;
Binary file added Sprint-3/alarmclock/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sprint-3/alarmclock/assets/stopAlarm.mp3
Binary file not shown.
Binary file added Sprint-3/alarmclock/assets/trebolClan.mp3
Binary file not shown.
10 changes: 8 additions & 2 deletions Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
<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>
<meta
name="description"
content="This page is an alarm clock with an alert to aware the user type or
select the time. This include two sound effects"
/>
<link rel="icon" type="image/png" href="assets/favicon.png" />
<title>Alarm clock app</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" />
<input id="alarmSet" type="number" placeholder="Type or select the time -->" min="0" step="1"/>

<button id="set" type="button">Set Alarm</button>
<button id="stop" type="button">Stop Alarm</button>
Expand Down
62 changes: 56 additions & 6 deletions Sprint-3/alarmclock/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@


body{
background-color: #f7f3f2;
color: #333;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.centre {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
padding: 2rem 2rem;
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.8);
text-align: center;
}

/* Input Field */
#alarmSet {
margin: 20px;
margin: 1rem ;
padding: 1rem;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 1rem;
max-width: 300px;
box-sizing: border-box;
}

#alarmSet::placeholder {
color: #888;
font-style: italic;
font-family: 'Arial', sans-serif;
font-size: 0.8rem;
}

h1 {
text-align: center;
}

/* Button */
button {
background-color: #6c63ff;
color: white;
border: none;
border-radius: 6px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
}

button:hover {
background-color: #dedee8;
color: #6c63ff;
transform: translateY(-2px);
}

button:active {
background-color: #4b47b0;
transform: translateY(0);
}