-
Notifications
You must be signed in to change notification settings - Fork 0
/
cordy.html
111 lines (104 loc) · 4.44 KB
/
cordy.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>Duckies!!!!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="Ducks for one of the coolest people I've ever had the pleasure of knowing :D">
<meta name="twitter:image:src" content="https://cdn.discordapp.com/attachments/1149735003933122670/1241435246612975736/6d99fb08a7ed3f03b26c688d49afa5e9.png?ex=664a302b&is=6648deab&hm=d287af9a90b2990233c4e2ee2bd29b2618aa3df91a4d7c606b28ea0f8fed1c2d&">
<meta name="twitter:site" content="@HelcialHelios">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Duckies!!!!">
<meta name="twitter:description" content="Ducks for one of the coolest people I've ever had the pleasure of knowing :D">
<meta property="og:image" content="https://cdn.discordapp.com/attachments/1149735003933122670/1241435246612975736/6d99fb08a7ed3f03b26c688d49afa5e9.png?ex=664a302b&is=6648deab&hm=d287af9a90b2990233c4e2ee2bd29b2618aa3df91a4d7c606b28ea0f8fed1c2d&">
<meta property="og:image:alt" content="Ducks for one of the coolest people I've ever had the pleasure of knowing :D">
<meta property="og:image:width" content="512">
<meta property="og:image:height" content="204">
<meta property="og:site_name" content="Cordy's Duckies!!">
<meta property="og:type" content="object">
<meta property="og:title" content="Duckies!!!!">
<meta property="og:url" content="https://redvalis.github.io/cordy">
<meta property="og:description" content="Ducks for one of the coolest people I've ever had the pleasure of knowing :D">
<meta name="expected-hostname" content="https://redvalis.github.io/cordy/">
<meta name="theme-color" content="#33ee99">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
font-family: 'Roboto', sans-serif;
transition: background-color 0.5s;
}
#container {
text-align: center;
}
h1 {
font-size: 2rem;
color: #333;
margin-bottom: 20px;
}
img {
cursor: pointer;
max-width: 90%;
max-height: 80vh;
border-radius: 10px;
transition: filter 0.5s, transform 0.3s;
}
img:hover {
transform: scale(1.05);
}
.loading {
filter: brightness(50%);
}
</style>
</head>
<body>
<div id="container">
<img id="duckImage" src="https://random-d.uk/api/213.jpg" alt="Random Duck" onclick="changeDuck()">
</div>
<script>
let duckUrls = [];
// Fetch the duck URLs from the text file
fetch('Media-DB/duckpics.txt')
.then(response => response.text())
.then(data => {
duckUrls = data.split('\n').filter(url => url.trim() !== '');
});
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function changeDuck() {
const duckImage = document.getElementById('duckImage');
if (duckUrls.length > 0) {
const randomIndex = Math.floor(Math.random() * duckUrls.length);
const newDuckUrl = duckUrls[randomIndex];
// Add loading class
duckImage.classList.add('loading');
// Create a temporary image to preload the new duck image
const tempImg = new Image();
tempImg.src = newDuckUrl;
tempImg.onload = () => {
duckImage.src = newDuckUrl;
duckImage.classList.remove('loading');
document.body.style.backgroundColor = getRandomColor();
};
} else {
console.error('No duck URLs available');
}
}
// Initialize with the first duck image and random background color
document.addEventListener('DOMContentLoaded', (event) => {
changeDuck();
});
</script>
</body>
</html>