Mercurial > code > home > repos > light-bridge
diff src/main.ts @ 22:178e020289c1
'full' button; other clean up
author | drewp@bigasterisk.com |
---|---|
date | Mon, 29 Jan 2024 13:01:23 -0800 |
parents | 4e350dcdc4fe |
children |
line wrap: on
line diff
--- a/src/main.ts Mon Jan 29 12:27:08 2024 -0800 +++ b/src/main.ts Mon Jan 29 13:01:23 2024 -0800 @@ -86,7 +86,7 @@ </table> <p>Updated ${this.reportTime.toLocaleString("sv")}</p> <p> - <a href="metrics">metrics</a> | + <a href="metrics">metrics</a> | <a href="https://bigasterisk.com/code/light-bridge/files/tip/">code</a> | <a href="api/graph">graph</a> </p> <bigast-loginbar></bigast-loginbar> @@ -112,8 +112,9 @@ <td class="col-group-1"><code>${this.renderLinked(d.address)}</code></td> <td class="col-group-2"> <code>${d.requestingColor}</code> - <input type="color" @input=${this.onRequestingColor.bind(this, d.name)} .value="${d.requestingColor}" /> - <button @click=${this.onZero.bind(this, d.name)}>off</button> + <input type="color" @input=${this.onRequestingColor.bind(this, d.name, null)} .value="${d.requestingColor}" /> + <button @click=${this.onRequestingColor.bind(this, d.name, "#000000")}>off</button> + <button @click=${this.onRequestingColor.bind(this, d.name, "#ffffff")}>full</button> </td> <td class="col-group-2 opt"><code>${JSON.stringify(d.requestingDeviceColor)}</code></td> <td class="col-group-3">${d.emittingColor} <span class="color" style="background: ${d.emittingColor}"></span></td> @@ -131,19 +132,9 @@ return addr; } - async onRequestingColor(lightName: string, ev: InputEvent) { + async onRequestingColor(lightName: string, preset: string | null, ev: InputEvent) { const currentRequest = this.lightByName.get(lightName)!.requestingColor; - const value = (ev.target as HTMLInputElement).value; - this.onCol(value, currentRequest, lightName); - } - - async onZero(lightName: string, ev: InputEvent) { - const currentRequest = this.lightByName.get(lightName)!.requestingColor; - const value = "#000000"; - this.onCol(value, currentRequest, lightName); - } - - private onCol(value: string, currentRequest: string, lightName: string) { + const value = preset || (ev.target as HTMLInputElement).value; console.log("LbPage ~ onRequestingColor ~ value === currentRequest:", value, currentRequest); if (value === currentRequest) { return;