-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
111 lines (100 loc) · 2.79 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<title>🦆.to</title>
<link href="https://fonts.googleapis.com/css?family=Vibur" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript">
function load() {
const randomOffset = Math.floor(Math.random() * 999);
const giphyDuckApiUrl = `https://api.giphy.com/v1/gifs/search?api_key=KjkBAZyJ9fSmsDOn2uAg704CkDH0ETJS&q=duck&limit=1&offset=${randomOffset}&rating=G&lang=en`
fetch(giphyDuckApiUrl).then(function(response) {
return response.json();
})
.then(function(json) {
const imgSrc = json.data[0].images.original.url;
return fetch(imgSrc, {headers: { accept: 'image/*'}});
})
.then(function(response) {
return response.blob();
})
.then(function(duckBlob) {
const objectUrl = URL.createObjectURL(duckBlob);
const stagingPond = document.querySelector('#staging-pond');
const productionPond = document.querySelector('#production-pond');
const notDuckImg = document.querySelector('#loaded-duck');
notDuckImg.src = objectUrl;
stagingPond.classList.add('hidden');
productionPond.classList.remove('hidden');
});
}
window.onload = load;
</script>
<style>
html, body {
height: 100%;
}
body {
padding: 0;
margin: 0;
font-family: 'Vibur', cursive;
background-color: rgb(252,242,202);
overflow-y: hidden;
}
.pond {
display: flex;
flex-flow: column;
align-items: center;
align-content: center;
margin: auto;
height: 100%;
}
.not-duck {
align-self: flex-start;
display: block;
max-height: 80%;
height: auto;
max-width: 94%;
width: auto;
margin: auto;
margin-bottom: 0;
}
h1.msg {
display: block;
margin: auto;
margin-top: 5px;
text-align: center;
font-size: 9vmin;
}
.hidden {
display: none;
}
h1.msg.loading {
font-size: 9vmin;
}
#about {
margin: 0;
padding: 0;
position: absolute;
bottom: -5px;
right: 3px;
font-size: 3vmin;
}
#about a {
color: black;
text-decoration: none;
}
</style>
</head>
<body id="home">
<div id="staging-pond" class="pond">
<img id="loading-duck" class="not-duck" alt="loading not duck" src="loading_duck.gif"/>
<h1 class="msg loading" id="one-moment">un moment…</h1>
</div>
<div id="production-pond" class="pond hidden">
<img id="loaded-duck" class="not-duck" alt="not duck" src="loading_duck.gif"/>
<h1 class="msg" id="subtitle">Ce n'est pas un canard.</h1>
</div>
<div id="about"><a href="http://motevets.com/">motevets.com</div></a>
</body>
</html>