-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
233 lines (216 loc) · 12 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Su Squares, cute squares you own and personalize</title>
<meta name="description" content="The first ERC-721 NFT. Cute squares you own and personalize.">
<link rel="canonical" href="https://tenthousandsu.com" />
<link rel="stylesheet" href="assets/main.css?20210926">
</head>
<body>
<header>
<a id="logo" href="/"><img src="assets/logo-su-squares.svg" style="width:348px;height:57px;object-fit: cover;" alt="Su Squares logo"></a>
<span>
The first ERC-721 NFT
</span>
<a class="btn" href="white-paper">About us</a>
<a class="btn" href="buy">Buy</a>
<a class="btn" href="personalize">Personalize</a>
<a class="btn" target="_blank" href="https://x.com/susquares">
<!-- Corrected target attribute -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-twitter-x" viewBox="0 0 16 16">
<path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Zm-.86 13.028h1.36L4.323 2.145H2.865l8.875 11.633Z"/>
</svg>
</a>
<a class="btn" target="_blank" href="https://discord.gg/6nTGNdjQ3B">
<!-- Corrected target attribute -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-discord" viewBox="0 0 16 16">
<path d="M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612Zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612Z" />
</svg>
</a>
</header>
<article>
<p>Click below to buy an available Su Square (0.5 ETH)</p>
<a id="wheretogo" href="#" target="_blank">
<div style="position:relative;height:1000px">
<img id="theImage" src="build/wholeSquare.png" alt="All Su Squares" style="margin:0; height:1000px; width:1000px">
<div id="position"
style="background:pink;opacity:0.8;width:10px;height:10px;;position:absolute;pointer-events:none">
</div>
<div id="tooltip" style="color:black"></div>
<div id="electric-fence"></div>
</div>
</a>
</article>
<article>
<section id="newly-minted" style="display:flex; align-items: center; width: 100%; margin-bottom: 2em">
<strong style="flex: 1 1 0">Newly minted</strong>
</section>
<section id="newly-personalized" style="display:flex; align-items: center; width: 100%">
<strong style="flex: 1 1 0">Latest personalized</strong>
</section>
</article>
<footer>
<small>
No cookies. No analytics. Not responsible for content of linked sites. Images shown on homepage are © their
respective owners. This image refreshes <a target="_blank" href="https://github.com/su-squares/tenthousandsu.com/actions/workflows/load-from-blockchain.yml">hourly</a>. To the extent possible under law, Su Entriken has waived
all copyright and related or neighboring rights to the TenThousandSu.com website. This work is published from the
United States.
</small>
</footer>
<script>
let positionSquareNumber = 1;
var squarePersonalizations = [];
var squareExtra = [];
// Animate the electric fence
let fence = new Set();
let litUpEdge = new Set();
let wasEverLitUp = new Set();
const squarePersonalizationsPromise = fetch("build/squarePersonalizations.json").then(response => response.json());
const squareExtraPromise = fetch("build/squareExtra.json").then(response => response.json());
Promise.all([squarePersonalizationsPromise, squareExtraPromise])
.then(([personalizations, extra]) => {
squarePersonalizations = personalizations; /* [title, href] or null */
squareExtra = extra; /* [mintedBlock, updatedBlock, mainIsPersonalized, version */
// Start fence animation
lightUpFence(new Set([1]));
// Show newly minted and personalized Squares
const newlyMintedSection = document.getElementById("newly-minted");
const newlyPersonalizedSection = document.getElementById("newly-personalized");
const mostRecentMintedSquares = squareExtra
.map((extraData, index) => [index, extraData])
.filter(([index, extraData]) => extraData !== null)
.sort((a, b) => b[1][0 /* mintedBlock */] - a[1][0])
.slice(0, 5);
mostRecentMintedSquares.forEach(([index, extraData]) => {
const row = Math.floor((index - 1) / 100);
const col = (index - 1) % 100;
const squareNumber = index + 1;
newlyMintedSection.insertAdjacentHTML("beforeend",
`<a style="display:flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 0" href="https://tenthousandsu.com/square#${squareNumber}">
<div style="background: url('https://tenthousandsu.com/build/wholeSquare.png'); height: 10px; width: 10px; background-position-x: ${-col * 10}px; background-position-y: ${-row * 10}px; display: inline-block; zoom: 5; image-rendering: pixelated;"></div>
<p>#${squareNumber}</p>
</a>`
);
});
const mostRecentPersonalizedSquares = squareExtra
.map((extraData, index) => [index, extraData])
.filter(([index, extraData]) => extraData !== null)
.filter(([index, extraData]) => extraData[1] !== extraData[0])
.sort((a, b) => b[1][1 /* updatedBlock */] - a[1][1])
.slice(0, 5);
mostRecentPersonalizedSquares.forEach(([index, extraData]) => {
const row = Math.floor((index) / 100);
const col = (index) % 100;
const squareNumber = index + 1;
newlyPersonalizedSection.insertAdjacentHTML("beforeend",
`<a style="display:flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 0" href="https://tenthousandsu.com/square#${squareNumber}">
<div style="background: url('https://tenthousandsu.com/build/wholeSquare.png'); height: 10px; width: 10px; background-position-x: ${-col * 10}px; background-position-y: ${-row * 10}px; display: inline-block; zoom: 5; image-rendering: pixelated;"></div>
<p>#${squareNumber}</p>
</a>`
);
});
});
function setPosition(squareNumber) {
positionSquareNumber = squareNumber;
const positionDiv = document.getElementById("position");
const tooltipDiv = document.getElementById("tooltip");
const whereToGoAnchor = document.getElementById("wheretogo");
if (!squarePersonalizations[squareNumber - 1]) {
document.getElementById("theImage").style.cursor = "pointer";
tooltipDiv.textContent = "Square #" + squareNumber + " is available for sale, click to buy.";
whereToGoAnchor.href = "buy?square=" + squareNumber;
} else if (!squarePersonalizations[squareNumber - 1][0] && !squarePersonalizations[squareNumber - 1][1]) {
document.getElementById("theImage").style.cursor = "not-allowed";
tooltipDiv.textContent = "Square #" + squareNumber + " WAS PURCHASED BUT NOT YET PERSONALIZED";
whereToGoAnchor.removeAttribute("href");
} else {
document.getElementById("theImage").style.cursor = "pointer";
tooltipDiv.textContent = "Square #" + squareNumber + " " + squarePersonalizations[squareNumber - 1][0];
whereToGoAnchor.href = squarePersonalizations[squareNumber - 1][1];
}
positionDiv.style.left = ((squareNumber - 1) % 100) * 10 + "px";
positionDiv.style.top = Math.floor((squareNumber - 1) / 100) * 10 + "px";
tooltipDiv.style.left = positionDiv.style.left;
tooltipDiv.style.top = (parseInt(positionDiv.style.top) + 30) + "px";
tooltipDiv.style.display = "block";
}
document.getElementById("theImage").addEventListener("mousemove", (e) => {
const theImage = document.getElementById("theImage");
const rect = theImage.getBoundingClientRect(); // Get the bounding rectangle of the image
const x = Math.min(Math.max(Math.floor((e.clientX - rect.left) / 10), 0), 99); // Adjust by element's left position
const y = Math.min(Math.max(Math.floor((e.clientY - rect.top) / 10), 0), 99); // Adjust by element's top position
const squareNumber = x + y * 100 + 1;
setPosition(squareNumber);
});
document.addEventListener("keydown", (e) => {
const key = e.key.toLowerCase();
if (key === 'w' || key === ',' || key === 'arrowup') {
// Move up
if (positionSquareNumber > 100) setPosition(positionSquareNumber - 100);
event.preventDefault(); // Prevent scrolling
} else if (key === 'a' || key === 'a' || key === 'arrowleft') {
// Move left
if (positionSquareNumber % 100 !== 1) setPosition(positionSquareNumber - 1);
} else if (key === 's' || key === 'o' || key === 'arrowdown') {
// Move down
if (positionSquareNumber <= 100 * 99) setPosition(positionSquareNumber + 100);
event.preventDefault(); // Prevent scrolling
} else if (key === 'd' || key === 'e' || key === 'arrowright') {
// Move right
if (positionSquareNumber % 100 !== 0) setPosition(positionSquareNumber + 1);
} else if (key === 'enter') {
// Trigger click for highlighted square
const whereToGoAnchor = document.getElementById("wheretogo");
if (whereToGoAnchor.href) {
whereToGoAnchor.click();
}
}
});
function lightUpFence(edge) {
litUpEdge.forEach(s => {
const element = document.getElementById("electric-fence-" + s);
if (element && element.parentNode) {
element.parentNode.removeChild(element);
}
});
litUpEdge.clear();
let nextEdge = new Set();
edge.forEach((square) => {
wasEverLitUp.add(square);
const element = document.createElement("div");
element.id = "electric-fence-" + square;
element.style.pointerEvents = "none";
element.style.position = "absolute";
element.style.left = ((square - 1) % 100 * 10) + "px";
element.style.top = Math.floor((square - 1) / 100) * 10 + "px";
element.style.width = "10px";
element.style.height = "10px";
element.style.background = "#ffd700";
element.style.opacity = "0.25";
document.getElementById("electric-fence").appendChild(element);
if (squarePersonalizations[square - 1] !== null) {
litUpEdge.add(square);
if (square > 100 && !wasEverLitUp.has(square - 100)) {
nextEdge.add(square - 100);
}
if (square <= 100 * 99 && !wasEverLitUp.has(square + 100)) {
nextEdge.add(square + 100);
}
if (square % 100 != 1 && !wasEverLitUp.has(square - 1)) {
nextEdge.add(square - 1);
}
if (square % 100 != 0 && !wasEverLitUp.has(square + 1)) {
nextEdge.add(square + 1);
}
} else {
fence.add(square);
}
});
if (nextEdge.size > 0) {
setTimeout(() => { lightUpFence(nextEdge) }, 25);
}
}
</script>
</body>
</html>