This commit is contained in:
Philippe Torrel
2026-10-07 14:34:48 +02:00
parent 1fe62103a8
commit 7e6ec5b9ef
35 changed files with 1601 additions and 17 deletions
@@ -2,7 +2,7 @@
const $ = (qs) => document.querySelector(qs);
const $$ = (qs) => Array.from(document.querySelectorAll(qs));
Node.prototype.on = function(name, fn) {
Node.prototype.on = function (name, fn) {
this.addEventListener(name, fn);
return this;
};
@@ -12,11 +12,13 @@ Node.prototype.on = function(name, fn) {
// // wird zu:
// document.querySelector('button').on('click', (event) => { });
Array.prototype.on = Array.prototype.addEventListener = function(name, fn) {
Array.prototype.on = Array.prototype.addEventListener = function (name, fn) {
this.forEach((elem) => elem.on(name, fn));
return this;
};
NodeList.prototype.__proto__ = Array.prototype;
// anstatt
// Array.from(document.querySelectorAll('.menu-main li a')).forEach((elem) =>
// elem.addEventListener('click', (event) => {
@@ -31,12 +33,9 @@ Array.prototype.on = Array.prototype.addEventListener = function(name, fn) {
// }
// );
// helper
const $on = (el, ev, fn) => {
Array.isArray(el) ? el.forEach(ae => $on(ae, ev, fn)) :
el.addEventListener(ev, fn);
Array.isArray(el) ? el.forEach((ae) => $on(ae, ev, fn)) : el.addEventListener(ev, fn);
return el;
};
@@ -80,8 +79,7 @@ function rangeFromStartToEnd(start, end, step = 1) {
result[index++] = value;
}
return result;
};
}
function range(startOrEnd, end, step) {
if (end) {
@@ -89,4 +87,4 @@ function range(startOrEnd, end, step) {
} else {
return rangeFromStartToEnd(0, startOrEnd);
}
};
}