mirror of
https://github.com/miggymofongo/asteroid.git
synced 2024-11-24 06:00:27 +00:00
declared facts as a constant
This commit is contained in:
parent
f45d60abba
commit
0313e2f0fd
2 changed files with 8 additions and 4 deletions
|
@ -102,7 +102,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="scripts.js"></script>
|
<script src="./scripts.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
10
scripts.js
10
scripts.js
|
@ -17,18 +17,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
.then(quotes => {
|
.then(quotes => {
|
||||||
let currentQuoteIndex = 0;
|
let currentQuoteIndex = 0;
|
||||||
const quoteBanner = document.getElementById('quoteBanner');
|
const quoteBanner = document.getElementById('quoteBanner');
|
||||||
|
const quoteText = quoteBanner.querySelector('blockquote p');
|
||||||
|
|
||||||
function updateQuote() {
|
function updateQuote() {
|
||||||
quoteBanner.textContent = quotes[currentQuoteIndex++];
|
quoteText.textContent = quotes[currentQuoteIndex];
|
||||||
if (currentQuoteIndex >= quotes.length) currentQuoteIndex = 0;
|
currentQuoteIndex = (currentQuoteIndex + 1) % quotes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateQuote();
|
updateQuote();
|
||||||
setInterval(updateQuote, 5000);
|
setInterval(updateQuote, 5000);
|
||||||
});
|
})
|
||||||
|
.catch(error => console.error('Error loading JSON:', error));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue