-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
122 lines (97 loc) · 2.94 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Troppydash's Simulations</title>
<link rel="icon" type="image/x-icon" href="/canvas/tdsim.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]">
<style>
body {
margin: 0;
min-height: 100vh;
padding: 3rem;
}
#sims {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
position: relative;
}
#sims > div {
margin: 2rem 1rem;
max-width: 400px;
width: 100%;
}
#sims a {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
#sims > div > div {
position: relative;
padding-bottom: 56.25%;
}
#sims img {
position: absolute;
object-fit: cover;
width: 100%;
height: 100%;
border: 2px solid red;
margin: 0.75rem 0;
}
/* lower resolutions */
@media screen and (max-width: 800px) {
body {
padding: 1rem;
}
#sims > div {
margin: 1rem;
max-width: 100%;
}
}
</style>
</head>
<body class="st-dark">
<div>
<h1 class="st-text st-text--title">Troppydash's Simulations</h1>
<h6 class="st-text">Visit <a href="https://github.com/troppydash/tdsim">the source code</a></h6>
<img src="/canvas/tdsim.ico" width="128"/>
</div>
<div id="sims">
</div>
<script>
function createSim(name, data) {
const simsList = document.getElementById('sims');
const sim = document.createElement('div');
sim.classList.add('sim');
const title = document.createElement('a');
title.classList.add('st-text', 'st-text--160');
title.innerText = name;
title.href = name;
sim.appendChild(title);
const imageWrapper = document.createElement('div');
const image = document.createElement('img');
image.src = data.screenshot;
imageWrapper.appendChild(image);
sim.appendChild(imageWrapper);
simsList.appendChild(sim);
}
async function fetchMappings(path) {
const data = await fetch(path);
return await data.json();
}
// document ready
document.addEventListener('DOMContentLoaded', async function () {
const mapping = await fetchMappings('canvas/mapping.json');
// generate sims
for (const [name, data] of Object.entries(mapping)) {
createSim(name, data);
}
});
</script>
</body>
</html>