-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmaster.html
More file actions
164 lines (134 loc) · 2.83 KB
/
Copy pathmaster.html
File metadata and controls
164 lines (134 loc) · 2.83 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
height: 100vh;
margin: 0;
width: 100vw;
}
main {
display: flex;
flex-direction: row;
padding: 15px;
max-height: 90vh;
}
body {
display: flex;
flex-direction: column;
background-color: gainsboro;
}
nav {
background-color: blueviolet;
flex-grow: 1;
display: flex;
align-items: center;
padding: 0 16px;
}
.back-link {
color: white;
text-decoration: none;
font-size: 0.9rem;
opacity: 0.85;
white-space: nowrap;
}
.back-link:hover {
opacity: 1;
text-decoration: underline;
}
main {
display: flex;
flex-direction: row;
padding: 15px;
flex-grow: 10;
}
#master {
flex-grow: 1;
background-color: white;
height: 100%;
border-right: 1px solid black;
max-height: 100%;
overflow-y: scroll;
}
#detail {
flex-grow: 6;
height: 100%;
text-align: center;
padding: 20px;
background-color: white;
}
li{
list-style-type: none;
border: 1px solid black;
padding: 10px;
}
nav>h1 {
flex: 1;
text-align: center;
color: white;
margin: 0;
padding: 10px 0;
}
</style>
</head>
<body>
<nav>
<a class="back-link" href="index.html">← Home</a>
<h1>Amiibo Master Detail</h1>
</nav>
<main>
<section id="master">
<ul id="list">
</ul>
</section>
<section id="detail">
<h1>Select A Pokemon</h1>
</section>
</main>
</body>
<script>
let result = document.querySelector('#result');
let poke_data = [];
function renderList(data) {
let html = '';
let result = document.querySelector('#list');
for (let rec of data) {
html += `<li><a href="#" onclick="select('${rec.name}')">${rec.name}</a></li>`;
}
result.innerHTML = html;
}
async function getData() {
const response = await fetch(`https://weblabs.web.app/data/amiibo.json`);
data = await response.json();
poke_data = data.amiibo;
renderList(data.amiibo);
}
function findRecord(name){
for(let rec of poke_data){
if (rec.name == name)
return rec
}
return null;
}
function select(name) {
let result = document.querySelector('#detail');
let html = '';
let data = findRecord(name);
html=`
<h1>${data.name}</h1>
<img src="${data.image}" style="height:200px; width:200px"></img>
<h1>${data.gameSeries}</h1>
<h1>Release Date ${data.release.au}</h1>
`;
result.innerHTML = html;
}
getData();
</script>
</html>