diff --git a/static/index.js b/static/index.js
index 36d7e55..cc43dd0 100644
--- a/static/index.js
+++ b/static/index.js
@@ -16,13 +16,7 @@ class WSElement extends HTMLElement {
this.#connect_socket(false);
}
- #connect_socket(recreate) {
- // `recreate` is used to handle reconnects, removeing the old websocket object
- // and recreating a new one
- if(recreate && WSElement.#sockets[this.src]) {
- delete WSElement.#sockets[this.src];
- }
-
+ #connect_socket() {
// a single WebSocket can be reused for multiple elements
// check to see if one exists for this `src` else create
// a new one.
@@ -77,9 +71,11 @@ class WSElement extends HTMLElement {
this.close(sock);
}
+ delete WSElement.#sockets[this.src];
+
// handle autoreconnect and delay throttling
if(this.autoreconnect) {
- setTimeout(this.#connect_socket.call(this, true), this.#delay);
+ setTimeout(this.#connect_socket.bind(this), this.#delay);
if(this.#delay < 10000) {
this.#delay += 1000;
}
@@ -131,7 +127,11 @@ class WSInput extends WSSenderElement {
connectedCallback() {
super.connectedCallback();
- this.insertAdjacentHTML('beforeend', ' ');
+ this.insertAdjacentHTML('beforeend', `
+
+ `
+ );
+
this.input = this.querySelector('input');
var self = this;
this.input.addEventListener('keyup', function(evt) {