From f9487a48b9dfade8ed9316b840218e5920519491 Mon Sep 17 00:00:00 2001 From: Juli Date: Sat, 14 Sep 2024 20:58:37 +0300 Subject: [PATCH] added fancies --- feed.xml | 4 +- index.html | 17 +++++-- pages/contact/index.html | 17 +++++-- pages/feed/index.html | 17 +++++-- pages/license/index.html | 17 +++++-- posts.html | 19 ++++--- posts/test/index.html | 19 ++++--- static/info.js | 106 +++++++++++++++++++++++++++++++++++++++ tags/test/index.html | 19 ++++--- 9 files changed, 195 insertions(+), 40 deletions(-) create mode 100644 static/info.js diff --git a/feed.xml b/feed.xml index c612014..f1c1182 100644 --- a/feed.xml +++ b/feed.xml @@ -1,11 +1,11 @@ Juli's site - https://julimiro.eu + http://localhost:8000 2024-09-14 silly test page - + 2024-09-14 diff --git a/index.html b/index.html index f63189d..a15f4b5 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@ + @@ -63,24 +64,30 @@ + diff --git a/pages/contact/index.html b/pages/contact/index.html index d488747..82ddffb 100644 --- a/pages/contact/index.html +++ b/pages/contact/index.html @@ -15,6 +15,7 @@ + @@ -42,24 +43,30 @@ + diff --git a/pages/feed/index.html b/pages/feed/index.html index 0bcfad6..fa29aa5 100644 --- a/pages/feed/index.html +++ b/pages/feed/index.html @@ -15,6 +15,7 @@ + @@ -39,24 +40,30 @@ + diff --git a/pages/license/index.html b/pages/license/index.html index 459fcee..21d4f0a 100644 --- a/pages/license/index.html +++ b/pages/license/index.html @@ -15,6 +15,7 @@ + @@ -42,24 +43,30 @@ + diff --git a/posts.html b/posts.html index b7edc48..19c6331 100644 --- a/posts.html +++ b/posts.html @@ -15,6 +15,7 @@ + @@ -30,7 +31,7 @@

- silly test page + silly test page

Sat 14 Sep 2024

@@ -50,24 +51,30 @@

+ diff --git a/posts/test/index.html b/posts/test/index.html index 267c49b..f41318b 100644 --- a/posts/test/index.html +++ b/posts/test/index.html @@ -15,6 +15,7 @@ + @@ -29,7 +30,7 @@

Tags:

@@ -46,24 +47,30 @@ + diff --git a/static/info.js b/static/info.js new file mode 100644 index 0000000..0e5b9f7 --- /dev/null +++ b/static/info.js @@ -0,0 +1,106 @@ +function getCurrentTime() { + const date = new Date(); + const options = { + timeZone: "Europe/Helsinki", + hour: 'numeric', + minute: 'numeric', + second: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false // + }; + document.getElementById('time').innerText = "Time: "+date.toLocaleTimeString('en-US', options) + } + +function lastfm() { + const url = 'https://api.julimiro.eu/lastfmproxy.php'; + fetch(url) + .then(response => response.json()) + .then(data => { + const recenttracks = data.recenttracks; + const tracks = recenttracks.track; + for (const track of tracks) { + if (track["@attr"] && track["@attr"].nowplaying === "true") { + const artist = track.artist["#text"]; + const song = track.name; + const songUrl = track.url; + + console.log(`Artist: ${artist}`); + console.log(`Song: ${song}`); + console.log(`Song URL: ${songUrl}`); + document.getElementById('song').innerHTML = `

Now playing: ${song} by ${artist}

` + } else { + // document.getElementById('song').innerText = "" + }} + }) + .catch(error => console.error('Error:', error)); +} + +function getweather() { + const apiUrl = 'https://api.open-meteo.com/v1/forecast'; +const params = { + latitude: 61.4833, + longitude: 21.7833, + current: 'temperature_2m,precipitation,weather_code,wind_speed_10m', + timeformat: 'unixtime', + forecast_days: 1 +}; + +fetch(`${apiUrl}?${new URLSearchParams(params)}`) + .then(response => response.json()) + .then(data => { + const weatherCodes = [ + "unknown", "clearing","unknown","clouds forming","smoke","haze", + "dust","dust","dust whirls","duststorm","mist","patches of fog","continuous fog", + "visible lightning", "precipitation that doesn't reach ground","precipitation at distance", + "precipitation nearby","thunderstorm but no precipitation","squalls","funnel clouds", + "drizzle","rain","snow","rain and snow/ice pellets","freezing rain","showers of rain", + "showers of snow", "showers of hail","fog","thunderstorm","decreasing slight dust storm", + "slight dust storm","beginning severe dust storm","decreasing severe dust storm", + "severe dust storm","beginning severe dust storm","blowing snow below eye level", + "heavy drifting snow below eye level", "blowing snow above eye level", + "heavy drifting snow above eye level", "fog at distance","fog in patches", + "lessening fog with visible sky", "lessening fog without visible sky","fog with sky visible", + "fog without sky visible", "beginning fog with sky visible","beginning fog without sky visible", + "fog with rime and sky visible","fog with rime and without sky visible", + "sligth intermittent drizzle", "slight continuous drizzle", "moderate intermittent drizzle", + "moderate continuous drizzle", "heavy intermittent drizzle", "heavy continuous drizzle", + "slight freezing drizzle", "moderate or heavy freezing drizzle", "slight drizzle and rain", + "moderate or heavy drizzle and rain", "slight intermittent rain", "slight continuous rain", + "moderate intermittent rain", "moderate continuos rain","heavy intermittent rain", + "heavy continous rain", "slight freezing rain","moderate or heavy freezing rain", + "slight rain and snow", "moderate or heavy rain and snow", "slight intermittent snowfall", + "slight continuous snowfall", "moderate intermittent snowfall", "moderate continuous snowfall", + "heavy intermittent snowfall", "heavy continuous snowfall", "diamond dust", "snow grains", + "star-like crystals of snow"," ice pellets", "slight rain showers", "moderate or heavy rain showers", + "violent rain showers", "slight showers of rain and snow", "moderate or heavy showers of snow and rain", + "slight snow showers", "moderate or heavy snow showers", "slight showers of small hail", + "moderate or heavy small hail","slight showers of hail", "moderate or heavy showers of hail", + "slight rain with thunderstorms earlier", "moderate or heavy rain with thunderstorms earlier", + "slight snow or rain and hail mixed, thunderstorms earlier", + "moderate or heavy rain or snow and hail mixed, thunderstorms earlier", + "slight or moderate thunderstorm without hail","slight or moderate thunderstorm with hail", + "heavy thunderstorm with rain or snow", "heavy thunderstorm with duststorm", "heavy thunderstorm with hail" + ]; + + const currentWeatherCode = data.current.weather_code; + const currentWeather = weatherCodes[currentWeatherCode - 1]; + + console.log(`Current Weather: ${currentWeather}`); + console.log(`Temperature: ${data.current.temperature_2m}°C`); + console.log(`Precipitation: ${data.current.precipitation} mm`); + console.log(`Wind Speed: ${data.current.wind_speed_10m} km/h`); + document.getElementById('weather').innerHTML = `

Weather: ${currentWeather}

Temperature: ${data.current.temperature_2m}°C

Wind speed: ${data.current.wind_speed_10m} m/s` + }) + .catch(error => console.error('Error:', error)); +} + +window.addEventListener('load', function () { + setInterval(getCurrentTime, 1000); + setInterval(lastfm, 15000); + setInterval(lastfm, 300000); + lastfm() + getCurrentTime() + getweather() +}) \ No newline at end of file diff --git a/tags/test/index.html b/tags/test/index.html index e36426d..f45feb7 100644 --- a/tags/test/index.html +++ b/tags/test/index.html @@ -15,6 +15,7 @@ + @@ -30,7 +31,7 @@

- silly test page + silly test page

Sat 14 Sep 2024

@@ -50,24 +51,30 @@

+