Smarter way to do icons

This commit is contained in:
Neale Pickett 2023-01-22 16:46:30 -07:00
parent 2b52bc5d29
commit dc3efd3104
2 changed files with 13 additions and 8 deletions

View File

@ -19,8 +19,10 @@
<!-- Vail stuff -->
<link rel="manifest" href="manifest.json">
<link rel="icon" href="assets/vail.png" sizes="256x256" type="image/png">
<link rel="icon" href="assets/vail.svg" sizes="any" type="image/svg+xml">
<link rel="icon" class="quiet icon" href="assets/vail.png" sizes="256x256" type="image/png">
<link rel="icon" class="quiet icon" href="assets/vail.svg" sizes="any" type="image/svg+xml">
<link rel="" class="rx icon" href="assets/vail-rx.png" sizes="256x256" type="image/png">
<link rel="" class="rx icon" href="assets/vail-rx.svg" sizes="any" type="image/svg+xml">
<script type="module" src="scripts/vail.mjs"></script>
<script type="module" src="scripts/ui.mjs"></script>
<link rel="stylesheet" href="vail.css">

View File

@ -165,10 +165,13 @@ class VailClient {
document.querySelector("#keyer-rate").dispatchEvent(new Event("input"))
}
setIconBase(base) {
for (let e of document.querySelectorAll("link[rel=icon]")) {
let ext = e.href.split(".")[1]
e.href = `${base}.${ext}`
setIconBase(icon) {
for (let e of document.querySelectorAll("link.icon")) {
if (e.classList.contains(icon)) {
e.relList.add("icon")
} else {
e.relList.remove("icon")
}
}
}
@ -176,8 +179,8 @@ class VailClient {
this.outputs.Buzz(false)
clearTimeout(this.activityTimeout)
this.activityTimeout = setTimeout(() => this.setIconBase("assets/vail"), 2*time.Second)
this.setIconBase("assets/vail-rx")
this.activityTimeout = setTimeout(() => this.setIconBase("quiet"), 2*time.Second)
this.setIconBase("rx")
if (this.rxChart) this.rxChart.Set(1)
}