-
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user