Skip to content

Pawel Broilo I Module Data Groups I Alarm clock #462

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 2 commits 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
37 changes: 37 additions & 0 deletions Alarm Clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function setAlarm() { }
button onclick=("set").addEventListener("Click", () => {
setAlarm();
function time(10);
return value=(00:10);
set interval(60);
Document.getElementById=(60) => -1 = 0 => alarmsound.mp3;
function playAlarm() {
audio.play();
function pauseAlarm() {
audio.pause();
button onclick=("stop").addEventListener("Click", () => {
stopAlarm();

// DO NOT EDIT BELOW HERE

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

function setup() {
document.getElementById("set").addEventListener("click", () => {
setAlarm();
});

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

function playAlarm() {
audio.play();
}

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

window.onload = setup;
37 changes: 37 additions & 0 deletions Alarm Clock/Alarm Clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function setAlarm() { }
button onclick=("set").addEventListener("Click", () => {
setAlarm();
function time(10);
return value=(00:10);
set interval(60);
Document.getElementById=(60) => -1 = 0 => alarmsound.mp3;
function playAlarm() {
audio.play();
function pauseAlarm() {
audio.pause();
button onclick=("stop").addEventListener("Click", () => {
stopAlarm();

// DO NOT EDIT BELOW HERE

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

function setup() {
document.getElementById("set").addEventListener("click", () => {
setAlarm();
});

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

function playAlarm() {
audio.play();
}

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

window.onload = setup;
44 changes: 44 additions & 0 deletions Alarm Clock/AlarmClock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function setAlarm() {
const input = document.getElementById("alarmSet").value;
let timeRemaining = parseInt(input, 10);

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

const display = document.getElementById("timeRemaining");
const interval = setInterval(() => {
if (timeRemaining > 0) {
display.textContent = `Time Remaining: ${timeRemaining--} seconds`;
} else {
clearInterval(interval);
display.textContent = "Time Remaining: 0 seconds";
playAlarm();
}
}, 1000);
}

// DO NOT EDIT BELOW HERE

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

function setup() {
document.getElementById("set").addEventListener("click", () => {
setAlarm();
});

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

function playAlarm() {
audio.play();
}

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

window.onload = setup;
44 changes: 44 additions & 0 deletions AlarmClock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function setAlarm() {
const input = document.getElementById("alarmSet").value;
let timeRemaining = parseInt(input, 10);

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

const display = document.getElementById("timeRemaining");
const interval = setInterval(() => {
if (timeRemaining > 0) {
display.textContent = `Time Remaining: ${timeRemaining--} seconds`;
} else {
clearInterval(interval);
display.textContent = "Time Remaining: 0 seconds";
playAlarm();
}
}, 1000);
}

// DO NOT EDIT BELOW HERE

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

function setup() {
document.getElementById("set").addEventListener("click", () => {
setAlarm();
});

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

function playAlarm() {
audio.play();
}

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

window.onload = setup;