/
ivanby
/
Compote
Обзор
Документация
Войти
/
ivanby
/
Compote
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
master
compote/src/out_script.js
137 строк
5 KB
Иван Быков
Initial commit
19 июн 2026, 08:50
19 июн 2026, 08:50
b4391e5
Код
Авторство
О чём код?
/**@replace '$$_yagaConfig_compote_compote_' : '${yagaConfig.compote.compote}', '$$_compote_path_();' : '${compote_path}', '};//<--remove!!!' : '' */ window.$$_yagaConfig_compote_compote_ = { parents: function (_co) { // цепочка всех предков const _r = []; while(_co) { _r.unshift(_co); _co = _co.parent; } return _r; }, childs: function (_co) { // потомки, плоский массив всех потомков const _r = []; const _tr = (_c)=>{ /* //возможны условия, тут листья: if (!_c.childs || _c.childs.length == 0) { _r.push(_c); return; } */ _r.push(_c); _c.childs.forEach(ch => { _tr(ch); }); }; _tr(_co); return _r; }, setpath_: function (_co) { // назначение compote-id и compote-forename компоненту $$_compote_path_(); const _coElm = _co.getElem(); let a_marked; if(!_co.compote.marked) { a_marked = _coElm.getAttribute('marked'); if(typeof a_marked == 'string') a_marked = a_marked.trim(); else a_marked = ''; a_marked += ' ${yagaConfig.compote.marked}'; a_marked = a_marked.split(' '); _co.compote.marked = a_marked; if(a_marked.includes('compote-id')) { _coElm.setAttribute('compote-id', _co.compote.id); } if(a_marked.includes('compote-forename')) { _coElm.setAttribute('compote-forename', _co.compote.forename); } if(!a_marked.includes('compote')) { _coElm.removeAttribute('compote'); } if(!a_marked.includes('setlist')) { _coElm.removeAttribute('setlist'); } if(!a_marked.includes('marked')) { _coElm.removeAttribute('marked'); } } else { a_marked = _co.compote.marked; if(a_marked.includes('compote-id')) { _coElm.setAttribute('compote-id', _co.compote.id); } if(a_marked.includes('compote-forename')) { _coElm.setAttribute('compote-forename', _co.compote.forename); } } }, props_: function (_co, _prs, _izprs ) { if(_prs && typeof _prs === 'object' && !Array.isArray(_prs)) { for(const pnm of Object.keys(_prs)) if(pnm !== 'root' && pnm !== 'parent' && _co[pnm] && _co[pnm].props instanceof Function) _co[pnm].props(_prs[pnm]); _izprs(_prs); } else { const ret = {}; for(const pnm of Object.keys(_co)) if(pnm !== 'root' && pnm !== 'parent' && _co[pnm] && _co[pnm].props instanceof Function) ret[pnm] = _co[pnm].props(); return {..._izprs(), ...ret}; } }, nested_: function (_co, _prs, _parent, _as) { // _co.childs = []; _co.parent = _parent; const _el = _co.getElem(); _co.compote.name = _el.getAttribute('compote'); _co.compote.forename = typeof _as != 'undefined'? _as : _co.compote.name; if(typeof _co.parent == 'object') { _co.parent[_co.compote.forename] = _co; _co.root = _co.parent.root || _co.parent; } window.$$_yagaConfig_compote_compote_.setpath_(_co); for(const _cl of _el.querySelectorAll('[nested]')) { let _aprs = _cl.getAttribute('props'); if(typeof _aprs == 'string') { _aprs = this.props_attrs_[parseInt(_aprs)]; } if(_aprs && typeof _aprs == 'object') if(_prs && typeof _prs == 'object') _prs = Object.assign(_aprs, _prs); else _prs = _aprs; let _ca = _cl.getAttribute('nested').split(' as '); if(_ca[0]) _ca = { name: _ca[0], value: _ca[1] }; else _ca = [..._cl.attributes].find(atr=>atr.name != 'nested' && atr.name != 'props'); if(_ca) { if(typeof this[_ca.name] != 'function') throw 'Неизвестный компонент ' + _ca.name + ' в '+_co.compote.name+', продолжение невозможно.'; const _cn = _ca.value || _ca.name; _co[_cn] = this[_ca.name](_prs, _co, _cn); _cl.replaceWith(_co[_cn].getElem()); _co.childs.push(_co[_cn]); } } if(_prs && typeof _prs === 'object' && !Array.isArray(_prs))_co.props(_prs); _el.izba = _co; // в DOM элементе размещается ссылка на его об. izba }, version: "/**@exec //yaga/exec/version.js*/" , };//<--remove!!!