Skip to content

Commit

Permalink
✨ Add new autochange feature & quickfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
migueravila committed Jan 24, 2022
1 parent efab538 commit 7d23293
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
1 change: 0 additions & 1 deletion assets/js/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Print cards
const printCards = () => {
for (const card of CONFIG.cards) {

// Card Item
let item = `
<a
Expand Down
9 changes: 3 additions & 6 deletions assets/js/greeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ const gree4 = `${CONFIG.greetingEvening}\xa0`;
if (hour >= 23 || hour < 5) {
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;
}
21 changes: 15 additions & 6 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,29 @@ if (CONFIG.imageBackground) {
document.body.classList.add('withImageBackground');
}

if(CONFIG.changeThemeByOS && CONFIG.autoChangeTheme) {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
if (CONFIG.changeThemeByOS && CONFIG.autoChangeTheme) {
if (
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches
) {
enableDark();
} else {
disableDark();
}
}

if(CONFIG.changeThemeByHour && CONFIG.autoChangeTheme) {
if (CONFIG.changeThemeByHour && CONFIG.autoChangeTheme && !CONFIG.changeThemeByOS) {
const date = new Date();
const hours = date.getHours() < 10 ? '0' + date.getHours().toString() : date.getHours().toString();
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes().toString() : date.getMinutes().toString();
const hours =
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;
if(currentTime >= CONFIG.hourDarkThemeActive) {
if (currentTime >= CONFIG.hourDarkThemeActive) {
enableDark();
} else if (currentTime >= CONFIG.hourDarkThemeInactive) {
disableDark();
Expand Down
12 changes: 5 additions & 7 deletions assets/js/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
// β””β”΄β”˜β””β”€β”˜β”΄ β”΄ β”΄ β”΄ β”΄β””β”€β”˜β”΄β””β”€

const iconElement = document.querySelector('.weatherIcon');
const tempElement = document.querySelector(
'.weatherValue p'
);
const descElement = document.querySelector(
'.weatherDescription p'
);
const tempElement = document.querySelector('.weatherValue p');
const descElement = document.querySelector('.weatherDescription p');

// App data
const weather = {};
Expand Down Expand Up @@ -73,6 +69,8 @@ function getWeather(latitude, longitude) {
// Display Weather info
function displayWeather() {
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;
}

0 comments on commit 7d23293

Please sign in to comment.