Move scripts

This commit is contained in:
Florian Hoss 2024-04-04 09:34:29 +02:00
parent 4e4bdf5bcd
commit 73fbe6c3f7
3 changed files with 32 additions and 34 deletions

View file

@ -57,9 +57,6 @@ templ Uptime(extraInfo string, id string, uptime services.Uptime) {
</div>
</div>
</div>
}
templ SystemScript() {
<script>
let systemSSESource = null;
addEventListener('beforeunload', () => {

View file

@ -59,9 +59,6 @@ templ Weather(weather *services.OpenWeather) {
</div>
</div>
</div>
}
templ WeatherScript() {
<script>
let weatherSSESource = null;
addEventListener('beforeunload', () => {
@ -82,32 +79,39 @@ templ WeatherScript() {
const weatherSunrise = document.getElementById('weatherSunrise');
const weatherSunset = document.getElementById('weatherSunset');
function weatherClass(icon){
function weatherClass(icon) {
switch (icon) {
case "01d":
return "icon-[bi--sun-fill]"
return "icon-[bi--sun-fill]";
case "01n":
return "icon-[bi--moon-fill]"
return "icon-[bi--moon-fill]";
case "02d":
return "icon-[bi--cloud-sun-fill]"
return "icon-[bi--cloud-sun-fill]";
case "02n":
return "icon-[bi--cloud-moon-fill]"
case "03d", "03n":
return "icon-[bi--cloud-fill]"
case "04d", "04n":
return "icon-[bi--clouds-fill]"
case "09d", "09n":
return "icon-[bi--cloud-rain-heavy-fill]"
case "10d", "10n":
return "icon-[bi--cloud-drizzle-fill]"
case "11d", "11n":
return "icon-[bi--cloud-lightning-rain-fill]"
case "13d", "13n":
return "icon-[bi--cloud-snow-fill]"
case "50d", "50n":
return "icon-[bi--cloud-fog2-fill]"
return "icon-[bi--cloud-moon-fill]";
case "03d":
case "03n":
return "icon-[bi--cloud-fill]";
case "04d":
case "04n":
return "icon-[bi--clouds-fill]";
case "09d":
case "09n":
return "icon-[bi--cloud-rain-heavy-fill]";
case "10d":
case "10n":
return "icon-[bi--cloud-drizzle-fill]";
case "11d":
case "11n":
return "icon-[bi--cloud-lightning-rain-fill]";
case "13d":
case "13n":
return "icon-[bi--cloud-snow-fill]";
case "50d":
case "50n":
return "icon-[bi--cloud-fog2-fill]";
default:
return ""
return "";
}
}
@ -116,7 +120,6 @@ templ WeatherScript() {
if (className.startsWith('icon-')) {
weatherIcon.classList.remove(className);
}
break;
});
weatherIcon.classList.add(weatherClass(parsed.icon));
weatherTemp.innerText = parsed.temp;

View file

@ -52,8 +52,6 @@ templ Home(title string, claims *core.IdTokenClaims, bookmarks *services.Bookmar
</div>
}
</div>
@components.WeatherScript()
@components.SystemScript()
</section>
}