quill updates, signup comment

This commit is contained in:
metacryst
2026-03-31 07:08:07 -05:00
parent 8279a81dc9
commit 2592137fa3
2 changed files with 59 additions and 31 deletions

View File

@@ -103,7 +103,6 @@ class Signup extends Shadow {
e.preventDefault(); e.preventDefault();
const data = new FormData(e.target); const data = new FormData(e.target);
if (this.verifyInput(data)) { if (this.verifyInput(data)) {
this.errorMessage = "";
await this.requestSignup(data); await this.requestSignup(data);
} else { } else {
console.log(this.errorMessage) console.log(this.errorMessage)
@@ -111,6 +110,11 @@ class Signup extends Shadow {
}) })
} }
/*
*******************************************************************************
NO LONGER WORKS - SEE AUTH ENDPOINT IN SERVER
*******************************************************************************
*/
async requestSignup(data) { async requestSignup(data) {
const networkId = this.attr("networkid"); const networkId = this.attr("networkid");
const res = await fetch(`${util.HOST}/auth/signup`, { const res = await fetch(`${util.HOST}/auth/signup`, {

View File

@@ -1,6 +1,7 @@
/* /*
Sam Russell Sam Russell
Captured Sun Captured Sun
3.28.26 - Stopping state() from duplicating on rerender()
3.27.26 - Adding quill router, removing dynamicText(), removing horizontal and verticalAlign() checks 3.27.26 - Adding quill router, removing dynamicText(), removing horizontal and verticalAlign() checks
3.24.26 - Allowing state() to watch other elements 3.24.26 - Allowing state() to watch other elements
3.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings 3.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings
@@ -186,6 +187,7 @@ window.quill = {
rendering: [], rendering: [],
lastState: null, lastState: null,
router: null, router: null,
storedState: new WeakMap(),
router: class { router: class {
routes = [] routes = []
@@ -261,7 +263,19 @@ window.quill = {
quill.rendering.pop(el) quill.rendering.pop(el)
}, },
removeState: (el) => {
let state = quill.storedState.get(el)
if(state) {
state.forEach(observer => {
observer.disconnect()
})
}
quill.storedState.delete(el)
},
rerender: (el) => { rerender: (el) => {
quill.removeState(el)
Array.from(el.attributes).forEach(attr => el.removeAttribute(attr.name)); Array.from(el.attributes).forEach(attr => el.removeAttribute(attr.name));
el.innerHTML = "" el.innerHTML = ""
el.removeAllListeners() el.removeAllListeners()
@@ -763,54 +777,64 @@ HTMLElement.prototype.horizontalAlign = function (value) {
/* Elements */ /* Elements */
HTMLElement.prototype.state = function(arg1, arg2, arg3) { /*
STATE RULES:
reset on rerender()
elements not connected to the dom have their state listeners removed
*/
HTMLElement.prototype.state = function(arg1, arg2, arg3, arg4) {
let el; let el;
let attr; let attr;
let cb; let cb;
let runImmediately;
if(arg3) { // element, attr, callback
el = arg1 // element, attr, callback, bool
attr = arg2 // attr, callback
cb = arg3 // attr, callback, bool
if(arg1 instanceof Element) {
if(typeof arg4 === 'boolean') {
el = arg1; attr = arg2; cb = arg3; runImmediately = arg4;
} else {
el = arg1; attr = arg2; cb = arg3; runImmediately = true;
}
} else { } else {
el = this if(typeof arg3 === 'boolean') {
attr = arg1 el = this; attr = arg1; cb = arg2; runImmediately = arg3
cb = arg2 } else {
el = this; attr = arg1; cb = arg2; runImmediately = true
}
} }
if (attr !== attr.toLowerCase()) { if (attr !== attr.toLowerCase()) {
throw new Error(`quill: dynamicText() attr "${attr}" must be lowercase`); throw new Error(`quill: state() attr "${attr}" must be lowercase`);
} }
let handler = () => { let handler = () => {
const value = el.getAttribute(attr); const value = el.getAttribute(attr);
cb.call(this, value) if(!this.isConnected) {
quill.removeState(this)
} else {
cb.call(this, value)
}
} }
new MutationObserver(handler) let observer = new MutationObserver(handler)
.observe(el, { attributes: true, attributeFilter: [attr] }); observer.observe(el, { attributes: true, attributeFilter: [attr] })
handler() if(!quill.storedState.get(this)) {
quill.storedState.set(this, [])
}
quill.storedState.get(this).push(observer)
if(runImmediately) {
handler()
}
return this return this
} }
HTMLElement.prototype.dynamicText = function(attr, template) {
// Set initial text if attr already has a value
if (attr !== attr.toLowerCase()) {
throw new Error(`quill: dynamicText() attr "${attr}" must be lowercase`);
}
if (this.getAttribute(attr)) {
this.innerText = template.replace('{{}}', this.getAttribute(attr));
}
new MutationObserver(() => {
const value = this.getAttribute(attr);
this.innerText = template.replace('{{}}', value ?? '');
}).observe(this, { attributes: true, attributeFilter: [attr] });
return this
};
quill.setChildren = function(el, innerContent) { quill.setChildren = function(el, innerContent) {
if(typeof innerContent === "string") { if(typeof innerContent === "string") {
el.innerText = innerContent el.innerText = innerContent