This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (67 loc) · 1.62 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
<!DOCTYPE html>
<html>
<head>
<title>doggo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html, body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
background-color: #000;
color: #fff;
font-family: sans-serif;
}
body {
background-image: url();
background-repeat: repeat;
background-position: center;
background-size: fit;
}
#attribution, #author {
background-color: #000;
color: #fff;
padding: 6px;
font-size: 12px;
text-decoration: none;
position: fixed;
bottom: 0px;
}
#author { left: 0px; }
#attribution { right: 0px; }
#attribution:hover, #author:hover {
text-decoration: underline;
}
</style>
<script>
window.onload = function(){
// GIPHY loader code
q = "dog";
api_key = "X1FqV4u0y80GtmHSWPg8ho9p9c1cPnI1";
request = new XMLHttpRequest;
request.open('GET', `https://api.giphy.com/v1/gifs/random?api_key=${api_key}&tag=${q}&rating=g`, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400){
data = JSON.parse(request.responseText).data.image_url;
document.body.style.backgroundImage = `url(${data})`;
document.getElementById("attribution").setAttribute("href", data);
} else {
console.log('reached giphy, but API returned an error');
console.log(`status: ${request.status}`);
console.log(JSON.parse(request.responseText));
}
};
request.onerror = function() {
console.log('connection error');
};
request.send();
};
</script>
</head>
<body>
<a id="author" href="https://ovine.xyz">made by katacarbix</a>
<a id="attribution" href="https://giphy.com">powered by giphy</a>
</body>
</html>