-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_edit.html
118 lines (102 loc) · 4.19 KB
/
index_edit.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<ul id="main"></ul>
<script>
var response = {
"brands": {
"Honda": {
"Accord": ["red", "blue"],
"Civic": ["green", "yellow"]
},
"Porsche": {
"Cayenne": ["black", "grey"],
"Cayman": ["orange", "pink"]
},
"Toyota": {
"Prius": ["magenta", "turquish"],
"Aqua": ["magenta", "turquish"]
},
"Nissan": {
"Sunny": ["puple", "white"],
"Bluebird": ["ash", "glow"]
}
}
}
var car_brands;
var car_modals;
var car_colors;
var html_output = '';
for (car_brands in response.brands) {
// console.log(car_brands);
html_output += `<li id = title_${car_brands} >` + car_brands + "</li>";
if (car_brands == 'Honda') {
html_output += "<ul>"
for (car_modals in response.brands.Honda) {
// console.log(car_modals);
html_output += `<li id=subtitle_${car_modals}>` + car_modals + "</li>";
car_colors = response.brands.Honda[car_modals]
html_output += "<ul>"
for (var i = 0; i < car_colors.length; i++) {
// console.log(car_colors[i]);
html_output += "<li>" + car_colors[i] + "</li>";
}
html_output += "</ul>"
}
html_output += "</ul>"
} else if (car_brands == 'Porsche') {
html_output += "<ul>"
for (car_modals in response.brands.Porsche) {
// console.log(car_modals);
html_output += `<li id=subtitle_${car_modals}>` + car_modals + "</li>";
car_colors = response.brands.Porsche[car_modals]
html_output += "<ul>"
for (var i = 0; i < car_colors.length; i++) {
// console.log(car_colors[i]);
html_output += "<li>" + car_colors[i] + "</li>";
}
html_output += "</ul>"
}
html_output += "</ul>"
} else if (car_brands == 'Toyota') {
html_output += "<ul>"
for (car_modals in response.brands.Toyota) {
// console.log(car_modals);
html_output += `<li id=subtitle_${car_modals}>` + car_modals + "</li>";
car_colors = response.brands.Toyota[car_modals]
html_output += "<ul>"
for (var i = 0; i < car_colors.length; i++) {
// console.log(car_colors[i]);
html_output += "<li>" + car_colors[i] + "</li>";
}
html_output += "</ul>"
}
html_output += "</ul>"
} else if (car_brands == 'Nissan') {
html_output += "<ul>"
for (car_modals in response.brands.Nissan) {
// console.log(car_modals);
html_output += `<li id=subtitle_${car_modals}>` + car_modals + "</li>";
car_colors = response.brands.Nissan[car_modals]
html_output += "<ul>"
for (var i = 0; i < car_colors.length; i++) {
// console.log(car_colors[i])
html_output += "<li>" + car_colors[i] + "</li>";
}
html_output += "</ul>"
}
html_output += "</ul>"
}
html_output += "</ul>"
}
$('#main').html(html_output);
</script>
</body>
</html>