From 96c8d99ec74acad6f0c99d4d7c006a67ee7d643e Mon Sep 17 00:00:00 2001 From: CircleShift Date: Sat, 20 Dec 2025 11:18:55 -0500 Subject: Add debug mode --- scripts/gui-common/widgets.js | 24 +++++++++++++++++++++++- scripts/main.js | 7 +++++-- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/gui-common/widgets.js b/scripts/gui-common/widgets.js index 05d6126..f14fb22 100644 --- a/scripts/gui-common/widgets.js +++ b/scripts/gui-common/widgets.js @@ -1,5 +1,7 @@ 'use strict'; +var WIDGETS_DEBUG = false; + /** * The base Widget class. Represents an interactible * value-producing object in the browser, like an input. @@ -103,6 +105,10 @@ class Widget extends EventTarget{ /** @param {MouseEvent} event */ #emitMouseEvent(event) { + if (WIDGETS_DEBUG) { + console.log(event); + } + if (this.#inactive) this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new MouseEvent(event.type, event)}})); else @@ -115,6 +121,10 @@ class Widget extends EventTarget{ //if (window.SCROLLING) // return; + if (WIDGETS_DEBUG) { + console.log(event); + } + if (event.type == "touchstart") this.element.classList.add("touch"); else if (event.type == "touchend" || event.type == "touchcancel") @@ -130,6 +140,10 @@ class Widget extends EventTarget{ /** @param {KeyboardEvent} event */ #emitKeyboardEvent(event) { + if (WIDGETS_DEBUG) { + console.log(event); + } + if (this.#inactive) this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new KeyboardEvent(event.type, event)}})); else @@ -149,6 +163,10 @@ class Widget extends EventTarget{ /** @param {FocusEvent} event */ #emitFocusEvent(event) { + if (WIDGETS_DEBUG) { + console.log(event); + } + if (this.#inactive) this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new FocusEvent(event.type, event)}})); else @@ -161,6 +179,10 @@ class Widget extends EventTarget{ /** @param {Event} event */ #emitContextEvent(event) { + if (WIDGETS_DEBUG) { + console.log(event); + } + if (this.#inactive) this.dispatchEvent(new CustomEvent("inactive", {detail: {widget: this, event: new Event(event.type, event)}})); else @@ -599,7 +621,7 @@ class WidgetDragable extends Widget return; } - if (event.type == "touchend") + if (event.type == "touchend" || event.type == "touchcancel") { if (this.#touches[event.changedTouches[0].identifier] == 1) { diff --git a/scripts/main.js b/scripts/main.js index e67cff3..bda7798 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -8,8 +8,8 @@ class Client { /** @type {DescAny[]} */ let desc = [ { type: "button", name: "bt", props: {}, }, - { type: "checkbox", name: "cb", props: {}, state: true }, - { type: "toggle", name: "tg", props: {}, state: false }, + { type: "checkbox", name: "cb", props: {}, state: false }, + { type: "toggle", name: "tg", props: {}, state: true }, { type: "slider", name: "sli", props: {max: 10, min: 1, percent: true}, state: 6 }, { type: "color-light", name: "cli", state: 0.7 }, { type: "color-temp", name: "ctp", state: 3000 }, @@ -32,6 +32,9 @@ class Client { { if (e.detail.name == "scb" && e.detail.changed == "value") this.set.widgets["thm"].set(Temperature.from_celcius(e.detail.value)); + + if (e.detail.name == "cb" && e.detail.changed == "value") + WIDGETS_DEBUG = !(!(e.detail.value)) } } -- cgit v1.2.3