Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8bc3e8c
feat: add container for quotes
Grajales-K Apr 7, 2026
c8b9d48
feat: add stylesheet and background styling for quote generator
Grajales-K Apr 7, 2026
43a7d8e
feat: add media images and sound
Grajales-K Apr 7, 2026
8291f6f
refactor: move example image to assets
Grajales-K Apr 7, 2026
4841426
feat: add script.js for additional functionality in quote generator
Grajales-K Apr 13, 2026
62c26cc
feat: implement random quote generation functionality
Grajales-K Apr 13, 2026
fcf0c91
feat: add auto-play functionality for random quotes
Grajales-K Apr 13, 2026
0d91e68
feat: add background sound playback functionality
Grajales-K Apr 13, 2026
c72fb1b
feat: enhance quote generator with sound playback and auto-quote inte…
Grajales-K Apr 13, 2026
ee8e66d
refactor: remove unused pickFromArray function from quotes.js
Grajales-K Apr 13, 2026
7847481
feat: add autoplay functionality for background sound and improve quo…
Grajales-K Apr 14, 2026
81bbb7f
feat: update styles for quote generator with improved layout and design
Grajales-K Apr 14, 2026
6d68eaa
feat: add button for auto-quote playback in quote generator
Grajales-K Apr 14, 2026
c7538f3
feat: rename button for auto-quote playback and update event listener
Grajales-K Apr 14, 2026
f0185ee
feat: improve sound playback logic and enhance quote display layout
Grajales-K Apr 14, 2026
beb1440
Revert "feat: improve sound playback logic and enhance quote display …
Grajales-K Apr 14, 2026
4172f20
feat: update styles for quote generator with enhanced design and layo…
Grajales-K Apr 14, 2026
c14ea3a
feat: enhance quote generator with background sound playback and rand…
Grajales-K Apr 14, 2026
9375e10
feat: refactor quote generation logic and improve event handling for …
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
Binary file added Sprint-3/quote-generator/assets/SPACE.mp3
Binary file not shown.
Binary file added Sprint-3/quote-generator/assets/stars.gif
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/quote-generator/assets/stars.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
<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 app</title>
<script defer src="quotes.js"></script>
<script defer src="script.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div id="container-quote">
<h1>Random Quotes 🔊</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
7 changes: 3 additions & 4 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
// ---------------
// pickFromArray(['a','b','c','d']) // maybe returns 'c'

// You don't need to change this function
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}


// ========================= array quotes ======================

// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
Expand Down
67 changes: 67 additions & 0 deletions Sprint-3/quote-generator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// added extra functionality to play music when the user click on autoplay
let backgroundSound = new Audio("assets/SPACE.mp3");
Comment thread
Grajales-K marked this conversation as resolved.
Outdated
let isSoundStarted = false;

//avoid auto-playing sound in test environment and jsdom which does not implement audio playback
function playSound() {
if (!navigator.userAgent.includes("jsdom")) {
backgroundSound.play().catch((error) => {
console.log("waiting for user interaction to start sound");
});
}
}

//generated random quote from the array of quotes
function pickFromArray(quotes) {
return quotes[Math.floor(Math.random() * quotes.length)];
}

const container = document.querySelector("#container-quote");
const quoteText = document.querySelector("#quote");
const quoteAuthor = document.querySelector("#author");
const button = document.querySelector("#new-quote");

// updates the quote and author text in the HTML
function randomQuoteGenerate() {
const randomArr = pickFromArray(quotes);
quoteText.textContent = randomArr.quote;
quoteAuthor.textContent = randomArr.author;
}

// triggers the first random quote display once the window is fully loaded
window.onload = () => {
randomQuoteGenerate();
};

// listens for clicks to change quotes manually and start the background sound
button.addEventListener("click", () => {
randomQuoteGenerate();
if (!isSoundStarted) {
playSound();
isSoundStarted = true;
}
});

const secondButton = document.createElement("button");
secondButton.textContent = "Play Auto-Quotes";
secondButton.classList.add("btn");

container.appendChild(secondButton);
Comment thread
Grajales-K marked this conversation as resolved.
Outdated

let quoteInterval;

// toggles the automatic quote generator and manages the play/stop state
secondButton.addEventListener("click", () => {
if (quoteInterval) {
clearInterval(quoteInterval);
quoteInterval = null;
secondButton.textContent = "Play Auto-Quotes";
} else {
quoteInterval = setInterval(randomQuoteGenerate, 2000);
secondButton.textContent = "Stop";
if (!isSoundStarted) {
playSound();
isSoundStarted = true;
}
}
});
Comment thread
Grajales-K marked this conversation as resolved.
Outdated
70 changes: 69 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,69 @@
/** Write your CSS in here **/
body {
background-image: url("./assets/stars.webp");
background-size: cover;
background-position: center;
background-attachment: fixed;
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: Arial, sans-serif;
}


#container-quote {
background: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
padding: 20px;
border-radius: 15px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
max-width: 400px;
width: 85%;
text-align: center;
}

h1 {
font-size: 1.4rem;
margin-bottom: 15px;
color: white;
}


#quote {
font-size: 1.2rem;
font-style: italic;
color: #3bffeb;
line-height: 1.3;
margin-bottom: 10px;
}


#author {
font-size: 0.9rem;
font-weight: bold;
color: #ffffff;
margin-bottom: 20px;
display: block;
}


#new-quote, .btn {
background-color: rgba(3, 251, 255, 0.15);
color: white;
border: 1px solid rgba(59, 255, 235, 0.5);
border-radius: 8px;
padding: 8px 16px;
font-size: 0.85rem;
cursor: pointer;
transition: all 0.3s ease;
margin: 5px;
}

#new-quote:hover, .btn:hover {
background-color: #3bffeb;
color: #000593;
transform: translateY(-2px);
}
Loading