-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimals.html
More file actions
67 lines (58 loc) · 1.29 KB
/
animals.html
File metadata and controls
67 lines (58 loc) · 1.29 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
<!doctype html>
<html>
<head>
<title>
Do you know the name of this animal?
</title>
<meta charset=utf-8>
<link rel=stylesheet href=css/style.css />
<link rel=stylesheet href=css/mobile.css />
</head>
<body>
<div id=gallery></div>
<template>
<div class=animal>
<header>
<h1>${jmx}</h1>
<h2>${en}</h2>
<h2>${es}</h2>
</header>
<figure>
<img src=images/${en}.jpg>
<figcaption>
</figcaption>
</figure>
</div>
</template>
<div style=display:none class=animal>
<header>
<h1>ma’a</h1>
<h2>raccoon</h2>
<h2>mapache</h2>
</header>
<figure>
<img src=images/raccoon.jpg>
<figcaption>
By Darkone (Own work) [<a href="http://creativecommons.org/licenses/by-sa/2.5">CC BY-SA 2.5</a>], <a href="https://commons.wikimedia.org/wiki/File%3ARaccoon_(Procyon_lotor)_2.jpg">via Wikimedia Commons</a>
</figcaption>
</figure>
</div>
<script src=../../js/template.js></script>
<script src=../../js/fetch.js></script>
<script>
var
gallery = document.querySelector('#gallery'),
template = document.querySelector('template').innerHTML;
fetch('animals.json')
.then(function(json){ return json.json() })
.then(function(animals){
animals.forEach(function(animal){
gallery.insertAdjacentHTML('beforeend', template.template(animal))
})
})
.catch(function(error){
console.log(error)
})
</script>
</body>
</html>