This commit is contained in:
2026-03-04 18:15:45 +01:00
parent afa3778103
commit 3a2abf90f6
16 changed files with 1563 additions and 93 deletions

View File

@@ -48,7 +48,7 @@ window.rkt_bind_evt_ids = function(win_nr, selector, event_kind) {
try {
let nodelist = document.querySelectorAll(selector);
if (nodelist === undefined || nodelist === null) {
return 'json:[]';
return [];
}
let ids = [];
nodelist.forEach(function(el) {
@@ -68,9 +68,27 @@ window.rkt_bind_evt_ids = function(win_nr, selector, event_kind) {
ids.push(info);
}
});
return 'json:' + JSON.stringify(ids);
return ids;
} catch(e) {
return 'json:[]';
return [];
}
};
window.rkt_with_selector = function(selector, func) {
let nodelist = document.querySelectorAll(selector);
if (nodelist === undefined || nodelist === null) {
return [];
}
let results = [];
let applier = function(el) {
let id = el.getAttribute('id');
results.push(func(id, el));
}
nodelist.forEach(applier);
let c = results.length;
let r = { 'applied-to-elements': c, 'with-ids': results.filter((id) => id !== null) };
return r;
}