diff --git a/app.js b/app.js index 1928552..19d7716 100644 --- a/app.js +++ b/app.js @@ -3,13 +3,41 @@ const todayDate = new Date(); jsyear.innerText = todayDate.getFullYear(); const disp = document.querySelector(".display"); +const numIterations = 20; +let ctr = 0; fetch("FavouriteQuotes.json") .then((response) => { return response.json(); }) .then((data) => { - numQuotes = Object.entries(data).length; - num = Math.floor(Math.random() * numQuotes); - disp.innerText = data[num].quote + "\n\n" + data[num].author.replace(/"/g, ''); + // quotes = data; + doTheLoop(data); }) + +// doTheLoop(quotes); + +function doTheLoop(quotes) { + console.log("Entering doTheLoop"); + numQuotes = Object.entries(quotes).length; + console.log(numQuotes); + getQuote(quotes, numQuotes); + timerID = setInterval(getQuote, 6000, quotes, numQuotes); + console.log("Timer ID: " + timerID); + setTimeout(() => { + console.log("Stopping"); + clearInterval(timerID); + console.log("Stopped"); + 30000 + }); +} + +function getQuote(quotes, numQuotes) { + console.log("Entering getQuote"); + num = Math.floor(Math.random() * numQuotes); + disp.classList.remove(".hidden"); + disp.classList.add(".anim"); + disp.innerText = quotes[num].quote + "\n\n" + quotes[num].author.replace(/"/g, ''); + disp.classList.remove(".anim"); + // disp.classList.add(".hidden"); +} \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..1e0715e Binary files /dev/null and b/favicon.ico differ diff --git a/index.html b/index.html index 5999631..4b38401 100644 --- a/index.html +++ b/index.html @@ -7,10 +7,11 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
{{ Hit Reload to see a new quote }}