Skip to content

Commit c80dfeb

Browse files
author
Silvan Strübi
committed
fixed all standard errors
Signed-off-by: Silvan Strübi <[email protected]>
1 parent dcd02bb commit c80dfeb

44 files changed

Lines changed: 3491 additions & 1669 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Docs/AnchorMenu.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
import MasterDocs from './MasterDocs.js';
1+
/* global __ */
2+
import MasterDocs from './MasterDocs.js'
23

34
export default class AnchorMenu extends MasterDocs {
4-
constructor(body) {
5-
super();
6-
this.lastScrollPos = 0;
7-
this.ticking = false;
8-
this.timeout = null;
9-
return this.html(__('div'), body);
10-
}
11-
html(el, body) {
12-
return el.$func((receiver) => {
13-
window.addEventListener('scroll', (e) => {
14-
if (!this.ticking) {
15-
this.ticking = true;
16-
clearTimeout(this.timeout);
17-
window.requestAnimationFrame(() => {
18-
this.timeout = setTimeout(() => {
19-
this.lastScrollPos > window.scrollY ? receiver.$setStyle('top: 0;') : receiver.$setStyle(`top: -${receiver.offsetHeight}px;`);
20-
this.lastScrollPos = window.scrollY;
21-
this.ticking = false;
22-
}, 500);
23-
});
24-
}
25-
});
26-
})
27-
.$css([
28-
`{
5+
constructor (body) {
6+
super()
7+
this.lastScrollPos = 0
8+
this.ticking = false
9+
this.timeout = null
10+
return this.html(__('div'), body)
11+
}
12+
html (el, body) {
13+
return el.$func((receiver) => {
14+
window.addEventListener('scroll', (e) => {
15+
if (!this.ticking) {
16+
this.ticking = true
17+
clearTimeout(this.timeout)
18+
window.requestAnimationFrame(() => {
19+
this.timeout = setTimeout(() => {
20+
this.lastScrollPos > window.scrollY ? receiver.$setStyle('top: 0;') : receiver.$setStyle(`top: -${receiver.offsetHeight}px;`)
21+
this.lastScrollPos = window.scrollY
22+
this.ticking = false
23+
}, 500)
24+
})
25+
}
26+
})
27+
})
28+
.$css([
29+
`{
2930
background-color: rgba(248, 248, 255, 0.8);
3031
margin-top: -10px;
3132
position: -webkit-sticky;
3233
position: sticky;
3334
text-align: center;
3435
transition: top 0.6s ease;
3536
}`,
36-
` ul{
37+
` ul{
3738
margin: 0;
3839
padding: 16px 0 6px;
3940
}`,
40-
` ul li{
41+
` ul li{
4142
display: inline-block;
4243
list-style: none;
4344
}`,
44-
` ul li span{
45+
` ul li span{
4546
padding: 0 10px;
4647
}`,
47-
,
48-
` ul li a{
48+
` ul li a{
4949
color: darkblue;
5050
text-decoration: none;
5151
transition: color 0.3s ease;
5252
white-space: nowrap;
5353
}`,
54-
` ul li a:hover{
54+
` ul li a:hover{
5555
color: pink;
5656
text-decoration: underline;
5757
}`
58-
], 'anchorMenu')
59-
.appendChild(__('ul'))
60-
.$appendChildren(Array.from(body.getElementsByTagName('h2')).map((el, i, arr) => {
61-
el.innerHTML = `<a name='${el.innerText}'></a>${el.innerHTML}`;
62-
return __('li').$setInnerHTML(`<a href='#${el.innerText}'>${el.innerText.replace(' ', '&nbsp;')}</a>${i !== arr.length - 1 ? '<span>|</span>' : ''}`);
63-
}))
64-
.parentElement
65-
.appendChild(__('hr'))
66-
.$css(false, 'hr')
67-
.parentElement;
68-
}
69-
}
58+
], 'anchorMenu')
59+
.appendChild(__('ul'))
60+
.$appendChildren(Array.from(body.getElementsByTagName('h2')).map((el, i, arr) => {
61+
el.innerHTML = `<a name='${el.innerText}'></a>${el.innerHTML}`
62+
return __('li').$setInnerHTML(`<a href='#${el.innerText}'>${el.innerText.replace(' ', '&nbsp;')}</a>${i !== arr.length - 1 ? '<span>|</span>' : ''}`)
63+
}))
64+
.parentElement
65+
.appendChild(__('hr'))
66+
.$css(false, 'hr')
67+
.parentElement
68+
}
69+
}

Docs/Examples/ChainDocs.js

Lines changed: 106 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import MasterExamples from './MasterExamples.js';
1+
/* global __ */
2+
import MasterExamples from './MasterExamples.js'
23
// used for examples
3-
import { ProxifyHook } from '../../JavaScript/Classes/Helper/ProxifyHook.js';
4-
import { Chain } from '../../JavaScript/Classes/Traps/Misc/Chain.js';
4+
import { ProxifyHook } from '../../JavaScript/Classes/Helper/ProxifyHook.js'
5+
import { Chain } from '../../JavaScript/Classes/Traps/Misc/Chain.js'
56

67
export default class ChainDocs extends MasterExamples {
7-
constructor(makeGlobal) {
8-
super(makeGlobal);
9-
this.name = 'chainDocs';
10-
return this.html(__('div'), ...this.text());
11-
}
12-
text() {
13-
return [
14-
'Chain',
15-
`The trap called Chain at /JavaScript/Classes/Traps/Misc/Chain.js, does Method Chaining. The $get and $set allow
8+
constructor (makeGlobal) {
9+
super(makeGlobal)
10+
this.name = 'chainDocs'
11+
return this.html(__('div'), ...this.text())
12+
}
13+
text () {
14+
return [
15+
'Chain',
16+
`The trap called Chain at /JavaScript/Classes/Traps/Misc/Chain.js, does Method Chaining. The $get and $set allow
1617
accessing properties as a function statement. $func makes it easy to execute any function within the method chaining and $_ can be prepended
1718
to any function name on the target object, to have it return the Proxy itself and for that doesn't break the chain.`,
18-
`$get + "propName"(func = undefined, ...args = undefined);
19+
`$get + "propName"(func = undefined, ...args = undefined);
1920
<ul>
2021
<li>[func]: function = a callback, which receives: receiver, prop, receiver[prop] (the value of the property), ...args.</li>
2122
<li>[...args]: any = arguments which will be passed to the function.</li>
@@ -37,97 +38,97 @@ export default class ChainDocs extends MasterExamples {
3738
<li>[...args]: any = arguments which will be passed to the function.</li>
3839
</ul>
3940
=> returns the Proxy`,
40-
`import { ProxifyHook } from './JavaScript/Classes/Helper/ProxifyHook.js;<br>
41+
`import { ProxifyHook } from './JavaScript/Classes/Helper/ProxifyHook.js;<br>
4142
import { Chain } from './JavaScript/Classes/Traps/Misc/Chain.js';<br><br>`,
42-
'Example without comments',
43-
this.example1,
44-
`Please, open the console in your developer tools and play with chainState!`,
45-
'Example with comments',
46-
this.example2,
47-
`Please, open the console in your developer tools and play with chainState!`
48-
];
49-
}
50-
example1(receiver) {
51-
// assemble the ProxifyHook with the minimum traps required
52-
const inject = new ProxifyHook(Chain()).get();
53-
54-
// proxify body
55-
const body = inject(receiver);
56-
57-
// proxify the object to which the Chain shall be applied
58-
this.makeGlobal('chainState', inject({
59-
a: 'Hello World!',
60-
b: 'Hello Universe!',
61-
c: function (str) {
62-
this.b = str;
63-
return str;
64-
}
65-
})).$getA((receiver, prop, value, ...args) => {
66-
body.appendChild(inject('p')).$setInnerHTML(`${value}:${args[0]}`);
67-
}, 'My Argument')
68-
.$func((receiver, ...args) => {
69-
body.appendChild(inject('b')).$setInnerHTML(receiver.a).parentElement.appendChild(inject('b')).$setInnerHTML(receiver.b);
70-
})
71-
.$setB('Hello Galaxy!')
72-
.$getB((receiver, prop, value, ...args) => {
73-
body.appendChild(inject('p')).$setInnerHTML(`${value}`);
74-
})
75-
.$_c('Hello SpaceX!')
76-
.$getB((receiver, prop, value, ...args) => {
77-
body.appendChild(inject('p')).$setInnerHTML(`${value}`);
78-
});
79-
}
80-
example2(receiver) {
81-
// assemble the ProxifyHook with the minimum traps required
82-
const inject = new ProxifyHook(Chain()).get();
83-
84-
// proxify body
85-
const body = inject(receiver);
86-
87-
// proxify the object to which the Chain shall be applied
88-
this.makeGlobal('chainState', inject({
89-
a: 'Hello World!',
90-
b: 'Hello Universe!',
91-
c: function (str) {
92-
this.b = str;
93-
return str;
94-
}
95-
}))
96-
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
97-
.$getA((receiver, prop, value, ...args) => {
98-
// append p to body
99-
body.appendChild(inject('p'))
100-
// getTrapSet: set an object property. Returns Proxy.
101-
.$setInnerHTML(`${value}:${args[0]}`); // "Hello World!:My Argument"
102-
}, 'My Argument')
103-
// getTrapFunc: hands over the receiver to a custom function. Returns Proxy.
104-
.$func((receiver, ...args) => {
105-
// append p to body
106-
body.appendChild(inject('b'))
107-
// getTrapSet: set an object property. Returns Proxy.
108-
.$setInnerHTML(receiver.a); // "Hello World!"
109-
// append p to body
110-
body.appendChild(inject('b'))
111-
// getTrapSet: set an object property. Returns Proxy.
112-
.$setInnerHTML(receiver.b); // "Hello Universe!"
113-
})
43+
'Example without comments',
44+
this.example1,
45+
`Please, open the console in your developer tools and play with chainState!`,
46+
'Example with comments',
47+
this.example2,
48+
`Please, open the console in your developer tools and play with chainState!`
49+
]
50+
}
51+
example1 (receiver) {
52+
// assemble the ProxifyHook with the minimum traps required
53+
const inject = new ProxifyHook(Chain()).get()
54+
55+
// proxify body
56+
const body = inject(receiver)
57+
58+
// proxify the object to which the Chain shall be applied
59+
this.makeGlobal('chainState', inject({
60+
a: 'Hello World!',
61+
b: 'Hello Universe!',
62+
c: function (str) {
63+
this.b = str
64+
return str
65+
}
66+
})).$getA((receiver, prop, value, ...args) => {
67+
body.appendChild(inject('p')).$setInnerHTML(`${value}:${args[0]}`)
68+
}, 'My Argument')
69+
.$func((receiver, ...args) => {
70+
body.appendChild(inject('b')).$setInnerHTML(receiver.a).parentElement.appendChild(inject('b')).$setInnerHTML(receiver.b)
71+
})
72+
.$setB('Hello Galaxy!')
73+
.$getB((receiver, prop, value, ...args) => {
74+
body.appendChild(inject('p')).$setInnerHTML(`${value}`)
75+
})
76+
.$_c('Hello SpaceX!')
77+
.$getB((receiver, prop, value, ...args) => {
78+
body.appendChild(inject('p')).$setInnerHTML(`${value}`)
79+
})
80+
}
81+
example2 (receiver) {
82+
// assemble the ProxifyHook with the minimum traps required
83+
const inject = new ProxifyHook(Chain()).get()
84+
85+
// proxify body
86+
const body = inject(receiver)
87+
88+
// proxify the object to which the Chain shall be applied
89+
this.makeGlobal('chainState', inject({
90+
a: 'Hello World!',
91+
b: 'Hello Universe!',
92+
c: function (str) {
93+
this.b = str
94+
return str
95+
}
96+
}))
97+
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
98+
.$getA((receiver, prop, value, ...args) => {
99+
// append p to body
100+
body.appendChild(inject('p'))
101+
// getTrapSet: set an object property. Returns Proxy.
102+
.$setInnerHTML(`${value}:${args[0]}`) // "Hello World!:My Argument"
103+
}, 'My Argument')
104+
// getTrapFunc: hands over the receiver to a custom function. Returns Proxy.
105+
.$func((receiver, ...args) => {
106+
// append p to body
107+
body.appendChild(inject('b'))
108+
// getTrapSet: set an object property. Returns Proxy.
109+
.$setInnerHTML(receiver.a) // "Hello World!"
110+
// append p to body
111+
body.appendChild(inject('b'))
112+
// getTrapSet: set an object property. Returns Proxy.
113+
.$setInnerHTML(receiver.b) // "Hello Universe!"
114+
})
115+
// getTrapSet: set an object property. Returns Proxy.
116+
.$setB('Hello Galaxy!')
117+
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
118+
.$getB((receiver, prop, value, ...args) => {
119+
// append p to body
120+
body.appendChild(inject('p'))
121+
// getTrapSet: set an object property. Returns Proxy.
122+
.$setInnerHTML(`${value}`) // "Hello Galaxy!"
123+
})
124+
// getTrap_ (underscore): executes a function on the object. Returns Proxy and ignores the functions return.
125+
.$_c('Hello SpaceX!')
126+
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
127+
.$getB((receiver, prop, value, ...args) => {
128+
// append p to body
129+
body.appendChild(inject('p'))
114130
// getTrapSet: set an object property. Returns Proxy.
115-
.$setB('Hello Galaxy!')
116-
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
117-
.$getB((receiver, prop, value, ...args) => {
118-
// append p to body
119-
body.appendChild(inject('p'))
120-
// getTrapSet: set an object property. Returns Proxy.
121-
.$setInnerHTML(`${value}`); // "Hello Galaxy!"
122-
})
123-
// getTrap_ (underscore): executes a function on the object. Returns Proxy and ignores the functions return.
124-
.$_c('Hello SpaceX!')
125-
// getTrapGet: get an object property and hand it over to custom callback. Returns Proxy.
126-
.$getB((receiver, prop, value, ...args) => {
127-
// append p to body
128-
body.appendChild(inject('p'))
129-
// getTrapSet: set an object property. Returns Proxy.
130-
.$setInnerHTML(`${value}`); // "Hello SpaceX!"
131-
});
132-
}
133-
}
131+
.$setInnerHTML(`${value}`) // "Hello SpaceX!"
132+
})
133+
}
134+
}

0 commit comments

Comments
 (0)