objs-core 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -5
- package/objs.1.0.js +2 -2
- package/objs.1.0.min.js +1 -1
- package/objs.npm.1.0.js +1 -1
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -2,28 +2,42 @@
|
|
|
2
2
|
> Fast and simple JS library to develop, test, cache and optimize. You can develop new features with Objs without rewriting anything. Examples and full documentation are [here](https://fous.name/objs)
|
|
3
3
|
|
|
4
4
|
Feel free to use and share ideas for the next versions!
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## Get started
|
|
6
|
-
Just include script or load in project by NPM
|
|
10
|
+
Just include script or load in project by NPM
|
|
7
11
|
```
|
|
8
12
|
<script src="objs.1.0.min.js" type="text/javascript"></script>
|
|
9
13
|
```
|
|
10
14
|
```
|
|
11
|
-
npm
|
|
15
|
+
npm i objs-core
|
|
12
16
|
```
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
13
21
|
## Features
|
|
14
|
-
|
|
22
|
+
|
|
23
|
+
#### Develop
|
|
15
24
|
- Elements state control
|
|
16
25
|
- Store data in object itself
|
|
17
26
|
- Cache server rendered elements
|
|
18
|
-
|
|
27
|
+
|
|
28
|
+
#### Test
|
|
19
29
|
- Sync/async tests
|
|
20
30
|
- Console & HTML output
|
|
21
31
|
- Autotests
|
|
22
|
-
|
|
32
|
+
|
|
33
|
+
#### Optimize
|
|
23
34
|
- Separated HTML and JS logic
|
|
24
35
|
- Async loading JS, CSS, images
|
|
25
36
|
- Cache JS, CSS
|
|
26
37
|
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
27
41
|
## Main principles
|
|
28
42
|
Logic structure to create any dynamic module and controll it
|
|
29
43
|
To control element Objs uses states. State - it's an information how to create or change element. To create element use `render` state with html (inner HTML) and tag attributes:
|
|
@@ -65,5 +79,163 @@ States are done and the last thing is to create and append element on the page.
|
|
|
65
79
|
|
|
66
80
|
|
|
67
81
|
|
|
82
|
+
## Functions
|
|
83
|
+
Almost all functions return control object with methods, let's call it **Objs**.
|
|
84
|
+
|
|
85
|
+
### Root functions
|
|
86
|
+
`o(q)` – gets elements to control object. If [string] - by querySelectorAll(q) into control object, if DOM element or an array of them - gets them, if [number] - gets control object from **o.inits[q]**.
|
|
87
|
+
|
|
88
|
+
`o.first(q)` – gets element to control by querySelector(q).
|
|
89
|
+
|
|
90
|
+
`o.take(q)` – gets elements like **o(q)** from DOM but if there is just one element or equal number of elements to inited in **o.inits[]**, gets all inited methods.
|
|
91
|
+
|
|
92
|
+
#### States control
|
|
93
|
+
`o.init(states)` – returns **Objs**, creates method(s) for each state to create, change elements. State called **render** is reserved for creation elements. **states** can be [string], [object], [function] that returns [string] or [object]. After **init()** **Objs** gets a **initID** parameter for a saved object in **o.inits**. More info [here](https://fous.name/objs).
|
|
94
|
+
|
|
95
|
+
`o.initState(state, [props])` – inite method and call it with props, e.g. to render/create element. **Objs** gets a **initID** parameter for a saved object in **o.inits**.
|
|
96
|
+
|
|
97
|
+
`o.inits[initID]` – an array of all inited objects. Available by index **initID** or **o.take()**.
|
|
98
|
+
|
|
99
|
+
`o.onError` – false as default, but can be a function that will get errors as the first parameter.
|
|
100
|
+
|
|
101
|
+
#### AJAX
|
|
102
|
+
`o.get(url, [props])` – returns promise for GET AJAX, **data** in **props** as an [object] will be converted to string parameters.
|
|
103
|
+
|
|
104
|
+
`o.post(url, props)` – returns promise for POST AJAX, **data** in **props** as an [object] will be converted to body.
|
|
105
|
+
|
|
106
|
+
`o.ajax(url, props)` – returns propmise for AJAX, needs **method** in **props** equal to GET or POST, **data** will be converted for GET/POST format.
|
|
107
|
+
|
|
108
|
+
`o.getParams([key])` – returns GET **key** value or an object with all GET parameters.
|
|
109
|
+
|
|
110
|
+
#### Include / load JS, CSS, images
|
|
111
|
+
`o.inc(sources, [callBack, callBad])` – returns [number] **setID**, gets **souces** is an object like {nameID: url, ...} where **nameID** is unique ID, **url** link to JS, CSS or image, **callBack** – function to run after everything is loaded successfully, **callBad** - function to run on failure. Functions gets **setN** as the first argument.
|
|
112
|
+
|
|
113
|
+
`o.incCheck(setID)` – true if include files set number **setID** is loaded.
|
|
114
|
+
|
|
115
|
+
`o.incCacheClear([all])` – true. Clears localStorage JS, CSS cache. If **all** is true, removes DOM elements of include and clears all include data.
|
|
116
|
+
|
|
117
|
+
`o.incCache` – true, cache in localStorage enabled.
|
|
118
|
+
|
|
119
|
+
`o.incCacheExp` – 1000 * 60 * 60 * 24, cache for 24 hours.
|
|
120
|
+
|
|
121
|
+
`o.incTimeout` – 6000, ms timeout to load function.
|
|
122
|
+
|
|
123
|
+
`o.incSource` – '', prefix for urls.
|
|
124
|
+
|
|
125
|
+
`o.incForce` – false, do not load already loaded files.
|
|
126
|
+
|
|
127
|
+
`o.incAsync` – true, async loading, set to false for in order loading.
|
|
128
|
+
|
|
129
|
+
`o.incCors` – false, do not allow loading from other domains
|
|
130
|
+
|
|
131
|
+
`o.incFns` – object, array of name:status for all loaded functions.
|
|
132
|
+
|
|
133
|
+
#### Unit tests
|
|
134
|
+
`o.test(title, test1, test2, ..., callBack)` – returns [number] **testID**, gets [string] **title** and tests like ["Test title", testFunction], where **testFunction** should return true for success and false or string for failure. If test is async, **testFunction** should get the first parameter and use it in **o.testUpdate()**.
|
|
135
|
+
|
|
136
|
+
`o.testUpdate(info, result, [description])` – returns undefined, gets **info** object (the first parameter of any **testFunction**) to update test status and set it to **result** (true or false/string), **description** - additional text if needed. Used for test status update for async tests. More info [here](https://fous.name/objs).
|
|
137
|
+
|
|
138
|
+
`o.tLog[testID]` – test sessions and text results.
|
|
139
|
+
|
|
140
|
+
`o.tRes[testID]` – test sets results as true/false.
|
|
141
|
+
|
|
142
|
+
`o.tStatus[testID: [functionID: true/false],...]` – an array of set test functions statuses.
|
|
143
|
+
|
|
144
|
+
`o.tShowOk` – false, success tests are hidden, only errors. Set to **true** to see success results before **o.test()**.
|
|
145
|
+
|
|
146
|
+
`o.tStyled` – false, logs are in console view. Set to **true** to make logs HTML styled before **o.test()**.
|
|
147
|
+
|
|
148
|
+
`o.tTime` – 2000, milliseconds timeout for async tests.
|
|
149
|
+
|
|
150
|
+
### Methods
|
|
151
|
+
Here are methods, **o()** means that they are available after getting elements from DOM or after init and render functions (after creating elements).
|
|
152
|
+
|
|
153
|
+
#### Select / DOM
|
|
154
|
+
`o().reset(q)` – clears **Objs** and get new elements by **q**, works as **o()**.
|
|
155
|
+
|
|
156
|
+
`o().select([i])` – selects number **i** element from 0 to change only it, if **i** is undefined selects the last index element.
|
|
157
|
+
|
|
158
|
+
`o().all()` – selects all elements to operate again.
|
|
159
|
+
|
|
160
|
+
`o().remove([i])` – removes all or **i** element from DOM.
|
|
161
|
+
|
|
162
|
+
`o().skip(i)` – removes **i** element from control set of this **Objs**.
|
|
163
|
+
|
|
164
|
+
`o().add()` – adds element to control set.
|
|
165
|
+
|
|
166
|
+
`o().find(q)` – finds all children elements by q-query in each element.
|
|
167
|
+
|
|
168
|
+
`o().first(q)` – finds only the first child element by q-query in each element.
|
|
169
|
+
|
|
170
|
+
`o().length` – number of elements of control set.
|
|
171
|
+
|
|
172
|
+
`o().el` – the first DOM element in the set.
|
|
173
|
+
|
|
174
|
+
`o().els` – all DOM elements of the set.
|
|
175
|
+
|
|
176
|
+
`o().last` – the last DOM element in the set.
|
|
177
|
+
|
|
178
|
+
#### States
|
|
179
|
+
`o().init()` – equal to **o.init()** but with elements to control.
|
|
180
|
+
|
|
181
|
+
`o().initState()` – equal to **o.initState()** but with elements to control.
|
|
182
|
+
|
|
183
|
+
`o().sample()` – returns states object with render state for creation such elements.
|
|
184
|
+
|
|
185
|
+
`o().html([html])` – returns html string of all elements or sets innerHTML as **html**.
|
|
186
|
+
|
|
187
|
+
`o().initID` – undefined or number. After **o().init(), o().initState()** **Objs** sets this parameter as index in **o.inits[]** to get ready elements. If elements were removed from DOM, they still there for re-use.
|
|
188
|
+
|
|
189
|
+
#### Direct DOM edit
|
|
190
|
+
`o().attr(attribute, [value])` – sets **attribute** to **value** or removes attribute if **value** is equal to '' or returns **attribute** value if **value** is undefined. If **.select()** was not used before - returns an array of values.
|
|
191
|
+
|
|
192
|
+
`o().attrs()` – returns an array of all elements attributes, if **.select()** was used before - returns an object with values of one element.
|
|
193
|
+
|
|
194
|
+
`o().dataset([object])` – Sets dataset values due to the **object** data. It will not delete other dataset values. If **.select()** was used before - returns an object with dataset of one element or changes just one element.
|
|
195
|
+
|
|
196
|
+
`o().style(value)` – sets style attribute to [string] **value**.
|
|
197
|
+
|
|
198
|
+
`o().css(object)` – sets style attribute to [string] created from **object** elements and values, e.g. {width: '100px', 'font-family': 'Arial'}.
|
|
199
|
+
|
|
200
|
+
`o().setClass(value)` – sets class attribute to **value**.
|
|
201
|
+
|
|
202
|
+
`o().addClass(class)` – adds **class**.
|
|
203
|
+
|
|
204
|
+
`o().removeClass(class)` – removes **class**.
|
|
205
|
+
|
|
206
|
+
`o().toggleClass(class, rule)` – switch having and not having **class** by **rule**. If **rule** set **class**.
|
|
207
|
+
|
|
208
|
+
`o().haveClass(class)` – returns true if all elements have **class**.
|
|
209
|
+
|
|
210
|
+
`o().innerHTML([html])` – if **html** is set, sets innerHTML af all elements. If not set, returns array with innerHTML of each element.
|
|
211
|
+
|
|
212
|
+
`o().innerText(text)` – sets innerText for all elements.
|
|
213
|
+
|
|
214
|
+
`o().textContent(content)` – sets textContent for all elements.
|
|
215
|
+
|
|
216
|
+
#### System
|
|
217
|
+
`o().forEach(function)` – runs **function** with ab object as the first parameter: {o, self, i} where is o-function, self Objs object and i-index of current element.
|
|
218
|
+
|
|
219
|
+
#### Events
|
|
220
|
+
`o().on(events, function, [options])` – adds **events** listeners separated by ', ' to elements.
|
|
221
|
+
|
|
222
|
+
`o().off(events, function, [options])` – removes **events** listeners separated by ', ' to elements.
|
|
223
|
+
|
|
224
|
+
`o().offAll([event])` – removes all listeners or for special **event** from elements.
|
|
225
|
+
|
|
226
|
+
`o().onAll([event])` – adds all inited listeners from cache for all or for special **event**.
|
|
227
|
+
|
|
228
|
+
`o().ie` – object with all ever added listeners like {click: [[function, options], ...], ...}.
|
|
229
|
+
|
|
230
|
+
#### DOM insert
|
|
231
|
+
`o().appendInside(q)` – append elements inside element **q** or got by **q** query.
|
|
232
|
+
|
|
233
|
+
`o().appendBefore(q)` – append elements before element **q** or got by **q** query.
|
|
234
|
+
|
|
235
|
+
`o().appendAfter(q)` – append elements after element **q** or got by **q** query.
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
68
240
|
## License
|
|
69
241
|
Apache 2.0: Save author name in the file: `// Roman Torshin`
|
package/objs.1.0.js
CHANGED
|
@@ -712,7 +712,7 @@ o.get = (url, props = {}) => {
|
|
|
712
712
|
o.post = (url, props = {}) => {
|
|
713
713
|
return o.ajax(url, {...props, method: 'POST'});
|
|
714
714
|
};
|
|
715
|
-
o.getParams = () => {
|
|
715
|
+
o.getParams = (key) => {
|
|
716
716
|
const params = {};
|
|
717
717
|
const paramsRaw = new URLSearchParams(window.location.search).entries();
|
|
718
718
|
|
|
@@ -720,7 +720,7 @@ o.getParams = () => {
|
|
|
720
720
|
params[entry[o.Z]] = entry[o.N];
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
-
return params;
|
|
723
|
+
return key ? params[key] : params;
|
|
724
724
|
};
|
|
725
725
|
|
|
726
726
|
|
package/objs.1.0.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @author Roman Torshin, Apache 2.0 licence
|
|
2
|
-
const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=2,l=3,a="object",r="function",c,d=document,f=-1,g=0,h=0,p=[],u=0,y=0,m=e=>typeof e,S=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},L=o.onError||(()=>{}),C=e=>(...a)=>{try{return e(a[n],a[i],a[s],a[l])||t}catch(r){L(r)}},$=e=>{for(u=g;u<=f;u++)e()},E=e=>(m(e)!==a&&(e=o.first(e).el),e),Z=(e=!0,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[f]:c,e&&(S(p,(e,n)=>{delete t[n[e]]}),p=[],t.ie={})},F=(e="")=>Array.from(d.querySelectorAll(e));t.reset=o;let v=(e,t,n)=>{S(t,i=>{let s=t[i];m(s)===r&&(s=s(n)),s!==c&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=s:"dataset"===i&&m(s)===a?S(s,t=>{e.dataset[t]=s[t]}):"toggleClass"===i?e.classList.toggle(s):"addClass"===i?m(s)===a?e.classList.add(...s):e.classList.add(s):"removeClass"===i?e.classList.remove(s):"style"===i&&m(s)===a?S(s,t=>{e.style[t]=s[t]}):"append"===i&&m(s)===a?S(s.length?s:[s],t=>{e.appendChild(s[t])}):e.setAttribute(i,s)))}),e.dataset.oState=t.state};return t.init=C(e=>{let s=t.initID||o.inits.length||n;t.initID=s,Z(),o.inits[t.initID]=t,(m(e)!==a||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=C((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+i);m(p)===a&&(p.state=l,p["data-o-init"]=s);let L=(e,t={})=>m(p)===a?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===r?p(t):p,u.children.length>i||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let C=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,C&&S.push(L(s,e)),e)),C&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let i=m(p)===r?p(h[y?t:n]):p;m(i)===a&&v(e,i,h[y?t:n])}))})})}),t.initState=C((e,n)=>{t.init(e).render(n)}),t.sample=C((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let a of i)"data-"!==a.nodeName.substring(n,5)&&(l[a.nodeName]=a.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=C(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=C(()=>{f=t.length-i,g=n,t.el=t.els[n],h=n}),t.remove=C(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):$(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=C(e=>{e===c&&(e=g),t.els.splice(u,i),Z()}),t.add=C((e,i)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===a?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===m(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==c&&t.dataset({oInit:t.initID})}),t.appendInside=C(e=>{$(()=>{E(e).appendChild(t.els[u])})}),t.appendBefore=C(e=>{$(()=>{E(e).parentNode.insertBefore(t.els[u],E(e))})}),t.appendAfter=C(e=>{$(()=>{E(e).after(...t.els)})}),t.find=C((e="")=>{let n=[];$(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=C((e="")=>{let n=c,i=[];$(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=C((e,i)=>{if(e){if(i===c){let s=[];return $(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?$(()=>{t.els[u].setAttribute(e,i)}):$(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=C(()=>{let e=[];return $(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=C(e=>{if(typeof e===a)$(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let i=[];return $(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),t.style=C(e=>{t.attr("style",e)}),t.css=C((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=C(e=>{$(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=C(e=>{$(()=>{t.els[u].classList.add(e)})}),t.removeClass=C(e=>{$(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=C((e,n)=>{$(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return $(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=C(e=>{if(e!==c)$(()=>{t.els[u].innerHTML=e});else{let n="";return $(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=C((e="")=>{$(()=>{t.els[u].innerText=e})}),t.textContent=C((e="")=>{$(()=>{t.els[u].textContent=e})}),t.html=C(e=>{if(e)t.innerHTML(e);else{let n="";return $(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=C(e=>{t.initState(e)}),t.on=C((e,n,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=C((e,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),t.onAll=C((e,l)=>{S(t.ie,(a,r)=>{e&&e!==a||r[a].forEach(e=>{$(()=>{l?t.els[u].removeEventListener(a,e[n]):t.els[u].addEventListener(a,e[n],e[i],e[s])})})})}),t.offAll=C(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.onError=!1,o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=()=>{let e={},t=new URLSearchParams(window.location.search).entries();for(let n of t)e[n[o.Z]]=n[o.N];return e},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let i=o.Z,s=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let a=o.incSet[o.Z];o.incSet[a]=t||o.Z,o.incReady[a]=[];let r=o.incReady[a];r[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){i++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){r[i]={name:d,loaded:o.N},s++;continue}if(r[i]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let g=localStorage,h=g.getItem("inc-"+d),p=g.getItem("inc-"+d+"Expires");h&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+a+"-"+i,innerHTML:h,"data-o-inc":a}).appendInside("head"),r[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{g.setItem("inc-"+d,e),g.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+a+"-"+c[d],innerHTML:e,"data-o-inc":a}).appendInside("head"),o.incCheck(a,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+a+"-"+i,"data-o-inc":a,async:o.incAsync,onload:"o.incCheck("+a+","+i+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return r[o.Z]+=s,i!==o.Z&&(s===i?typeof t===l&&t(a):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(a))},o.incTimeout,a)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,i=0,s="├ OK: ",l="├ ✘ ",a="\n",r="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",s=o.tPre+o.tOk,l=o.tPre+o.tXx,r=(a=o.tDc)+a):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let g={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},h=t[f][o.N];if("function"==typeof h)try{h=h(g)}catch(p){h=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof h?o.F:h,!0===h?(d++,o.tShowOk&&(o.tLog[n]+=s+t[f][o.Z]+a)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+r:(i++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,g))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let a=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+a+"</b>"+o.tDc:o.tLog[e.n]+="└ "+a,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
|
|
2
|
+
const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=2,l=3,a="object",r="function",c,d=document,f=-1,g=0,h=0,p=[],u=0,y=0,m=e=>typeof e,S=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},L=o.onError||(()=>{}),C=e=>(...a)=>{try{return e(a[n],a[i],a[s],a[l])||t}catch(r){L(r)}},$=e=>{for(u=g;u<=f;u++)e()},E=e=>(m(e)!==a&&(e=o.first(e).el),e),Z=(e=!0,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[f]:c,e&&(S(p,(e,n)=>{delete t[n[e]]}),p=[],t.ie={})},F=(e="")=>Array.from(d.querySelectorAll(e));t.reset=o;let v=(e,t,n)=>{S(t,i=>{let s=t[i];m(s)===r&&(s=s(n)),s!==c&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=s:"dataset"===i&&m(s)===a?S(s,t=>{e.dataset[t]=s[t]}):"toggleClass"===i?e.classList.toggle(s):"addClass"===i?m(s)===a?e.classList.add(...s):e.classList.add(s):"removeClass"===i?e.classList.remove(s):"style"===i&&m(s)===a?S(s,t=>{e.style[t]=s[t]}):"append"===i&&m(s)===a?S(s.length?s:[s],t=>{e.appendChild(s[t])}):e.setAttribute(i,s)))}),e.dataset.oState=t.state};return t.init=C(e=>{let s=t.initID||o.inits.length||n;t.initID=s,Z(),o.inits[t.initID]=t,(m(e)!==a||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=C((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+i);m(p)===a&&(p.state=l,p["data-o-init"]=s);let L=(e,t={})=>m(p)===a?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===r?p(t):p,u.children.length>i||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let C=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,C&&S.push(L(s,e)),e)),C&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let i=m(p)===r?p(h[y?t:n]):p;m(i)===a&&v(e,i,h[y?t:n])}))})})}),t.initState=C((e,n)=>{t.init(e).render(n)}),t.sample=C((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let a of i)"data-"!==a.nodeName.substring(n,5)&&(l[a.nodeName]=a.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=C(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=C(()=>{f=t.length-i,g=n,t.el=t.els[n],h=n}),t.remove=C(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):$(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=C(e=>{e===c&&(e=g),t.els.splice(u,i),Z()}),t.add=C((e,i)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===a?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===m(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==c&&t.dataset({oInit:t.initID})}),t.appendInside=C(e=>{$(()=>{E(e).appendChild(t.els[u])})}),t.appendBefore=C(e=>{$(()=>{E(e).parentNode.insertBefore(t.els[u],E(e))})}),t.appendAfter=C(e=>{$(()=>{E(e).after(...t.els)})}),t.find=C((e="")=>{let n=[];$(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=C((e="")=>{let n=c,i=[];$(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=C((e,i)=>{if(e){if(i===c){let s=[];return $(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?$(()=>{t.els[u].setAttribute(e,i)}):$(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=C(()=>{let e=[];return $(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=C(e=>{if(typeof e===a)$(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let i=[];return $(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),t.style=C(e=>{t.attr("style",e)}),t.css=C((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=C(e=>{$(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=C(e=>{$(()=>{t.els[u].classList.add(e)})}),t.removeClass=C(e=>{$(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=C((e,n)=>{$(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return $(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=C(e=>{if(e!==c)$(()=>{t.els[u].innerHTML=e});else{let n="";return $(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=C((e="")=>{$(()=>{t.els[u].innerText=e})}),t.textContent=C((e="")=>{$(()=>{t.els[u].textContent=e})}),t.html=C(e=>{if(e)t.innerHTML(e);else{let n="";return $(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=C(e=>{t.initState(e)}),t.on=C((e,n,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=C((e,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),t.onAll=C((e,l)=>{S(t.ie,(a,r)=>{e&&e!==a||r[a].forEach(e=>{$(()=>{l?t.els[u].removeEventListener(a,e[n]):t.els[u].addEventListener(a,e[n],e[i],e[s])})})})}),t.offAll=C(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.onError=!1,o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=e=>{let t={},n=new URLSearchParams(window.location.search).entries();for(let i of n)t[i[o.Z]]=i[o.N];return e?t[e]:t},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let i=o.Z,s=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let a=o.incSet[o.Z];o.incSet[a]=t||o.Z,o.incReady[a]=[];let r=o.incReady[a];r[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){i++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){r[i]={name:d,loaded:o.N},s++;continue}if(r[i]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let g=localStorage,h=g.getItem("inc-"+d),p=g.getItem("inc-"+d+"Expires");h&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+a+"-"+i,innerHTML:h,"data-o-inc":a}).appendInside("head"),r[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{g.setItem("inc-"+d,e),g.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+a+"-"+c[d],innerHTML:e,"data-o-inc":a}).appendInside("head"),o.incCheck(a,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+a+"-"+i,"data-o-inc":a,async:o.incAsync,onload:"o.incCheck("+a+","+i+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return r[o.Z]+=s,i!==o.Z&&(s===i?typeof t===l&&t(a):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(a))},o.incTimeout,a)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,i=0,s="├ OK: ",l="├ ✘ ",a="\n",r="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",s=o.tPre+o.tOk,l=o.tPre+o.tXx,r=(a=o.tDc)+a):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let g={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},h=t[f][o.N];if("function"==typeof h)try{h=h(g)}catch(p){h=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof h?o.F:h,!0===h?(d++,o.tShowOk&&(o.tLog[n]+=s+t[f][o.Z]+a)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+r:(i++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,g))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let a=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+a+"</b>"+o.tDc:o.tLog[e.n]+="└ "+a,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
|
package/objs.npm.1.0.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
(function(globals) {
|
|
4
4
|
'use strict';
|
|
5
|
-
function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function t(){};return{s:i,n:function e(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function t(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,s=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return c=e.done,e},e:function t(e){s=!0,a=e},f:function t(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(t,e)}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=function t(e){var n={els:[],ie:{}},r="object",i="function",a=void 0,c=document,s=-1,l=0,u=0,f=[],d=0,y=0,p=function t(e){return _typeof(e)},v=function t(e,n){for(var r in e)Object.hasOwnProperty.call(e,r)&&n(r,e)},g=t.onError||function(){},$=function t(e){return function(){try{return e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])||n}catch(t){g(t)}}},h=function t(e){for(d=l;d<=s;d++)e()},m=function e(n){return p(n)!==r&&(n=t.first(n).el),n},b=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.els,i=r.length;n.length=i,s=i-1,l=0,n.el=i?r[0]:a,n.last=i?r[s]:a,e&&(v(f,function(t,e){delete n[e[t]]}),f=[],n.ie={})},S=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(c.querySelectorAll(e))};n.reset=t;var _=function t(e,n,c){v(n,function(t){var s,l=n[t];p(l)===i&&(l=l(c)),l!==a&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=l:"dataset"===t&&p(l)===r?v(l,function(t){e.dataset[t]=l[t]}):"toggleClass"===t?e.classList.toggle(l):"addClass"===t?p(l)===r?(s=e.classList).add.apply(s,_toConsumableArray(l)):e.classList.add(l):"removeClass"===t?e.classList.remove(l):"style"===t&&p(l)===r?v(l,function(t){e.style[t]=l[t]}):"append"===t&&p(l)===r?v(l.length?l:[l],function(t){e.appendChild(l[t])}):e.setAttribute(t,l)))}),e.dataset.oState=n.state};return n.init=$(function(e){var u=n.initID||t.inits.length||0;n.initID=u,b(),t.inits[n.initID]=n,(p(e)!==r||e.render===a)&&(e={render:e}),v(e,function(v){f.push(v),n[v]=$(function(){var f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],g=e[v]||{tag:"div"},$=n.els.slice(l,s+1);p(g)===r&&(g.state=v,g["data-o-init"]=u);var h=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(g)===r?c.createElement(g.tag||"div"):((d=c.createElement("div")).innerHTML=p(g)===i?g(n):g,d.children.length>1||!d.firstElementChild)?(d.dataset.oInit=e,d):(d.firstElementChild.dataset.oInit=e,d.firstElementChild)};f.length||(f=[f]);var m=!$[0]&&"render"===v;f=f.map(function(e,r){return e.self=n,e.o=t,e.i=e.i===a?r:e.i,m&&$.push(h(u,e)),e}),m&&(n.els=$,b(!1)),$&&(y=$.length===f.length,$.map(function(t,e){f[y?e:0].i=e+l;var n=p(g)===i?g(f[y?e:0]):g;p(n)===r&&_(t,n,f[y?e:0])}))})})}),n.initState=$(function(t,e){n.init(t).render(e)}),n.sample=$(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",r=n.els[l].attributes,i=n.els[l].dataset,a={tag:n.els[l].tagName,html:n.els[l].innerHTML,dataset:{}},c=_createForOfIteratorHelper(r);try{for(c.s();!(t=c.n()).done;){var s=t.value;"data-"!==s.nodeName.substring(0,5)&&(a[s.nodeName]=s.value)}}catch(u){c.e(u)}finally{c.f()}return v(i,function(t){a.dataset[t]=i[t]}),_defineProperty({},e,a)}),n.select=$(function(t){t===a&&(t=n.length-1),s=t,l=t,n.el=n.els[t],u=1}),n.all=$(function(){s=n.length-1,l=0,n.el=n.els[0],u=0}),n.remove=$(function(t){t===a&&u&&(t=l),t!==a?n.els[t].parentNode.removeChild(n.els[t]):h(function(){n.els[d].parentNode.removeChild(n.els[d])}),b(!1)}),n.skip=$(function(t){t===a&&(t=l),n.els.splice(d,1),b()}),n.add=$(function(e,i){var c,s,l;"string"===p(e)&&""!==e?(c=n.els).push.apply(c,_toConsumableArray(S(e))):p(e)===r?e.tagName?n.els.push(e):e.els?(s=n.els).push.apply(s,_toConsumableArray(e.els)):e.length&&e[0].tagName&&(l=n.els).push.apply(l,_toConsumableArray(e)):"number"===p(e)&&t.inits[e]&&(n=t.inits[e]),b(!1),n.initID!==a&&n.dataset({oInit:n.initID})}),n.appendInside=$(function(t){h(function(){m(t).appendChild(n.els[d])})}),n.appendBefore=$(function(t){h(function(){m(t).parentNode.insertBefore(n.els[d],m(t))})}),n.appendAfter=$(function(t){h(function(){var e;(e=m(t)).after.apply(e,_toConsumableArray(n.els))})}),n.find=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];h(function(){e.push.apply(e,_toConsumableArray(Array.from(n.els[d].querySelectorAll(":scope "+t))))}),n.els=e,b()}),n.first=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=a,r=[];h(function(){(e=n.els[d].querySelector(t))&&r.push(e)}),n.els=r,b()}),n.attr=$(function(t,e){if(t){if(e===a){var r=[];return h(function(){r[d]=n.els[d].getAttribute(t)}),u?r[0]:r}""!==e?h(function(){n.els[d].setAttribute(t,e)}):h(function(){n.els[d].removeAttribute(t)})}}),n.attrs=$(function(){var t=[];return h(function(){var e={};_toConsumableArray(n.els[d].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),u?t[0]:t}),n.dataset=$(function(t){if(_typeof(t)===r)h(function(){v(t,function(e){n.els[d].dataset[e]=t[e]})});else{var e=[];return h(function(){e.push(_objectSpread({},n.els[d].dataset))}),u?e[0]:e}}),n.style=$(function(t){n.attr("style",t)}),n.css=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";v(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),n.style(e)}),n.setClass=$(function(t){h(function(){n.els[d].setAttribute("class",t)})}),n.addClass=$(function(t){h(function(){n.els[d].classList.add(t)})}),n.removeClass=$(function(t){h(function(){n.els[d].classList.remove(t)})}),n.toggleClass=$(function(t,e){h(function(){n.els[d].classList.toggle(t,e)})}),n.haveClass=function(t){var e=!0;return h(function(){n.els[d].classList.contains(t)||(e=!1)}),e},n.innerHTML=$(function(t){if(t!==a)h(function(){n.els[d].innerHTML=t});else{var e="";return h(function(){e+=n.els[d].innerHTML}),e}}),n.innerText=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].innerText=t})}),n.textContent=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].textContent=t})}),n.html=$(function(t){if(t)n.innerHTML(t);else{var e="";return h(function(){e+=n.els[d].outerHTML}),e}}),n.forEach=$(function(t){n.initState(t)}),n.on=$(function(t,e,r,i){t.split(", ").forEach(function(t){h(function(){n.els[d].addEventListener(t,e,r,i)}),n.ie[t]||(n.ie[t]=[]),n.ie[t].push([e,r,i])})}),n.off=$(function(t,e,r){t.split(", ").forEach(function(t){h(function(){n.els[d].removeEventListener(t,e,r)}),n.ie[t]&&(n.ie[t]=n.ie[t].filter(function(t){return t[0]!==e}))})}),n.onAll=$(function(t,e){v(n.ie,function(r,i){t&&t!==r||i[r].forEach(function(t){h(function(){e?n.els[d].removeEventListener(r,t[0]):n.els[d].addEventListener(r,t[0],t[1],t[2])})})})}),n.offAll=$(function(t){n.onAll(t,1)}),e&&n.add(e),n.take=function(e){if(n.add(e),n.el){var r=n.el.dataset.oInit;if(r!==a&&t.inits[r])return 1===n.length?(y=n.els[0],Object.assign(n,t.inits[r]),n.els=[y]):n=t.inits[r],b(!1,n.els),n}},n};o.first=function(t){return o(document.querySelector(t)||"")},o.inits=[],o.onError=!1,o.init=function(t){return o().init(t)},o.initState=function(t,e){return o().init(t).render(e)},o.take=function(t){return o().take(t)},o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=function(t,e){return Object.hasOwnProperty.call(t,e)},o.ajax=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;if(e.data&&"object"===_typeof(e.data)){for(var r in e.data)o.C(e.data,r)&&("object"===_typeof(e.data[r])?n.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):n.set(r,e.data[r]));"GET"===e.method||"get"===e.method?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return fetch(t,e)},o.get=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"GET"}))},o.post=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"POST"}))},o.getParams=function(){var t,e={},n=new URLSearchParams(window.location.search).entries(),r=_createForOfIteratorHelper(n);try{for(r.s();!(t=r.n()).done;){var i=t.value;e[i[o.Z]]=i[o.N]}}catch(a){r.e(a)}finally{r.f()}return e},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return!n&&t&&e===o.U&&o.incReady[t]?o.incSet[t]===o.N:o.incReady[t]===o.U||o.incReady[t][e]===o.U?o.F:(o.incReady[t][e].loaded=n,o.incFns[o.incReady[t][e].name]=n,o.incReady[t][o.Z]+=n,t&&o.incReady[t].length===o.incReady[t][o.Z]&&("function"==typeof o.incSet[t]&&o.incSet[t](t),o.incSet[t]=o.N),o.incSet[t]===o.N)},o.incCacheClear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.F;for(var e in o.incFns)o.C(o.incFns,e)&&(localStorage.removeItem("inc-"+e),localStorage.removeItem("inc-"+e+"Expires"));return t&&(o.incReady.forEach(function(t,e){e&&t.forEach(function(t,n){n&&o("#oInc-"+e+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=function(t,e,n){var r=o.Z,i=o.Z,a="function";if("object"!==_typeof(t)||!t)return o.incSet[o.Z];o.incSet[o.Z]++;var c=o.incSet[o.Z];o.incSet[c]=e||o.Z,o.incReady[c]=[];var s=o.incReady[c];s[o.Z]=o.N;var l={},u=function e(n){if(o.C(t,n)){r++,o.incN++;var a=t[n].indexOf(".css")>-1?"style":"script";if(t[n]=(o.incSource?o.incSource+"/":"")+t[n],isNaN(n)&&o.C(o.incFns,n)&&o.incFns[n]&&!o.incForce)return s[r]={name:n,loaded:o.N},i++,"continue";if(s[r]={name:n,loaded:o.Z},isNaN(n)&&(o.incFns[n]=o.Z),isNaN(n)&&o.incCache&&"http"!==t[n].substring(o.Z,4)&&"file:"!==window.location.protocol&&(t[n].indexOf(".css")>-1||t[n].indexOf(".js")>-1)){var u=localStorage,f=u.getItem("inc-"+n),d=u.getItem("inc-"+n+"Expires");f&&d&&new Date().getTime()<d?(o.initState({tag:a,id:"oInc-"+c+"-"+r,innerHTML:f,"data-o-inc":c}).appendInside("head"),s[r].loaded=o.N,o.incFns[n]=o.N,i++):(l[n]=r,o.get(t[n],{mode:o.incCors?"cors":"same-origin"}).then(function(e){if(200!==e.status){o.onError&&o.onError({message:o.incSource+t[n]+" was not loaded"});return}e.text().then(function(t){u.setItem("inc-"+n,t),u.setItem("inc-"+n+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+c+"-"+l[n],innerHTML:t,"data-o-inc":c}).appendInside("head"),o.incCheck(c,l[n],o.N)})}))}else{var y={tag:a,id:"oInc-"+c+"-"+r,"data-o-inc":c,async:o.incAsync,onload:"o.incCheck("+c+","+r+",1)"};t[n].indexOf(".css")>-1?(y.tag="link",y.rel="stylesheet",y.href=t[n]):(t[n].indexOf(".js")>-1||(y.tag="img",y.style="display:none;"),y.src=t[n]),o.initState(y).appendInside(y.style?"body":"head")}}};for(var f in t)if("continue"===u(f))continue;return s[o.Z]+=i,r!==o.Z&&(i===r?_typeof(e)===a&&e(c):setTimeout(function(t){o.incReady[t]&&o.incReady[t].length<o.incReady[t][o.Z]&&(o.incSet[t]=o.Z,_typeof(n)===a&&n(c))},o.incTimeout,c)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=o.tLog.length,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=0,c="├ OK: ",s="├ ✘ ",l="\n",u="\n",f=r.length,d=o.Z;"function"==typeof r[f-o.N]&&(o.tFns[e]=r[f-o.N],f--),o.tStyled?(o.tLog[e]="<div><b>"+t+" #"+e+"</b></div>",c=o.tPre+o.tOk,s=o.tPre+o.tXx,u=(l=o.tDc)+l):o.tLog[e]=t+" #"+e+"\n",o.tRes[e]=o.F,o.tStatus[e]=[];for(var y=o.Z;y<f;y++){var p={n:e,i:y,title:r[y][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},v=r[y][o.N];if("function"==typeof v)try{v=v(p)}catch(g){v=g.message,o.onError&&o.onError(g)}o.tStatus[e][y]="string"==typeof v?o.F:v,!0===v?(d++,o.tShowOk&&(o.tLog[e]+=c+r[y][o.Z]+l)):v!==o.U?o.tLog[e]+=s+r[y][o.Z]+(v!==o.F?": <i>"+v+"</i>":"")+u:(a++,setTimeout(function(t){t.title+=" (timeout)",o.testUpdate(t)},o.tTime,p))}return o.tRes[e]=d===f,o.tStyled?o.tLog[e]+=o.tPre+'<div style="color:'+(d+a!==f?"red":"green")+';"><b>':o.tLog[e]+=a?"├":"└ ",o.tLog[e]+="DONE "+d+"/"+(f-a),a&&(o.tLog[e]+=", waiting: "+a),o.tStyled?o.tLog[e]+="</b>"+o.tDc+o.tDc:o.tLog[e]+="\n",a||"function"!=typeof o.tFns[e]||o.tFns[e](e),e},o.testUpdate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.F,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(o.tStatus[t.n][t.i]===o.U){o.tStatus[t.n][t.i]=!0===e,!0===e?t.tShowOk&&(t.tStyled?o.tLog[t.n]+=o.tPre+o.tOk+t.title+n+o.tDc:o.tLog[t.n]+="└ OK: "+t.title+n+"\n"):(o.tRes[t.n]=o.F,t.tStyled?o.tLog[t.n]+=o.tPre+o.tXx+t.title+n+(e?": "+e:"")+o.tDc+o.tDc:o.tLog[t.n]+="└ ✘ "+t.title+(e?": "+e:"")+n+"\n");var r,i=o.Z,a=i,c=_createForOfIteratorHelper(o.tStatus[t.n]);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(s===o.U)return;!s&&i++,a++}}catch(l){c.e(l)}finally{c.f()}o.tRes[t.n]=!i;var u=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;t.tStyled?o.tLog[t.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+u+"</b>"+o.tDc:o.tLog[t.n]+="└ "+u,"function"==typeof o.tFns[t.n]&&o.tFns[t.n](t.n)}};
|
|
5
|
+
function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function t(){};return{s:i,n:function e(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function t(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,s=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return c=e.done,e},e:function t(e){s=!0,a=e},f:function t(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(t,e)}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=function t(e){var n={els:[],ie:{}},r="object",i="function",a=void 0,c=document,s=-1,l=0,u=0,f=[],d=0,y=0,p=function t(e){return _typeof(e)},v=function t(e,n){for(var r in e)Object.hasOwnProperty.call(e,r)&&n(r,e)},g=t.onError||function(){},$=function t(e){return function(){try{return e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])||n}catch(t){g(t)}}},h=function t(e){for(d=l;d<=s;d++)e()},m=function e(n){return p(n)!==r&&(n=t.first(n).el),n},b=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.els,i=r.length;n.length=i,s=i-1,l=0,n.el=i?r[0]:a,n.last=i?r[s]:a,e&&(v(f,function(t,e){delete n[e[t]]}),f=[],n.ie={})},S=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(c.querySelectorAll(e))};n.reset=t;var _=function t(e,n,c){v(n,function(t){var s,l=n[t];p(l)===i&&(l=l(c)),l!==a&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=l:"dataset"===t&&p(l)===r?v(l,function(t){e.dataset[t]=l[t]}):"toggleClass"===t?e.classList.toggle(l):"addClass"===t?p(l)===r?(s=e.classList).add.apply(s,_toConsumableArray(l)):e.classList.add(l):"removeClass"===t?e.classList.remove(l):"style"===t&&p(l)===r?v(l,function(t){e.style[t]=l[t]}):"append"===t&&p(l)===r?v(l.length?l:[l],function(t){e.appendChild(l[t])}):e.setAttribute(t,l)))}),e.dataset.oState=n.state};return n.init=$(function(e){var u=n.initID||t.inits.length||0;n.initID=u,b(),t.inits[n.initID]=n,(p(e)!==r||e.render===a)&&(e={render:e}),v(e,function(v){f.push(v),n[v]=$(function(){var f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],g=e[v]||{tag:"div"},$=n.els.slice(l,s+1);p(g)===r&&(g.state=v,g["data-o-init"]=u);var h=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(g)===r?c.createElement(g.tag||"div"):((d=c.createElement("div")).innerHTML=p(g)===i?g(n):g,d.children.length>1||!d.firstElementChild)?(d.dataset.oInit=e,d):(d.firstElementChild.dataset.oInit=e,d.firstElementChild)};f.length||(f=[f]);var m=!$[0]&&"render"===v;f=f.map(function(e,r){return e.self=n,e.o=t,e.i=e.i===a?r:e.i,m&&$.push(h(u,e)),e}),m&&(n.els=$,b(!1)),$&&(y=$.length===f.length,$.map(function(t,e){f[y?e:0].i=e+l;var n=p(g)===i?g(f[y?e:0]):g;p(n)===r&&_(t,n,f[y?e:0])}))})})}),n.initState=$(function(t,e){n.init(t).render(e)}),n.sample=$(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",r=n.els[l].attributes,i=n.els[l].dataset,a={tag:n.els[l].tagName,html:n.els[l].innerHTML,dataset:{}},c=_createForOfIteratorHelper(r);try{for(c.s();!(t=c.n()).done;){var s=t.value;"data-"!==s.nodeName.substring(0,5)&&(a[s.nodeName]=s.value)}}catch(u){c.e(u)}finally{c.f()}return v(i,function(t){a.dataset[t]=i[t]}),_defineProperty({},e,a)}),n.select=$(function(t){t===a&&(t=n.length-1),s=t,l=t,n.el=n.els[t],u=1}),n.all=$(function(){s=n.length-1,l=0,n.el=n.els[0],u=0}),n.remove=$(function(t){t===a&&u&&(t=l),t!==a?n.els[t].parentNode.removeChild(n.els[t]):h(function(){n.els[d].parentNode.removeChild(n.els[d])}),b(!1)}),n.skip=$(function(t){t===a&&(t=l),n.els.splice(d,1),b()}),n.add=$(function(e,i){var c,s,l;"string"===p(e)&&""!==e?(c=n.els).push.apply(c,_toConsumableArray(S(e))):p(e)===r?e.tagName?n.els.push(e):e.els?(s=n.els).push.apply(s,_toConsumableArray(e.els)):e.length&&e[0].tagName&&(l=n.els).push.apply(l,_toConsumableArray(e)):"number"===p(e)&&t.inits[e]&&(n=t.inits[e]),b(!1),n.initID!==a&&n.dataset({oInit:n.initID})}),n.appendInside=$(function(t){h(function(){m(t).appendChild(n.els[d])})}),n.appendBefore=$(function(t){h(function(){m(t).parentNode.insertBefore(n.els[d],m(t))})}),n.appendAfter=$(function(t){h(function(){var e;(e=m(t)).after.apply(e,_toConsumableArray(n.els))})}),n.find=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];h(function(){e.push.apply(e,_toConsumableArray(Array.from(n.els[d].querySelectorAll(":scope "+t))))}),n.els=e,b()}),n.first=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=a,r=[];h(function(){(e=n.els[d].querySelector(t))&&r.push(e)}),n.els=r,b()}),n.attr=$(function(t,e){if(t){if(e===a){var r=[];return h(function(){r[d]=n.els[d].getAttribute(t)}),u?r[0]:r}""!==e?h(function(){n.els[d].setAttribute(t,e)}):h(function(){n.els[d].removeAttribute(t)})}}),n.attrs=$(function(){var t=[];return h(function(){var e={};_toConsumableArray(n.els[d].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),u?t[0]:t}),n.dataset=$(function(t){if(_typeof(t)===r)h(function(){v(t,function(e){n.els[d].dataset[e]=t[e]})});else{var e=[];return h(function(){e.push(_objectSpread({},n.els[d].dataset))}),u?e[0]:e}}),n.style=$(function(t){n.attr("style",t)}),n.css=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";v(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),n.style(e)}),n.setClass=$(function(t){h(function(){n.els[d].setAttribute("class",t)})}),n.addClass=$(function(t){h(function(){n.els[d].classList.add(t)})}),n.removeClass=$(function(t){h(function(){n.els[d].classList.remove(t)})}),n.toggleClass=$(function(t,e){h(function(){n.els[d].classList.toggle(t,e)})}),n.haveClass=function(t){var e=!0;return h(function(){n.els[d].classList.contains(t)||(e=!1)}),e},n.innerHTML=$(function(t){if(t!==a)h(function(){n.els[d].innerHTML=t});else{var e="";return h(function(){e+=n.els[d].innerHTML}),e}}),n.innerText=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].innerText=t})}),n.textContent=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].textContent=t})}),n.html=$(function(t){if(t)n.innerHTML(t);else{var e="";return h(function(){e+=n.els[d].outerHTML}),e}}),n.forEach=$(function(t){n.initState(t)}),n.on=$(function(t,e,r,i){t.split(", ").forEach(function(t){h(function(){n.els[d].addEventListener(t,e,r,i)}),n.ie[t]||(n.ie[t]=[]),n.ie[t].push([e,r,i])})}),n.off=$(function(t,e,r){t.split(", ").forEach(function(t){h(function(){n.els[d].removeEventListener(t,e,r)}),n.ie[t]&&(n.ie[t]=n.ie[t].filter(function(t){return t[0]!==e}))})}),n.onAll=$(function(t,e){v(n.ie,function(r,i){t&&t!==r||i[r].forEach(function(t){h(function(){e?n.els[d].removeEventListener(r,t[0]):n.els[d].addEventListener(r,t[0],t[1],t[2])})})})}),n.offAll=$(function(t){n.onAll(t,1)}),e&&n.add(e),n.take=function(e){if(n.add(e),n.el){var r=n.el.dataset.oInit;if(r!==a&&t.inits[r])return 1===n.length?(y=n.els[0],Object.assign(n,t.inits[r]),n.els=[y]):n=t.inits[r],b(!1,n.els),n}},n};o.first=function(t){return o(document.querySelector(t)||"")},o.inits=[],o.onError=!1,o.init=function(t){return o().init(t)},o.initState=function(t,e){return o().init(t).render(e)},o.take=function(t){return o().take(t)},o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=function(t,e){return Object.hasOwnProperty.call(t,e)},o.ajax=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;if(e.data&&"object"===_typeof(e.data)){for(var r in e.data)o.C(e.data,r)&&("object"===_typeof(e.data[r])?n.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):n.set(r,e.data[r]));"GET"===e.method||"get"===e.method?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return fetch(t,e)},o.get=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"GET"}))},o.post=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"POST"}))},o.getParams=function(t){var e,n={},r=new URLSearchParams(window.location.search).entries(),i=_createForOfIteratorHelper(r);try{for(i.s();!(e=i.n()).done;){var a=e.value;n[a[o.Z]]=a[o.N]}}catch(c){i.e(c)}finally{i.f()}return t?n[t]:n},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return!n&&t&&e===o.U&&o.incReady[t]?o.incSet[t]===o.N:o.incReady[t]===o.U||o.incReady[t][e]===o.U?o.F:(o.incReady[t][e].loaded=n,o.incFns[o.incReady[t][e].name]=n,o.incReady[t][o.Z]+=n,t&&o.incReady[t].length===o.incReady[t][o.Z]&&("function"==typeof o.incSet[t]&&o.incSet[t](t),o.incSet[t]=o.N),o.incSet[t]===o.N)},o.incCacheClear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.F;for(var e in o.incFns)o.C(o.incFns,e)&&(localStorage.removeItem("inc-"+e),localStorage.removeItem("inc-"+e+"Expires"));return t&&(o.incReady.forEach(function(t,e){e&&t.forEach(function(t,n){n&&o("#oInc-"+e+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=function(t,e,n){var r=o.Z,i=o.Z,a="function";if("object"!==_typeof(t)||!t)return o.incSet[o.Z];o.incSet[o.Z]++;var c=o.incSet[o.Z];o.incSet[c]=e||o.Z,o.incReady[c]=[];var s=o.incReady[c];s[o.Z]=o.N;var l={},u=function e(n){if(o.C(t,n)){r++,o.incN++;var a=t[n].indexOf(".css")>-1?"style":"script";if(t[n]=(o.incSource?o.incSource+"/":"")+t[n],isNaN(n)&&o.C(o.incFns,n)&&o.incFns[n]&&!o.incForce)return s[r]={name:n,loaded:o.N},i++,"continue";if(s[r]={name:n,loaded:o.Z},isNaN(n)&&(o.incFns[n]=o.Z),isNaN(n)&&o.incCache&&"http"!==t[n].substring(o.Z,4)&&"file:"!==window.location.protocol&&(t[n].indexOf(".css")>-1||t[n].indexOf(".js")>-1)){var u=localStorage,f=u.getItem("inc-"+n),d=u.getItem("inc-"+n+"Expires");f&&d&&new Date().getTime()<d?(o.initState({tag:a,id:"oInc-"+c+"-"+r,innerHTML:f,"data-o-inc":c}).appendInside("head"),s[r].loaded=o.N,o.incFns[n]=o.N,i++):(l[n]=r,o.get(t[n],{mode:o.incCors?"cors":"same-origin"}).then(function(e){if(200!==e.status){o.onError&&o.onError({message:o.incSource+t[n]+" was not loaded"});return}e.text().then(function(t){u.setItem("inc-"+n,t),u.setItem("inc-"+n+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+c+"-"+l[n],innerHTML:t,"data-o-inc":c}).appendInside("head"),o.incCheck(c,l[n],o.N)})}))}else{var y={tag:a,id:"oInc-"+c+"-"+r,"data-o-inc":c,async:o.incAsync,onload:"o.incCheck("+c+","+r+",1)"};t[n].indexOf(".css")>-1?(y.tag="link",y.rel="stylesheet",y.href=t[n]):(t[n].indexOf(".js")>-1||(y.tag="img",y.style="display:none;"),y.src=t[n]),o.initState(y).appendInside(y.style?"body":"head")}}};for(var f in t)if("continue"===u(f))continue;return s[o.Z]+=i,r!==o.Z&&(i===r?_typeof(e)===a&&e(c):setTimeout(function(t){o.incReady[t]&&o.incReady[t].length<o.incReady[t][o.Z]&&(o.incSet[t]=o.Z,_typeof(n)===a&&n(c))},o.incTimeout,c)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=o.tLog.length,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=0,c="├ OK: ",s="├ ✘ ",l="\n",u="\n",f=r.length,d=o.Z;"function"==typeof r[f-o.N]&&(o.tFns[e]=r[f-o.N],f--),o.tStyled?(o.tLog[e]="<div><b>"+t+" #"+e+"</b></div>",c=o.tPre+o.tOk,s=o.tPre+o.tXx,u=(l=o.tDc)+l):o.tLog[e]=t+" #"+e+"\n",o.tRes[e]=o.F,o.tStatus[e]=[];for(var y=o.Z;y<f;y++){var p={n:e,i:y,title:r[y][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},v=r[y][o.N];if("function"==typeof v)try{v=v(p)}catch(g){v=g.message,o.onError&&o.onError(g)}o.tStatus[e][y]="string"==typeof v?o.F:v,!0===v?(d++,o.tShowOk&&(o.tLog[e]+=c+r[y][o.Z]+l)):v!==o.U?o.tLog[e]+=s+r[y][o.Z]+(v!==o.F?": <i>"+v+"</i>":"")+u:(a++,setTimeout(function(t){t.title+=" (timeout)",o.testUpdate(t)},o.tTime,p))}return o.tRes[e]=d===f,o.tStyled?o.tLog[e]+=o.tPre+'<div style="color:'+(d+a!==f?"red":"green")+';"><b>':o.tLog[e]+=a?"├":"└ ",o.tLog[e]+="DONE "+d+"/"+(f-a),a&&(o.tLog[e]+=", waiting: "+a),o.tStyled?o.tLog[e]+="</b>"+o.tDc+o.tDc:o.tLog[e]+="\n",a||"function"!=typeof o.tFns[e]||o.tFns[e](e),e},o.testUpdate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.F,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(o.tStatus[t.n][t.i]===o.U){o.tStatus[t.n][t.i]=!0===e,!0===e?t.tShowOk&&(t.tStyled?o.tLog[t.n]+=o.tPre+o.tOk+t.title+n+o.tDc:o.tLog[t.n]+="└ OK: "+t.title+n+"\n"):(o.tRes[t.n]=o.F,t.tStyled?o.tLog[t.n]+=o.tPre+o.tXx+t.title+n+(e?": "+e:"")+o.tDc+o.tDc:o.tLog[t.n]+="└ ✘ "+t.title+(e?": "+e:"")+n+"\n");var r,i=o.Z,a=i,c=_createForOfIteratorHelper(o.tStatus[t.n]);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(s===o.U)return;!s&&i++,a++}}catch(l){c.e(l)}finally{c.f()}o.tRes[t.n]=!i;var u=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;t.tStyled?o.tLog[t.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+u+"</b>"+o.tDc:o.tLog[t.n]+="└ "+u,"function"==typeof o.tFns[t.n]&&o.tFns[t.n](t.n)}};
|
|
6
6
|
if (typeof define === 'function' && define.amd) {
|
|
7
7
|
define(function() {return o;}); // RequireJS
|
|
8
8
|
} else if (typeof module !== 'undefined' && module.exports) {
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "objs-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"homepage": "https://github.com/foggysq/objs",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/foggysq/objs.git"
|
|
8
|
-
},
|
|
9
|
-
"author": "Roman Torshin <inbox@fous.name> (https://fous.name/objs)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/foggysq/objs/issues"
|
|
13
|
-
},
|
|
14
|
-
"main": "objs.npm.1.0.js",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "echo \"Error: tests are here: https://fous.name/objs/documentation\" && exit 1"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"objs",
|
|
20
|
-
"test",
|
|
21
|
-
"script cache",
|
|
22
|
-
"optimize",
|
|
23
|
-
"fast develop",
|
|
24
|
-
"lightweight",
|
|
25
|
-
"library",
|
|
26
|
-
"sample",
|
|
27
|
-
"state",
|
|
28
|
-
"dom control"
|
|
29
|
-
],
|
|
30
|
-
"description": "JS library for fast develop, states control and optimisation with auto tests."
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "objs-core",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"homepage": "https://github.com/foggysq/objs",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/foggysq/objs.git"
|
|
8
|
+
},
|
|
9
|
+
"author": "Roman Torshin <inbox@fous.name> (https://fous.name/objs)",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/foggysq/objs/issues"
|
|
13
|
+
},
|
|
14
|
+
"main": "objs.npm.1.0.js",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "echo \"Error: tests are here: https://fous.name/objs/documentation\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"objs",
|
|
20
|
+
"test",
|
|
21
|
+
"script cache",
|
|
22
|
+
"optimize",
|
|
23
|
+
"fast develop",
|
|
24
|
+
"lightweight",
|
|
25
|
+
"library",
|
|
26
|
+
"sample",
|
|
27
|
+
"state",
|
|
28
|
+
"dom control"
|
|
29
|
+
],
|
|
30
|
+
"description": "JS library for fast develop, states control and optimisation with auto tests."
|
|
31
|
+
}
|