-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
73 lines (69 loc) · 1.97 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
<html>
<head>
<title>JSocksford Club</title>
<link href="https://fonts.googleapis.com/css?family=Niconne" rel="stylesheet">
<style>
body {
background: url(wall.png);
display: flex;
justify-content: center;
flex-direction: column;
}
#gallery {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
}
figure img {
width: 171px;
height: 236px;
position: relative;
left: 61px;
top: 74px;
object-fit: cover;
}
figure {
margin: 20px 10px;
width: 300px;
height: 385px;
background-repeat: no-repeat;
background-position: center center;
}
figcaption {
text-align: center;
position: relative;
top: 75px;
font-weight: bold;
opacity: 0.5;
font-size: 1.3em;
font-family: 'Niconne', cursive;
}
#gallery div:nth-of-type(even) > figure, #gallery div:nth-of-type(even) > figure img {
filter: invert(1);
}
</style>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}
</script>
<script src="socks.js"></script>
</head>
<body>
<div id="gallery"></div>
<script>
var gallery = document.getElementById('gallery');
function buildPicture(sock) {
var name = sock.substring(0, sock.indexOf('.'));
name = name[0].toUpperCase() + name.substring(1);
var markup = '<figure style="background-image: url(/frame.png)"><img src="/images/' + sock + '" alt="' + name + '\'s socks" /><figcaption>' + name + '</figcaption></figure>';
var picture = document.createElement('div');
picture.innerHTML = markup;
return picture;
}
socks.sort(function() { return 0.5 - Math.random() }).forEach(function(sock) {
gallery.appendChild(buildPicture(sock));
});
</script>
</body>
</html>