-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.js
116 lines (92 loc) Β· 3.5 KB
/
bundle.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
105
106
107
108
109
110
111
112
113
114
115
116
"use strict";
window.onload = () => {
let viewer = [];
const parse = (page, obj) => {
if (typeof obj?.textContent === `object` && obj.textContent.name && obj.textContent.value ? true : false) {
let result;
page.states.forEach(state => {
if (state.name === obj.textContent.name) {
result = state;
}
});
obj.textContent = result.value;
viewer.push(createElement(page, obj));
} else {
viewer.push(createElement(page, obj));
}
Object.keys(obj).forEach((key, idx) => {
const value = Object.values(obj)[idx];
if (key === `child` && Array.isArray(value)) {
value.forEach(e => parse(page, e));
}
});
}
const createElement = (page, obj) => {
const element = document.createElement(obj.type);
Object.keys(obj).forEach((key, idx) => {
const value = Object.values(obj)[idx];
if (child_list.includes(key)) {
if (key !== `textContent`) element.setAttribute(key, value);
else element.textContent = obj.textContent;
}
if (on_list.includes(key)) {
element[key.toLowerCase()] = () => {
const state = (name, value) => {
let result;
page.states.forEach(state => {
if (state.name === name) {
state.value = value;
result = state;
}
});
viewer = [];
page.json.forEach(element => parse(page, element));
document.querySelector(`body #root`).innerHTML = ``;
viewer.forEach(view => {
document.querySelector(`body #root`).append(view);
});
return result;
}
const request = {};
const response = { state };
eval(value)(request, response);
}
}
});
return element;
}
let pages = [];
/* &*_-jsbo_-_*& */
let child_list = [
"id",
"textContent",
"className",
"style",
"src",
"href",
"value",
];
let on_list = [
"onClick",
"onChange",
"onInput",
"onMouseDown",
"onMouseMove",
"onMouseUp",
"onKeyDown",
"onKeyUp",
]
document.write(`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>Document</title>\n</head>\n<body>\n <div id="root"></div>\n</body>\n</html>`);
pages.forEach(page => {
if (window.location.pathname === page.path) {
// setInterval(() => {
document.querySelector(`body #root`).innerHTML = ``;
viewer = [];
page.json.forEach(element => parse(page, element));
viewer.forEach(view => {
document.querySelector(`body #root`).appendChild(view);
});
// });
}
});
}