-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
104 lines (100 loc) · 2.42 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
window.demoLibs = {};
const ulList = document.createElement('ul');
ulList.setAttribute('id', 'parent-list');
ulList.addEventListener("click", function(e) {
if(e.target && e.target.nodeName === 'A') {
window.demoLibs[e.target.id] && window.demoLibs[e.target.id]();
}
});
document.body.appendChild(ulList);
[
{
key: 'func-prog',
name: 'Functional Programming',
src: './func-prog/index.js',
},{
key: 'array-func',
name: 'Array Functions',
src: './array-func/index.js',
},{
key: 'arrow-func',
name: 'Arrow Functions',
src: './arrow-func/index.js',
},{
key: 'bind-call-apply',
name: 'Bind Call Apply',
src: './bind-call-apply/index.js',
},{
key: 'bind',
name: 'Bind In Class',
src: './bind-in-es5class/index.js',
},{
key: 'let-const-var',
name: 'Let Const Var',
src: './let-const-var/index.js',
},{
key: 'destruct',
name: 'Destructuring',
src: './destruct/index.js',
},{
key: 'spread',
name: 'Spread',
src: './spread/index.js',
},{
key: 'promises',
name: 'Promises',
src: './promises/index.js',
},{
key: 'default-params',
name: 'Default Parameters',
src: './default-params/index.js',
},{
key: 'template-literals',
name: 'Template Literals',
src: './template-literals/index.js',
},{
key: 'object-literals',
name: 'Object Literals',
src: './object-literals/index.js',
},{
key: 'func-curry',
name: 'Function Currying',
src: './func-curry/index.js',
},{
key: 'closures',
name: 'Closures',
src: './closures/index.js',
},{
key: 'proxies',
name: 'Proxies',
src: './proxies/index.js',
},{
key: 'async-await',
name: 'Async Await',
src: './async-await/index.js',
},{
key: 'generators',
name: 'Generators',
src: './generators/index.js',
},
].sort((a, b) => {
const nameA = a.name.toLowerCase();
const nameB = b.name.toLowerCase();
if (nameA < nameB) return -1;
else if (nameA > nameB) return 1;
else return 0;
}).forEach(item => {
const li = document.createElement('li');
const a = document.createElement('a');
a.setAttribute('id', item.key);
a.setAttribute('href', '#');
a.text = item.name;
li.appendChild(a);
ulList.appendChild(li);
if (item.src) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = item.src;
document.body.appendChild(script);
}
});