Market filter works except for exclusive boxes

This commit is contained in:
metacryst
2025-11-25 12:51:32 -06:00
parent cf9edc066a
commit dc9b106439
6 changed files with 115 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
/*
Sam Russell
Captured Sun
11.25.25 - Added onChange for check boxes, added setQuery / onQueryChanged for easy filtering
11.24.25 - Fixing onClick because it was reversed, adding event to onHover params
11.23.25 - Added onSubmit() event for form submission, added marginHorizontal() and marginVertical()
11.20.25 - Added "pct" style unit, added alignVertical and alignHorizontal for flex boxes
@@ -28,6 +29,23 @@ history.pushState = function pushState() {
window.addEventListener('popstate', () => {
window.dispatchEvent(new Event('navigate'));
});
window.setQuery = function(key, value) {
const url = new URL(window.location.href);
const params = url.searchParams;
if (value === null || value === undefined) {
params.delete(key);
} else {
params.set(key, value);
}
const newUrl = url.toString();
history.replaceState(null, "", newUrl);
window.dispatchEvent(new Event('query-changed'));
return newUrl;
};
window.navigateTo = function(url) {
window.dispatchEvent(new Event('navigate'));
@@ -877,6 +895,14 @@ HTMLElement.prototype.onInput = function(cb) {
return this;
};
HTMLElement.prototype.onChange = function(cb) {
if(!this.matches('input, textarea, [contenteditable=""], [contenteditable="true"]'))
throw new Error("Can't put input event on non-input element!")
this._storeListener("change", cb);
return this;
};
HTMLElement.prototype.onSubmit = function(cb) {
if(!this.matches('form'))
throw new Error("Can't put form event on non-form element!")
@@ -929,6 +955,33 @@ window.addEventListener("navigate", () => {
}
})
/*
Same principle applies
*/
queryListeners = []
HTMLElement.prototype.onQueryChanged = function(cb) {
this._storeListener("query-changed", cb);
let found = false
for(entry of queryListeners) {
if(entry.cb.toString() === cb.toString() &&
this.nodeName === entry.el.nodeName) {
found = true
break;
}
}
if(found === false) {
queryListeners.push({el: this, cb: cb})
}
return this;
};
window.addEventListener("query-changed", () => {
for(entry of queryListeners) {
entry.el.dispatchEvent(new CustomEvent("query-changed"))
}
})
HTMLElement.prototype.onEvent = function(name, cb) {
window._storeListener(window, name, cb);
return this;