-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.html
277 lines (246 loc) · 8.18 KB
/
template.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<!DOCTYPE html>
<html>
<head>
<title>Horloge</title>
<meta name="description" content="EVM-made SVG animations">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Horloge">
<meta property="og:description" content="EVM-made SVG animations">
<style>
body, * {
font-family: sans-serif;
margin:0;
color: white;
overflow: hidden;
box-sizing: border-box;
}
main {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #111111;
flex-direction: column;
}
.container {
top: 0;
left: 0;
display: flex;
flex-direction: column-reverse;
align-items: flex-start;
flex-wrap: wrap;
position: relative;
}
nav {
display: flex;
flex-wrap: wrap;
align-items: center;
flex-direction: column;
max-height:90vh;
margin-top: 0.75rem;
}
nav a {
display: inline-block;
padding: 0.15rem;
margin-right: 1rem;
white-space: nowrap;
flex-grow: 0;
flex-basis: auto;
}
@media (max-width: 1240px) {
.container {
flex-direction: column;
}
nav {
flex-direction: row;
}
nav a {
padding: 0.25rem;
margin: 0;
}
}
@media (max-width: 720px) {
nav a {
padding: 0.5rem;
}
}
h1 {
margin-top: 0;
white-space: nowrap;
flex-grow: 0;
flex-shrink: 0;
}
img {
width: 89vw;
height: 89vh;
}
#openseaContainer {
bottom: 0;
left: 0;
}
.container,
#openseaContainer,
#artworkTitle ,
#artworkDescription {
position: absolute;
margin: 0.5rem;
}
#artworkTitle {
top: 0;
right: 0;
font-style: italic;
font-weight: bold;
}
#artworkDescription {
bottom: 0;
right: 0;
}
@media (max-width: 1240px) {
#artworkTitle {
bottom: 1.5rem;
top: auto;
}
h1 {
transform: rotate(180deg);
width: 95vw;
margin-top: 0.75rem;
}
}
@media (max-width: 300px) {
#artworkTitle {
bottom: 3.5rem;
}
#artworkDescription {
bottom: 1.5rem;
}
#openseaContainer {
right: 0;
left: auto;
}
}
a {
color: #FEFEFE;
text-decoration: none;
}
a {
color: #FEFEFE;
text-decoration: none;
padding:0.25rem;
border-radius: 0.25rem;
}
a:hover {
background-color: #FEFEFE;
color:#111111;
}
</style>
<script>
window.onload = function () {
var myImage = document.getElementById('artworkImage');
if (myImage) {
myImage.addEventListener('click', toggleVisibility);
}
// Function to get the artwork number from URL
function getArtworkNumber() {
const path = window.location.pathname;
// Remove trailing slash if it exists
const trimmedPath = path.endsWith('/') ? path.slice(0, -1) : path;
console.log(trimmedPath);
return trimmedPath.split("/").pop();
}
// Function to update the title and meta description
function updateHeadElements(title, description) {
document.title = title; // Update the title
// Find and update the meta description
let metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.setAttribute('content', description);
} else {
// Create meta description if it doesn't exist
metaDescription = document.createElement('meta');
metaDescription.setAttribute('name', 'description');
metaDescription.setAttribute('content', description);
document.getElementsByTagName('head')[0].appendChild(metaDescription);
}
}
// Function to load metadata from JSON
function loadContent(artworkNumber) {
fetch(`data.json`)
.then((response) => response.json())
.then((data) => {
const decodedJson = atob(data[artworkNumber]);
const artworkInfo = JSON.parse(decodedJson);
// Update the title and meta description
updateHeadElements(artworkInfo.name, artworkInfo.description);
// Set the image and description
document.getElementById('artworkImage').src = artworkInfo.image;
document.getElementById('artworkTitle').innerText = artworkInfo.name;
const description = artworkInfo.description.split('This clock was')[1];
const blockNumber = description.split('#')[1];
const descriptionElement = document.getElementById('artworkDescription');
const link = document.createElement('a');
link.href = `https://optimistic.etherscan.io/block/${blockNumber}`; // Adjust the href according to your URL structure
link.textContent = `${description}`;
descriptionElement.appendChild(link);
// Retrieve the total number of artworks
const totalArtworks = artworkInfo.total_artworks;
// Populate navigation with links to other artworks
populateNavigation(artworkNumber, totalArtworks);
})
.catch((error) => console.error("Error:", error));
}
// Function to populate navigation with links
function populateNavigation(currentArtworkNumber, totalArtworks) {
const navElement = document.getElementById('links');
// Determine the base URL
let baseURL = window.location.href;
baseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
baseURL = baseURL.substring(0, baseURL.lastIndexOf('/') + 1);
// Loop through the total number of artworks to create navigation links
for (let i = 1; i <= totalArtworks; i++) {
// Skip the current artwork
if (i.toString() === currentArtworkNumber) continue;
const link = document.createElement('a');
link.href = `../${i}`; // Adjust the href according to your URL structure
link.textContent = `[ ${i} ]`;
navElement.appendChild(link);
}
}
// Function to toggle visibility
function toggleVisibility() {
var elements = ['artworkTitle', 'artworkDescription', 'openseaLink', 'bonjour'];
elements.forEach(function(id) {
var element = document.getElementById(id);
if (element) {
element.style.display = element.style.display === 'none' ? '' : 'none';
}
});
}
const artworkNumber = getArtworkNumber();
// OpenSea link
document.getElementById("openseaLink").href =
"https://opensea.io/assets/optimism/0x55dd0cd5ed594bbd47faeebff0665bc241a53157/" +
artworkNumber;
loadContent(artworkNumber);
};
</script>
</head>
<body>
<div id="bonjour" class="container">
<nav id="links"></nav>
<h1><a href="https://vncnt.xyz/horloge">Horloge</a></h1>
</div>
<main>
<img id="artworkImage" src="" alt="SVG Animations made of a grid of rectangle elements with shifting colours and border radius" />
</main>
<div id="openseaContainer">
<a id="openseaLink">
OpenSea
</a>
</div>
<div id="artworkTitle">
</div>
<div id="artworkDescription">
</div>
</body>
</html>