cleaned up directory
This commit is contained in:
33
public/js/app.js
Normal file
33
public/js/app.js
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
// Full year for footer
|
||||
const todayDate = new Date();
|
||||
jsyear.innerText = todayDate.getFullYear();
|
||||
|
||||
const quoteDisplay = document.querySelector(".quote");
|
||||
let numQuotes;
|
||||
let randomNum;
|
||||
let intervalID;
|
||||
let iteratorID = 0;
|
||||
let currQuote;
|
||||
|
||||
fetch("https://cdn.fyrfli.link/FavouriteQuotes.json")
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
currQuote = getQuote(data);
|
||||
for (let i = 0; i < 50; i++) {
|
||||
quoteDisplay.innerText = currQuote;
|
||||
intervalID = setInterval(() => {
|
||||
currQuote = getQuote(data);
|
||||
quoteDisplay.innerText = currQuote;
|
||||
}, 12000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
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, '');
|
||||
}
|
23
public/js/layout.js
Normal file
23
public/js/layout.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
// Full year for footer
|
||||
const todayDate = new Date();
|
||||
jsyear.innerText = todayDate.getFullYear();
|
||||
|
||||
const quoteDisplay = document.querySelector(".quotes");
|
||||
const debugDisplay = document.querySelector(".debug");
|
||||
let i = 0;
|
||||
let quote_section = "";
|
||||
|
||||
fetch("https://cdn.fyrfli.link/FavouriteQuotes.json")
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
while (i < Object.entries(data).length) {
|
||||
quote_section = document.createElement("section")
|
||||
quote_section.className = "quote";
|
||||
quote_section.innerText = "\"" + data[i].quote + "\"\n\n" + data[i].author;
|
||||
quoteDisplay.appendChild(quote_section);
|
||||
i++;
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user