Skip to content

Maryna Romanova - Sprint-3 #450

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 3 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
54 changes: 50 additions & 4 deletions Sprint-3/alarmclock/alarmclock.js
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working in my Browser. There areas to be reviewed specifically line 26. I advise breaking this down into multiple pull requests. Also look strengthening your process for handling inputs and checking out the clear interval function.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 26 of test.js to be precise

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All is fixed

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);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is fistRemaider a typo? if not just ignore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixes my typo.

intervalId = setInterval(() => {
firstReminder -= 100;

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() {
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();
});

Expand All @@ -18,8 +64,8 @@ function playAlarm() {
audio.play();
}

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

window.onload = setup;
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body>
<div class="centre">
<h1 id="timeRemaining">Time Remaining: 00:00</h1>
<h1 id="timeRemaining">Time Remaining:</h1> <h1 id="timeValue"> 00:00</h1>
<label for="alarmSet">Set time to:</label>
<input id="alarmSet" type="number" />

Expand Down
20 changes: 20 additions & 0 deletions Sprint-3/alarmclock/indextime.html
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>
29 changes: 29 additions & 0 deletions Sprint-3/alarmclock/test.js
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);
17 changes: 14 additions & 3 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
<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>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<h1>hello there</h1>
<p id="quote"></p>

<div id="div">

<div id="div-in">
<h1 id="quote"></h1>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>

</div>

</body>
</html>


5 changes: 5 additions & 0 deletions Sprint-3/quote-generator/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
require("@testing-library/jest-dom");





17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}

function showRandomQuote() {
document.getElementById("new-quote").addEventListener("click", () => {
const randomQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = `"${randomQuote.quote}"`;
document.getElementById("author").textContent = `— ${randomQuote.author}`;
});
}
showRandomQuote();


// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
const quotes = [
Expand Down Expand Up @@ -491,3 +501,10 @@ const quotes = [
];

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



// const randomQuote = pickFromArray(quotes);
// console.log(randomQuote.quote);
// console.log(randomQuote.author);

54 changes: 54 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
/** Write your CSS in here **/
body {
background-color:bisque;
}

#div-in {
background-color: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
width: 600px;
height: 200px;
text-align: center;

justify-content: center;
margin-left: 30%;
margin-top:10%;

}



#quote {
font-size: 1.5em;
font-style: italic;
margin-bottom: 15px;
color: #333;
}

#author {
font-size: 1.1em;
font-weight: bold;
color: #555;
}

#new-quote {
position: fixed;
bottom: 40%;
left: 50%;

margin-bottom: 20px;
padding: 12px 24px;
background-color:orange;
color: white;
border: none;
border-radius: 12px;
cursor: pointer;
transition: background-color 0.3s ease;
}

#new-quote:hover {
background-color: red;
}


5 changes: 5 additions & 0 deletions Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
<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 id="content">
<ul id="reading-list"></ul>
</div>
<div id="placeholder">

</div>
<script src="script.js"></script>
</body>
</html>

12 changes: 11 additions & 1 deletion Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// for the tests, do not modify this array of books


const books = [
{
title: "The Design of Everyday Things",
Expand All @@ -21,3 +22,12 @@ const books = [
},
];


const booksContainer = document.getElementById("placeholder");

books.forEach ((book) => {
const bookDiv = document.createElement("div");
bookDiv.innerHTML = book.title + book.author + '<img src="' + book.bookCoverImage + '" />';
booksContainer.appendChild(bookDiv);
});

14 changes: 11 additions & 3 deletions Sprint-3/slideshow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<script defer src="slideshow.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<img id="carousel-img" src="./assets/cute-cat-a.png" alt="cat-pic" />
<button type="button" id="backward-btn">Backwards</button>
<button type="button" id="forward-btn">Forward</button>

<div id="box-cat">
<img id="carousel-img" src="./assets/cute-cat-a.png" alt="cat-pic" />
</div>

<div id="button">
<button type="button" id="backward-btn">Backwards</button>
<button type="button" id="forward-btn">Forward</button>
</div>

</body>
</html>
23 changes: 22 additions & 1 deletion Sprint-3/slideshow/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,25 @@ const images = [
];


// Write your code here
// Write your code here

let currentIndex = 0;

const imgElement = document.getElementById("carousel-img");

function slideShowBack() {
document.getElementById("backward-btn").addEventListener("click", () => {
currentIndex = (currentIndex - 1 + images.length) % images.length;
imgElement.src = images[currentIndex];
});
}
slideShowBack();

function slideShowForward() {
document.getElementById("forward-btn").addEventListener("click", () => {
currentIndex = (currentIndex + 1 + images.length) % images.length;
imgElement.src = images[currentIndex];
});
}
slideShowForward();

21 changes: 21 additions & 0 deletions Sprint-3/slideshow/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
/** Write your CSS in here **/
#box-cat {
display: flex;
justify-content: center;
align-items: center;
height: 90vh;
}


#carousel-img {

height: 600px;
width: 900px;

}

#button {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
}