✨ Add new autochange feature & quickfixes
This commit is contained in:
parent
802aec898a
commit
0c56923c2a
@ -5,7 +5,6 @@
|
|||||||
// Print cards
|
// Print cards
|
||||||
const printCards = () => {
|
const printCards = () => {
|
||||||
for (const card of CONFIG.cards) {
|
for (const card of CONFIG.cards) {
|
||||||
|
|
||||||
// Card Item
|
// Card Item
|
||||||
let item = `
|
let item = `
|
||||||
<a
|
<a
|
||||||
|
@ -19,12 +19,9 @@ const gree4 = `${CONFIG.greetingEvening}\xa0`;
|
|||||||
if (hour >= 23 || hour < 5) {
|
if (hour >= 23 || hour < 5) {
|
||||||
document.getElementById('greetings').innerText = gree1 + name;
|
document.getElementById('greetings').innerText = gree1 + name;
|
||||||
} else if (hour >= 6 && hour < 12) {
|
} else if (hour >= 6 && hour < 12) {
|
||||||
document.getElementById('greetings').innerText =
|
document.getElementById('greetings').innerText = gree2 + name;
|
||||||
gree2 + name;
|
|
||||||
} else if (hour >= 12 && hour < 17) {
|
} else if (hour >= 12 && hour < 17) {
|
||||||
document.getElementById('greetings').innerText =
|
document.getElementById('greetings').innerText = gree3 + name;
|
||||||
gree3 + name;
|
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('greetings').innerText =
|
document.getElementById('greetings').innerText = gree4 + name;
|
||||||
gree4 + name;
|
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,26 @@ if (CONFIG.imageBackground) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG.changeThemeByOS && CONFIG.autoChangeTheme) {
|
if (CONFIG.changeThemeByOS && CONFIG.autoChangeTheme) {
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if (
|
||||||
|
window.matchMedia &&
|
||||||
|
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
|
) {
|
||||||
enableDark();
|
enableDark();
|
||||||
} else {
|
} else {
|
||||||
disableDark();
|
disableDark();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CONFIG.changeThemeByHour && CONFIG.autoChangeTheme) {
|
if (CONFIG.changeThemeByHour && CONFIG.autoChangeTheme && !CONFIG.changeThemeByOS) {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const hours = date.getHours() < 10 ? '0' + date.getHours().toString() : date.getHours().toString();
|
const hours =
|
||||||
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes().toString() : date.getMinutes().toString();
|
date.getHours() < 10
|
||||||
|
? '0' + date.getHours().toString()
|
||||||
|
: date.getHours().toString();
|
||||||
|
const minutes =
|
||||||
|
date.getMinutes() < 10
|
||||||
|
? '0' + date.getMinutes().toString()
|
||||||
|
: date.getMinutes().toString();
|
||||||
const currentTime = hours + ':' + minutes;
|
const currentTime = hours + ':' + minutes;
|
||||||
if (currentTime >= CONFIG.hourDarkThemeActive) {
|
if (currentTime >= CONFIG.hourDarkThemeActive) {
|
||||||
enableDark();
|
enableDark();
|
||||||
|
@ -3,12 +3,8 @@
|
|||||||
// └┴┘└─┘┴ ┴ ┴ ┴ ┴└─┘┴└─
|
// └┴┘└─┘┴ ┴ ┴ ┴ ┴└─┘┴└─
|
||||||
|
|
||||||
const iconElement = document.querySelector('.weatherIcon');
|
const iconElement = document.querySelector('.weatherIcon');
|
||||||
const tempElement = document.querySelector(
|
const tempElement = document.querySelector('.weatherValue p');
|
||||||
'.weatherValue p'
|
const descElement = document.querySelector('.weatherDescription p');
|
||||||
);
|
|
||||||
const descElement = document.querySelector(
|
|
||||||
'.weatherDescription p'
|
|
||||||
);
|
|
||||||
|
|
||||||
// App data
|
// App data
|
||||||
const weather = {};
|
const weather = {};
|
||||||
@ -73,6 +69,8 @@ function getWeather(latitude, longitude) {
|
|||||||
// Display Weather info
|
// Display Weather info
|
||||||
function displayWeather() {
|
function displayWeather() {
|
||||||
iconElement.innerHTML = `<img src="assets/icons/${CONFIG.weatherIcons}/${weather.iconId}.png"/>`;
|
iconElement.innerHTML = `<img src="assets/icons/${CONFIG.weatherIcons}/${weather.iconId}.png"/>`;
|
||||||
tempElement.innerHTML = `${weather.temperature.value.toFixed(0)}°<span class="darkfg">${tempUnit}</span>`;
|
tempElement.innerHTML = `${weather.temperature.value.toFixed(
|
||||||
|
0
|
||||||
|
)}°<span class="darkfg">${tempUnit}</span>`;
|
||||||
descElement.innerHTML = weather.description;
|
descElement.innerHTML = weather.description;
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,15 @@ const CONFIG = {
|
|||||||
defaultLatitude: '37.775',
|
defaultLatitude: '37.775',
|
||||||
defaultLongitude: '-122.419',
|
defaultLongitude: '-122.419',
|
||||||
|
|
||||||
// Autochange dark-theme (24hrs format, string must be in: hh:mm)
|
// Autochange
|
||||||
autoChangeTheme: true,
|
autoChangeTheme: true,
|
||||||
|
|
||||||
|
// by OS
|
||||||
changeThemeByOS: false,
|
changeThemeByOS: false,
|
||||||
|
|
||||||
|
// Autochange by hour options (24hrs format, string must be in: hh:mm)
|
||||||
changeThemeByHour: true,
|
changeThemeByHour: true,
|
||||||
hourDarkThemeActive: '19:00',
|
hourDarkThemeActive: '18:30',
|
||||||
hourDarkThemeInactive: '07:00',
|
hourDarkThemeInactive: '07:00',
|
||||||
|
|
||||||
// ┌─┐┌─┐┬─┐┌┬┐┌─┐
|
// ┌─┐┌─┐┬─┐┌┬┐┌─┐
|
||||||
|
Loading…
x
Reference in New Issue
Block a user