2022-05-28 01:07:20 -05:00
|
|
|
'use strict';
|
2022-05-18 00:23:56 -05:00
|
|
|
// Full year for footer
|
|
|
|
const todayDate = new Date();
|
|
|
|
jsyear.innerText = todayDate.getFullYear();
|
|
|
|
|
2022-05-28 09:03:27 -05:00
|
|
|
const quoteDisplay = document.querySelector(".quote");
|
2022-05-28 01:07:20 -05:00
|
|
|
let numQuotes;
|
|
|
|
let randomNum;
|
|
|
|
let intervalID;
|
|
|
|
let iteratorID = 0;
|
2022-05-28 09:03:27 -05:00
|
|
|
let currQuote;
|
2022-05-18 00:14:26 -05:00
|
|
|
|
|
|
|
fetch("FavouriteQuotes.json")
|
|
|
|
.then((response) => {
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then((data) => {
|
2022-05-28 09:03:27 -05:00
|
|
|
currQuote = getQuote(data);
|
2022-06-02 02:36:07 -05:00
|
|
|
for (let i = 0; i < 50; i++) {
|
2022-05-28 09:03:27 -05:00
|
|
|
quoteDisplay.innerText = currQuote;
|
|
|
|
intervalID = setInterval(() => {
|
|
|
|
currQuote = getQuote(data);
|
|
|
|
quoteDisplay.innerText = currQuote;
|
2022-06-01 12:40:15 -05:00
|
|
|
}, 12000);
|
2022-05-28 09:03:27 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function getQuote(data) {
|
|
|
|
let noQuotes = Object.entries(data).length;
|
|
|
|
let randNo = Math.floor(Math.random() * noQuotes);
|
|
|
|
return data[randNo].quote + "\n\n" + data[randNo].author.replace(/"/g, '');
|
|
|
|
}
|