-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
96 lines (82 loc) · 2.13 KB
/
index.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
<!doctype html>
<html>
<head>
<title>NodeConf 2014 NodeBots workshop high five machine photos!</title>
<link href="style.css" rel="stylesheet">
<style>
img {
-webkit-clip-path: polygon(100px 0, 178px 45px, 178px 132px, 100px 177px, 20px 132px, 20px 45px);
clip-path: url(#hexagon);
}
</style>
</head>
<div class="nodebot">
<div class="icon">
<div class="bobble"></div>
<div class="antenna"></div>
<div class="head">
<div class="eye left"></div>
<div class="eye right"></div>
</div>
<div class="neck"></div>
<div class="neck"></div>
</div>
</div>
<div id="pics"></div>
<svg width="0" height="0">
<clipPath id="hexagon">
<polygon points="100 0, 178 45, 178 132, 100 177, 20 132, 20 45"></polygon>
</clipPath>
</svg>
<script>
(function () {
function getPictures (cb) {
var request = new XMLHttpRequest()
request.open("GET", "pictures.json", true)
request.onload = function () {
if (!(this.status >= 200 && this.status < 400)) {
return cb(new Error("Server returned status " + this.status))
}
try {
cb(null, JSON.parse(this.response))
} catch (er) {
cb(er)
}
}
request.onerror = cb
request.send()
}
function renderPictures (pics) {
var ct = document.getElementById("pics")
, x = -20
, y = -45
, width = window.innerWidth
, alternate = false
ct.style.width = width + "px"
pics.forEach(function (url) {
var img = document.createElement("img")
img.src = "img/" + url
img.onload = function () { img.className = "fade-in" }
img.style.left = x + "px"
img.style.top = y + "px"
x = x + 160
if (x > width) {
alternate = !alternate
if (alternate) {
x = -100
} else {
x = -20
}
y = y + 134
}
ct.appendChild(img)
})
ct.style.height = (y + 177) + "px"
}
getPictures(function (er, pics) {
if (er) throw er
renderPictures(pics)
})
})()
</script>
</html>