-
Notifications
You must be signed in to change notification settings - Fork 0
/
Your-assets.html
305 lines (262 loc) · 10.1 KB
/
Your-assets.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My MIDSOMAR Assets</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><text y='14'>☀️</text></svg>">
<style>
body {
margin: 0;
padding: 20px;
font-family: 'Maven Pro', monospace;
background-color: #262626;
color: #eee;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 20px;
padding: 20px 0;
}
.asset-card {
background-color: #333;
border-radius: 8px;
overflow: hidden;
transition: transform 0.2s;
position: relative;
}
.asset-card:hover {
transform: translateY(-5px);
}
.asset-image {
width: 100%;
height: auto;
display: block;
background-color: #262626;
}
.asset-info {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 15px;
background: rgba(51, 51, 51, 0.9);
color: #eee;
opacity: 0;
transition: opacity 0.2s;
}
.asset-card:hover .asset-info {
opacity: 1;
}
.asset-name {
margin: 0;
font-size: 1em;
}
.asset-details {
margin-top: 4px;
font-size: 0.9em;
opacity: 0.8;
}
.nav-links {
text-align: center;
margin: 20px 0;
}
.nav-links a {
color: #a7ffea; /* Cyan color to match other pages */
text-decoration: none;
margin: 0 10px;
}
.nav-links a:hover {
text-decoration: underline;
}
.nav-links span {
color: #666; /* Bullet point color */
margin: 0 5px;
}
.video-modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.9);
z-index: 1000;
cursor: pointer;
}
.modal-content {
position: relative;
margin: auto;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
#assetVideo {
max-width: 90%;
max-height: 90vh;
object-fit: contain;
}
.asset-card {
cursor: pointer;
}
</style>
</head>
<body>
<div class="nav-links">
<a href="index.html">Pyramid</a>
<span>•</span>
<a href="about.html">About</a>
<span>•</span>
<a href="tracker.html">Asset manager</a>
<span>•</span>
<a href="prize-distribution.html">Prize calculator</a>
</div>
<div class="container">
<h1>Your MIDSOMAR Assets</h1>
<p style="text-align: center; color: #ccc; margin-bottom: 20px;">
NOTE: Thumbnails for combined assets not available atm.
</p>
<div class="gallery" id="assetGallery">
<!-- Cards will be generated here -->
</div>
</div>
<div id="videoModal" class="video-modal" style="display: none;">
<div class="modal-content">
<video id="assetVideo" loop>
Your browser does not support the video tag.
</video>
</div>
</div>
<script>
const assetDurations = new Map([
['0', '3'], ['1', '3'], ['2', '3'], ['3', '3'], ['4', '3'],
['5', '3'], ['6', '3'], ['7', '3'], ['8', '3'], ['9', '3'],
['10', '3'], ['11', '3'], ['12', '3'], ['13', '3'], ['14', '3'],
['15', '3'], ['16', '3'], ['17', '3'], ['18', '7'], ['19', '7'],
['20', '7'], ['21', '7'], ['22', '7'], ['23', '7'], ['24', '11'],
['25', '11'], ['26', '7'], ['27', '11'], ['28', '11'], ['29', '11'],
['30', '7'], ['31', '11'], ['32', '11'], ['33', '11'], ['34', '11'],
['35', '13'], ['36', '13'], ['37', '13'], ['38', '11'], ['39', '11'],
['40', '11'], ['41', '13'], ['42', '11'], ['43', '7'], ['44', '7'],
['45', '11'], ['46', '7'], ['47', '11'], ['48', '11'], ['49', '11'],
['50', '7'], ['51', '7'], ['52', '11'], ['53', '11'], ['54', '11'],
['55', '11'], ['56', '11'], ['57', '13'], ['58', '7'], ['59', '11'],
['60', '11'], ['61', '11'], ['62', '11'], ['63', '7'], ['64', '11'],
['65', '11'], ['66', '11'], ['67', '11'], ['68', '7'], ['69', '11'],
['70', '7'], ['71', '3'], ['72', '3'], ['73', '3'], ['74', '3'],
['75', '3'], ['76', '3']
]);
function getAssetDuration(id, asset) {
// Check if this is a combined asset
if (asset.range) {
// Parse the range (format is "XX-YY")
const [start, end] = asset.range.split('-').map(num => parseInt(num));
let totalDuration = 0;
// Sum up durations for all assets in the range
for (let i = start; i <= end; i++) {
totalDuration += parseInt(assetDurations.get(i.toString()) || 0);
}
return totalDuration;
}
// Single asset - return its duration directly
return assetDurations.get(id) || '??';
}
async function loadGallery() {
try {
const gallery = document.getElementById('assetGallery');
const savedState = localStorage.getItem('trackerState');
if (!savedState) {
gallery.innerHTML = '<p>No assets found. Visit the Asset manager to get started!</p>';
return;
}
const state = JSON.parse(savedState);
const myAssets = new Map(state.myAssets);
const assets = new Map(state.assets);
gallery.innerHTML = '';
const sortedAssets = Array.from(myAssets.entries())
.sort((a, b) => parseInt(a[0]) - parseInt(b[0]));
sortedAssets.forEach(([id, amount]) => {
if (amount > 0) {
const card = document.createElement('div');
card.className = 'asset-card';
const formattedId = id.padStart(2, '0');
const asset = assets.get(id);
const imagePath = `my-assets-images/${formattedId}_midsomar_thumb.jpg`;
const videoPath = `https://gateway.pinata.cloud/ipfs/bafybeifrxhtel4v7szmctnmz5pdw2yqsrod2qumsr5rjkdr3tgrft6wk2y/${formattedId}_midsomar_compressed.mp4`;
card.setAttribute('data-video', videoPath);
const img = new Image();
img.className = 'asset-image';
img.alt = `MS ${formattedId}`;
img.onerror = function() {
this.src = 'my-assets-images/placeholder.jpg';
this.onerror = null;
};
img.src = imagePath;
const info = document.createElement('div');
info.className = 'asset-info';
const duration = getAssetDuration(id, asset);
info.innerHTML = `
<h3 class="asset-name">MS ${formattedId}</h3>
<div class="asset-details">
Owned: ${amount}<br>
Duration: ${duration}s
</div>
`;
card.appendChild(img);
card.appendChild(info);
gallery.appendChild(card);
card.addEventListener('click', function() {
toggleVideo(this.getAttribute('data-video'));
});
}
});
if (gallery.children.length === 0) {
gallery.innerHTML = '<p>No assets found. Visit the tracker to get started!</p>';
}
} catch (error) {
console.error('Error in loadGallery:', error);
document.getElementById('assetGallery').innerHTML = '<p>Error loading gallery.</p>';
}
}
function toggleVideo(videoUrl) {
const modal = document.getElementById('videoModal');
const video = document.getElementById('assetVideo');
if (modal.style.display === 'none') {
video.src = videoUrl;
modal.style.display = 'block';
video.play();
} else {
closeVideo();
}
}
function closeVideo() {
const modal = document.getElementById('videoModal');
const video = document.getElementById('assetVideo');
video.pause();
video.src = '';
modal.style.display = 'none';
}
document.getElementById('videoModal').addEventListener('click', function() {
closeVideo();
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeVideo();
}
});
document.addEventListener('DOMContentLoaded', () => {
loadGallery().catch(error => {
console.error('Failed to load gallery:', error);
});
});
</script>
</body>
</html>