-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
189 lines (174 loc) · 6.65 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
<!--
This is the file that generates the file listing for the records.abstractplay.com S3 bucket.
It is here simply so the file is in source control somewhere.
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<style>
/* Overall font definitions */
@import url("https://fonts.googleapis.com/css2?family=Cardo:wght@700&family=Josefin+Sans&display=swap");
/* Colour definitions */
:root {
--main-bg-color: white;
--main-fg-color: #1a3e6f;
--main-fg-color-lighter: #c3d6f1;
--bg-color2: #999999;
--secondary-color-1: #ff6633;
--secondary-color-1-lighter: #ff8962;
--secondary-color-1-bg: #ffe8e0;
--secondary-color-2: #99cccc;
--secondary-color-2-lighter: #e6f2f2;
--secondary-color-3: #008ca8;
--secondary-color-3-lighter: #009fbf;
--secondary-color-3-bg: #eefcff;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Cardo", serif;
}
body,
button,
input,
select,
textarea {
font-family: "Josefin Sans", sans-serif;
font-size: 1em;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: var(--main-bg-color);
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
/* Link handling */
/* a {
color: var(--secondary-color-3);
text-decoration: underline;
} */
/* Add a little bit of space after checkboxes and radio buttons */
input[type="checkbox"],
input[type="radio"] {
margin-right: 0.25em;
}
/* Only used to colour buttons until I can figure out how to override Bulma colours */
.apButton {
background: linear-gradient(
180deg,
var(--secondary-color-3-lighter) 0%,
var(--secondary-color-3) 100%
);
color: white;
}
.apButton:hover {
background: var(--main-fg-color);
color: white;
}
.apButtonAlert {
background: linear-gradient(
180deg,
var(--secondary-color-1-lighter) 0%,
var(--secondary-color-1) 100%
);
color: white;
}
.apButtonAlert:hover {
background: var(--main-fg-color);
color: white;
}
</style>
<title>Abstract Play Records</title>
</head>
<body>
<main class="container p-6">
<div class="content">
<p class="title">Abstract Play Records</p>
<p>Game reports adhere to a schema, available in the <a href="https://github.com/AbstractPlay/recranks/blob/main/src/schemas/gamerecord.json">Abstract Play Records and Rankings repository</a>.</p>
</div>
<table class="table">
<thead>
<tr>
<th>File</th>
<th>Size</th>
<th>Last modified</th>
</tr>
</thead>
<tbody id="tableBody">
</tbody>
</table>
</main>
<script type="text/javascript">
// Load JSON text from server hosted file and return JSON parsed object
function loadJSON(filePath) {
// Load json file;
var json = loadTextFileAjaxSync(filePath, "application/json");
// Parse json
return JSON.parse(json);
}
// Load text with Ajax synchronously: takes path to file and optional MIME type
function loadTextFileAjaxSync(filePath, mimeType)
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET",filePath,false);
if (mimeType != null) {
if (xmlhttp.overrideMimeType) {
xmlhttp.overrideMimeType(mimeType);
}
}
xmlhttp.send();
if (xmlhttp.status==200 && xmlhttp.readyState == 4 )
{
return xmlhttp.responseText;
}
else {
throw new Error("Unable to load manifest");
}
}
document.addEventListener("DOMContentLoaded", function(event) {
let data = loadJSON("_manifest.json");
data = data.filter(x => (x.Key.endsWith(".json")) && (! x.Key.startsWith("_")));
data.sort((a, b) => a.Key.localeCompare(b.Key));
let tbodyStr = "";
for (const rec of data) {
let size = rec.Size;
if (size <= 1024) {
size += "b";
} else if (size < 1024**2) {
size = Math.trunc((size / 1024) * 100) / 100;
size += "k";
} else {
size = Math.trunc((size / 1024**2) * 100) / 100;
size += "M"
}
tbodyStr += `<tr><td><a href="${rec.Key}">${rec.Key}</a></td><td>${size}</td><td>${rec.LastModified}</td></tr>`;
}
const tbody = document.getElementById("tableBody");
tbody.innerHTML = tbodyStr;
});
</script>
</body>
</html>