From 0072e6d86eb819a7ca8a6ebbbd8e8da7a0783cc2 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 29 Dec 2024 16:55:14 +0100 Subject: [PATCH] Some changes. --- src/rwebgui/static/rwebgui.js | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/rwebgui/static/rwebgui.js b/src/rwebgui/static/rwebgui.js index 8a638da..9a129c1 100644 --- a/src/rwebgui/static/rwebgui.js +++ b/src/rwebgui/static/rwebgui.js @@ -20,7 +20,6 @@ const allEvents = [ 'dragenter', 'dragleave', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointerup', 'pointermove', 'pointerover', 'pointerout', 'pointerenter', 'pointerleave', 'wheel'/*'scroll',*/ - // Add more as needed ]; const props = [ 'data', @@ -104,20 +103,15 @@ const callback = (mutationList, observer) => { } } }; -// Create an observer instance linked to the callback function const observer = new MutationObserver(callback); -// Start observing the target node for configured mutations observer.observe(rWebGui, config); -// Later, you can stop observing -//observer.disconnect(); } -class MyCustomElement extends HTMLElement { - static observedAttributes = ["color", "size"]; +class RWebGuiApp extends HTMLElement { _ready = false _uuid = null ws = null @@ -138,7 +132,7 @@ class MyCustomElement extends HTMLElement { // Always call super first in constructor super(); if(!this.parent || !this.parent.app){ - this.ws = new WebSocket(`ws://${window.location.host}/ws/${this.uuid}`) + this.ws = new WebSocket(`wss://${window.location.host}/ws/${this.uuid}`) const me = this this.ws.onopen = ()=>{ me.connected = true; @@ -252,7 +246,6 @@ class MyCustomElement extends HTMLElement { } connectedCallback() { - console.log("Custom element added to page."); this.rWebGui() @@ -270,25 +263,15 @@ class MyCustomElement extends HTMLElement { this._ready = true } - disconnectedCallback() { - console.log("Custom element removed from page."); - } - - adoptedCallback() { - console.log("Custom element moved to new page."); - } - attributeChangedCallback(name, oldValue, newValue) { this.emit("attributeChanged", {aa:123}) - console.log(`Attribute ${name} has changed.`); } } -customElements.define("rwebgui-app", MyCustomElement); +customElements.define("rwebgui-app",RWebGuiApp); /* document.addEventListener("DOMContentLoaded", () => { - console.log("DOM fully loaded and parsed"); document.querySelectorAll("*").forEach(child => { child.rWebGui() })