-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
99 lines (99 loc) · 2.86 KB
/
example.html
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
<html>
<head>
<meta charset="utf-8">
<title>JSON to HTML Tree Example</title>
<script type="text/javascript" src="./JSONtoHTMLTree.js"></script>
<style>
:root {
--first-color: rgba(128,128,128,0.5);
--second-color: rgba(255,255,255,0.25);
}
.tree-creator-table {
background: var(--first-color);
border-radius: 0.2em;
padding: 0.2em;
margin: 0.2em;
border: 1px solid var(--first-color);
font-family: sans-serif;
}
.tree-creator-container td {
padding: 0.2em
}
.tree-creator-controller {
background: var(--first-color);
border-radius: 0.2em;
cursor: pointer;
border: 1px solid var(--first-color);
}
.tree-creator-body {
background: var(--second-color);
border: 1px solid var(--second-color);
border-radius: 0.2em;
}
.tree-creator-body input {
background: none;
border: none;
border-bottom: 1px solid var(--first-color);
width: 100%;
text-align: center;
}
#test-table {
background: rgba(128,128,128,0.5);
padding: 0.2em;
border-radius: 0.2em;
border: 1px solid rgba(128,128,128,0.5);
}
#simple-json {
width: 100%;
height: 25%;
}
</style>
</head>
<body>
<textarea id="simple-json">
{
"style": "display: inline-block",
"street": {
"value": "My street",
"house1": {
"value": "Green House",
"room1": {
"value": "Bathroom"
},
"room2": {
"value": "Living room"
},
"room3": {
"value": "Kitchen"
}
},
"house2": {
"value": "Red House",
"room1": {
"value": "Bathroom"
},
"room2": {
"value": "Living room"
},
"room3": {
"value": "Kitchen"
}
}
},
"peoples": {
"Jack Smitt": {},
"Mike Jobs": {}
}
}
</textarea>
<h1> ▼ JSON to HTML Tree ▼ </h1>
<div id="test-table">
</div>
<script>
let simpleJSON = document.getElementById('simple-json').innerHTML;
let parseJSON = JSON.parse(simpleJSON);
let tree = new JSONtoHTMLTree();
tree.init(parseJSON, document.getElementById('test-table'));
</script>
</body>
</html>