Move scripts
This commit is contained in:
parent
4e4bdf5bcd
commit
73fbe6c3f7
3 changed files with 32 additions and 34 deletions
|
@ -57,9 +57,6 @@ templ Uptime(extraInfo string, id string, uptime services.Uptime) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
templ SystemScript() {
|
|
||||||
<script>
|
<script>
|
||||||
let systemSSESource = null;
|
let systemSSESource = null;
|
||||||
addEventListener('beforeunload', () => {
|
addEventListener('beforeunload', () => {
|
||||||
|
|
|
@ -59,9 +59,6 @@ templ Weather(weather *services.OpenWeather) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
|
|
||||||
templ WeatherScript() {
|
|
||||||
<script>
|
<script>
|
||||||
let weatherSSESource = null;
|
let weatherSSESource = null;
|
||||||
addEventListener('beforeunload', () => {
|
addEventListener('beforeunload', () => {
|
||||||
|
@ -82,32 +79,39 @@ templ WeatherScript() {
|
||||||
const weatherSunrise = document.getElementById('weatherSunrise');
|
const weatherSunrise = document.getElementById('weatherSunrise');
|
||||||
const weatherSunset = document.getElementById('weatherSunset');
|
const weatherSunset = document.getElementById('weatherSunset');
|
||||||
|
|
||||||
function weatherClass(icon){
|
function weatherClass(icon) {
|
||||||
switch (icon) {
|
switch (icon) {
|
||||||
case "01d":
|
case "01d":
|
||||||
return "icon-[bi--sun-fill]"
|
return "icon-[bi--sun-fill]";
|
||||||
case "01n":
|
case "01n":
|
||||||
return "icon-[bi--moon-fill]"
|
return "icon-[bi--moon-fill]";
|
||||||
case "02d":
|
case "02d":
|
||||||
return "icon-[bi--cloud-sun-fill]"
|
return "icon-[bi--cloud-sun-fill]";
|
||||||
case "02n":
|
case "02n":
|
||||||
return "icon-[bi--cloud-moon-fill]"
|
return "icon-[bi--cloud-moon-fill]";
|
||||||
case "03d", "03n":
|
case "03d":
|
||||||
return "icon-[bi--cloud-fill]"
|
case "03n":
|
||||||
case "04d", "04n":
|
return "icon-[bi--cloud-fill]";
|
||||||
return "icon-[bi--clouds-fill]"
|
case "04d":
|
||||||
case "09d", "09n":
|
case "04n":
|
||||||
return "icon-[bi--cloud-rain-heavy-fill]"
|
return "icon-[bi--clouds-fill]";
|
||||||
case "10d", "10n":
|
case "09d":
|
||||||
return "icon-[bi--cloud-drizzle-fill]"
|
case "09n":
|
||||||
case "11d", "11n":
|
return "icon-[bi--cloud-rain-heavy-fill]";
|
||||||
return "icon-[bi--cloud-lightning-rain-fill]"
|
case "10d":
|
||||||
case "13d", "13n":
|
case "10n":
|
||||||
return "icon-[bi--cloud-snow-fill]"
|
return "icon-[bi--cloud-drizzle-fill]";
|
||||||
case "50d", "50n":
|
case "11d":
|
||||||
return "icon-[bi--cloud-fog2-fill]"
|
case "11n":
|
||||||
default:
|
return "icon-[bi--cloud-lightning-rain-fill]";
|
||||||
return ""
|
case "13d":
|
||||||
|
case "13n":
|
||||||
|
return "icon-[bi--cloud-snow-fill]";
|
||||||
|
case "50d":
|
||||||
|
case "50n":
|
||||||
|
return "icon-[bi--cloud-fog2-fill]";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +120,6 @@ templ WeatherScript() {
|
||||||
if (className.startsWith('icon-')) {
|
if (className.startsWith('icon-')) {
|
||||||
weatherIcon.classList.remove(className);
|
weatherIcon.classList.remove(className);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
});
|
});
|
||||||
weatherIcon.classList.add(weatherClass(parsed.icon));
|
weatherIcon.classList.add(weatherClass(parsed.icon));
|
||||||
weatherTemp.innerText = parsed.temp;
|
weatherTemp.innerText = parsed.temp;
|
||||||
|
|
|
@ -52,8 +52,6 @@ templ Home(title string, claims *core.IdTokenClaims, bookmarks *services.Bookmar
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@components.WeatherScript()
|
|
||||||
@components.SystemScript()
|
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue