generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 94
ITP_London | Maryna Romanova | Module_Data_Groups | Sprint-3 | AlarmClock #500
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
MarynaRomashca
wants to merge
1
commit into
CodeYourFuture:main
Choose a base branch
from
MarynaRomashca:AlarmClockNew
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,57 @@ | ||
function setAlarm() {} | ||
const textArea = document.querySelector("#alarmSet"); | ||
const timeRemaining = document.querySelector("#timeValue"); | ||
const startButton = document.querySelector("#set"); | ||
let isAudioPlay = false; | ||
let intervalId = null; | ||
|
||
textArea.addEventListener('input', function () { | ||
const value = textArea.value; | ||
timeRemaining.innerHTML = value; | ||
}); | ||
|
||
function setAlarm() { | ||
let firstReminder = +timeRemaining.innerHTML * 1000; | ||
|
||
if (intervalId) { | ||
clearInterval(intervalId); | ||
} | ||
|
||
intervalId = setInterval(() => { | ||
firstReminder -= 100; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this to be 1000 |
||
|
||
if (firstReminder <= 0) { | ||
clearInterval(intervalId); | ||
intervalId = null; | ||
timeRemaining.innerHTML = 0; | ||
if (!isAudioPlay) { | ||
playAlarm(); | ||
isAudioPlay = true; | ||
} | ||
} else { | ||
|
||
timeRemaining.innerHTML = (firstReminder / 1000).toFixed(1); | ||
} | ||
}, 100); | ||
} | ||
|
||
function pauseAlarm() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the code refer to the button (listener) that makes pauseAlarm to happen? |
||
audio.pause(); | ||
audio.currentTime = 0; | ||
isAudioPlay = false; | ||
|
||
if (intervalId) { | ||
clearInterval(intervalId); | ||
intervalId = null; | ||
} | ||
} | ||
|
||
// DO NOT EDIT BELOW HERE | ||
|
||
var audio = new Audio("alarmsound.mp3"); | ||
|
||
function setup() { | ||
document.getElementById("set").addEventListener("click", () => { | ||
console.log("1") | ||
setAlarm(); | ||
}); | ||
|
||
|
@@ -18,8 +64,8 @@ function playAlarm() { | |
audio.play(); | ||
} | ||
|
||
function pauseAlarm() { | ||
audio.pause(); | ||
} | ||
// function pauseAlarm() { | ||
// audio.pause(); | ||
// } | ||
|
||
window.onload = setup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<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> | ||
</head> | ||
<body> | ||
<div class="centre"> | ||
<h1 id="timeRemaining">Time Remaining:</h1> <h1 id="timeValue"> 00:00</h1> | ||
<label for="alarmSet">Set time to:</label> | ||
<input id="alarmSet" type="number" /> | ||
|
||
<button id="set" type="button">Set Alarm</button> | ||
<button id="stop" type="button">Stop Alarm</button> | ||
</div> | ||
<script src="test.js"></script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// const endDate = new Date("2025-03-12T03:25:00") | ||
|
||
// console.log (endDate) | ||
// function countDoun (){ | ||
// let now = new Date() | ||
// console.log (now) | ||
// if (now.getTime() < endDate.getTime()){ | ||
// //loop | ||
// setInterval(() => { | ||
// now = new Date() | ||
// let timeRemide = endDate - now | ||
|
||
// console.log (new Date (timeRemide)) | ||
// console.log (new Date(now.getTime() + timeRemide * 24 * 60 * 60 * 1000)) | ||
// console.log (new Date(daysRemaining * 24 * 60 * 60 * 1000)); | ||
// }, 1000); | ||
|
||
// } | ||
// else { | ||
// console.log("finish") | ||
// } | ||
// } | ||
// countDoun () | ||
|
||
|
||
// //new Date(now.getTime() + daysRemaining * 24 * 60 * 60 * 1000); | ||
|
||
|
||
// //new Date(daysRemaining * 24 * 60 * 60 * 1000); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement does not seem complete