/
ivanby
/
Compote
Обзор
Документация
Войти
/
ivanby
/
Compote
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
master
compote/src/out_script-setlist.js
127 строк
5 KB
Иван Быков
Обновление README, изменения в compote
07 июл 2026, 09:24
07 июл 2026, 09:24
85b2e12
Код
Авторство
О чём код?
/**@replace '$$_yagaConfig_compote_compote_' : '${yagaConfig.compote.compote}', '$$_setlist_' : '${setlist}', 'setlist_ = {//<--replace!!!' : 'setlist_: {', '};//<--replace!!!' : '},' */ // любой метод если принимает, то это просы или массивы пропсов // любой метод если возвращает, то это просы или массивы пропсов setlist_ = {//<--replace!!! splice: function ($this, idxs, cntrm, ...items) { let len = $this.childs.length; let ret = []; if(typeof idxs != 'number') idxs = 0; if(typeof cntrm != 'number' || cntrm < 0) cntrm = 0; if(idxs > len) idxs = len; if(idxs < 0) idxs = len + idxs; if(idxs < 0) idxs = 0; if(cntrm > 0 && idxs < len) { let toIdx = idxs + cntrm; if(toIdx > len) toIdx = len; for(let idx = idxs; idx < toIdx; idx++) $this.childs[idx].getElem().remove(); for(let idx = idxs; idx < len; idx++){ if($this[idx].destroy instanceof Function) $this[idx].destroy(); delete $this[idx]; } ret = $this.childs.splice(idxs, cntrm).map(itm=>itm.props()); len = $this.childs.length; $this.length = len; for(let idx = idxs; idx < len; idx++) { $this[idx] = $this.childs[idx]; $this[idx].compote.forename = idx; if($this[idx].$index instanceof Function) $this[idx].$index(idx); for(const chld of window.$$_yagaConfig_compote_compote_.childs($this[idx])) window.$$_yagaConfig_compote_compote_.setpath_(chld); } } if(Array.isArray(items) && items.length) { const $elem = $this.getElem(); const elems = []; len = $this.childs.length; for(let idx = 0; idx < items.length; idx++) { let citm = {}; const gidx = idxs + idx; const itm = items[idx]; if(itm && typeof itm == 'object' && !Array.isArray(itm)) { citm = Object.assign(itm, $this.$$_setlist_.template_props); } const nwc = window.$$_yagaConfig_compote_compote_[$this.$$_setlist_.template](citm, $this, gidx); $this.childs.splice(gidx, 0, nwc); } for(let idx = idxs; idx < $this.childs.length; idx++) { $this[idx] = $this.childs[idx]; $this[idx].compote.forename = idx; if($this[idx].$index instanceof Function) $this[idx].$index(idx); for(const chld of window.$$_yagaConfig_compote_compote_.childs($this[idx])) window.$$_yagaConfig_compote_compote_.setpath_(chld); elems.push($this[idx].getElem()); } if(!len || idxs >= len) $elem.append(...elems); else if(!idxs) $elem.prepend(...elems); else $elem.children[idxs].before(...elems); $this.length = $this.childs.length; } return ret; }, slice: function ($this, idx, idxe) { return $this.childs.slice(idx, idxe).map(itm=>itm.props()); }, push: function ($this, ...items) { this.splice($this, $this.length, 0, ...items); return $this.length; }, pop: function ($this) { const lidx = $this.length-1; if(lidx < 0) return; return this.splice($this, lidx, 1)[0]; }, unshift: function ($this, ...items) { this.splice($this, 0, 0, ...items); return $this.length; }, shift: function ($this) { if(!$this.length) return; return this.splice($this, 0, 1)[0]; }, insert: function ($this, idx, ...items) { this.splice($this, idx, 0, ...items); return $this.length; }, remove: function ($this, idx, cnt) { if(typeof cnt != 'number') cnt = 1; else if(cnt < 0 || cnt > $this.childs.length) cnt = $this.childs.length; return this.splice($this, idx, cnt); }, props: function ($this, prps, setlistnm, $izba_props) { if(prps && typeof prps === 'object' && !Array.isArray(prps)) { if(prps[setlistnm] && Array.isArray(prps[setlistnm]) && prps[setlistnm].length) { if($this.childs.length) $this.clean(); $this.push(...prps[setlistnm]); delete prps[setlistnm]; } $izba_props(prps); } else return {...$izba_props(), [setlistnm]: $this.childs.map(chl=>chl.props())}; }, };//<--replace!!!