Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random quotes #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions app.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ body {
color: var(--fg);
}

#quotes{
text-align: center;
font-size: 2vh;
padding-top: 30px;
color: var(--fg);
}

.weatherIcon img {
width: 70px;
height: 70px;
Expand Down
25 changes: 20 additions & 5 deletions assets/js/greeting.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
// ┌─┐┬─┐┌─┐┌─┐┌┬┐┬┌┐┌┌─┐┌─┐
// │ ┬├┬┘├┤ ├┤ │ │││││ ┬└─┐
// └─┘┴└─└─┘└─┘ ┴ ┴┘└┘└─┘└─┘
// Function to set Greetings
// Function to set Greetings & Quotes

const today = new Date();
const hour = today.getHours();
const name = CONFIG.name;

//Quotes
const quotesElements = document.getElementById("quotes");
const quote = { content: "Everything will be fine", author: "Anonymous" };
(function getQuotes() {
fetch("https://api.quotable.io/quotes/random")
.then(function (response) {
let data = response.json();
return data;
})
.then(function (data) {
const quotes = data[0];
quotesElements.innerHTML = `<i>"${quotes.content}"</i> <br/> <b>${quotes.author}</b>`;
});
})(); // immediate invoke function

const gree1 = `${CONFIG.greetingNight}\xa0`;
const gree2 = `${CONFIG.greetingMorning}\xa0`;
const gree3 = `${CONFIG.greetingAfternoon}\xa0`;
const gree4 = `${CONFIG.greetingEvening}\xa0`;

if (hour >= 23 || hour < 6) {
document.getElementById('greetings').innerText = gree1 + name;
document.getElementById("greetings").innerText = gree1 + name;
} else if (hour >= 6 && hour < 12) {
document.getElementById('greetings').innerText = gree2 + name;
document.getElementById("greetings").innerText = gree2 + name;
} else if (hour >= 12 && hour < 17) {
document.getElementById('greetings').innerText = gree3 + name;
document.getElementById("greetings").innerText = gree3 + name;
} else {
document.getElementById('greetings').innerText = gree4 + name;
document.getElementById("greetings").innerText = gree4 + name;
}
Loading