mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-05 22:10:31 +02:00
fix some stuff
This commit is contained in:
parent
0936decd2b
commit
75cf355820
8 changed files with 149 additions and 15 deletions
|
@ -282,7 +282,7 @@ async function fetchWeather(location) {
|
|||
const query = location ? location : "Munich";
|
||||
|
||||
try {
|
||||
const response = await fetch(`https://wttr.in/${query}?format=%t | %C`);
|
||||
const response = await fetch(`https://wttr.in/${query}?format=%t | %C&lang=en`);
|
||||
const data = await response.text();
|
||||
target.innerText = data;
|
||||
return data;
|
||||
|
@ -355,16 +355,39 @@ typeWriter();
|
|||
fetchSong();
|
||||
|
||||
const weather = await fetchWeather();
|
||||
weather.toLowerCase();
|
||||
|
||||
if (weather && weather.includes("rain")) {
|
||||
const deco = document.createElement("script");
|
||||
let deco = document.createElement("script");
|
||||
|
||||
if (weather.includes("rain")) {
|
||||
deco.src = "/assets/js/rain.js";
|
||||
document.body.appendChild(deco);
|
||||
|
||||
} else if (weather.includes("snow")) {
|
||||
const deco = document.createElement("script");
|
||||
deco.src = "/assets/js/snow.js";
|
||||
document.body.appendChild(deco);
|
||||
}
|
||||
|
||||
} else if (weather.includes("coud")) {
|
||||
deco.src = "/assets/js/clouds.js";
|
||||
document.body.appendChild(deco);
|
||||
} else {
|
||||
deco.src = "/assets/js/sun.js";
|
||||
document.body.appendChild(deco);
|
||||
}
|
||||
|
||||
let decoShowing = true;
|
||||
|
||||
function toggleDeco() {
|
||||
decoShowing = !decoShowing;
|
||||
|
||||
const decoElem = document.querySelector("#deco");
|
||||
decoElem.style.display = `${decoShowing ? "block" : "none"}`;
|
||||
|
||||
const btn = document.querySelector("#show-deco")
|
||||
btn.innerHTML = `${decoShowing ? "Hide Decoration" : "Show Decoration"}`
|
||||
}
|
||||
|
||||
document.querySelector("#show-deco").addEventListener("click", toggleDeco);
|
||||
|
||||
let countdown = 60;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue