This commit is contained in:
german 2026-04-08 19:20:20 +04:00
parent 75c551347e
commit 5cfdfdbcca
2 changed files with 13 additions and 6 deletions

View File

@ -125,4 +125,8 @@ map.value(/* value для замены */); // Без аргументов ве
map.id(/* ID элемента */); // Вернет экземпляр map для выбранного элемента map.id(/* ID элемента */); // Вернет экземпляр map для выбранного элемента
map.tag(/* TAG элемента */); // Вернет экземпляр map для выбранного элемента map.tag(/* TAG элемента */); // Вернет экземпляр map для выбранного элемента
map.attach(/* событие */, /* функция */); // EventHandler map.attach(/* событие */, /* функция */); // EventHandler
/*
* Функция в attach может принимать параметр.
* Этот параметр - обьект Find, map которого был вызван
*/
``` ```

View File

@ -24,11 +24,12 @@
const ERROR_CODE = "Find framework error:"; const ERROR_CODE = "Find framework error:";
class FindObjectMap { class FindObjectMap {
constructor(_root) { constructor(_root, app) {
this.root = _root; this.root = _root;
if (typeof this.root !== "object") { if (typeof this.root !== "object") {
PrivateFind.error("Unknown root!"); PrivateFind.error("Unknown root!");
} }
this._app = app;
return this; return this;
} }
select(q) { select(q) {
@ -37,7 +38,7 @@ class FindObjectMap {
PrivateFind.error("No objects of selector"); PrivateFind.error("No objects of selector");
return undefined; return undefined;
} }
return new FindObjectMap(o); return new FindObjectMap(o, this._app);
} }
read() { read() {
return this.root.innerHTML; return this.root.innerHTML;
@ -69,7 +70,7 @@ class FindObjectMap {
PrivateFind.error("No objects of selector"); PrivateFind.error("No objects of selector");
return undefined; return undefined;
} }
return new FindObjectMap(o); return new FindObjectMap(o, this._app);
} }
tag(q) { tag(q) {
const o = this.root.getElementsByTagName(q); const o = this.root.getElementsByTagName(q);
@ -77,10 +78,12 @@ class FindObjectMap {
PrivateFind.error("No objects of selector"); PrivateFind.error("No objects of selector");
return undefined; return undefined;
} }
return new FindObjectMap(o); return new FindObjectMap(o, this._app);
} }
attach(event, func) { attach(event, func) {
this.root.addEventListener(event, func); this.root.addEventListener(event, () => {
func(this._app);
});
} }
} }
@ -92,7 +95,7 @@ export default class {
this.root = root; this.root = root;
this.groups = new Array(); this.groups = new Array();
this.groups_count = 0; this.groups_count = 0;
this._map = new FindObjectMap(this.root); this._map = new FindObjectMap(this.root, this);
return this; return this;
} }