generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
446 lines (415 loc) · 17.5 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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<!-- Copyright (c) 2024, Oracle and/or its affiliates.
Licensed under the terms of the GNU General Public License. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Distribution Kernel Configs</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/png" href="tux-sm.png">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<!-- Popperjs (required by tempus dominus)-->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha256-BRqBN7dYgABqtY9Hd4ynE+1slnEw+roEPFzQ7TRRfcg=" crossorigin="anonymous"></script>
<!-- Tempus Dominus JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/[email protected]/dist/js/tempus-dominus.min.js" crossorigin="anonymous"></script>
<!-- Tempus Dominus Styles -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@eonasdan/[email protected]/dist/css/tempus-dominus.min.css" crossorigin="anonymous">
<!-- FontAwesome for calendar icon -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
</head>
<body>
<div class="modal fade" id="versionModal" tabindex="-1" aria-labelledby="versionModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="versionModalLabel">Select Date of Snapshot</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="input-group" id="versionDateTimePicker" data-td-target-input="nearest" data-td-target-toggle="nearest">
<input id="versionDateTimePicker_input" type="text" class="form-control" data-td-target="#versionDateTimePicker"/>
<span class="input-group-text" data-td-target="#versionDateTimePicker" data-td-toggle="datetimepicker">
<i class="fas fa-calendar"><span class="path1"></span><span class="path2"></span></i>
</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="navigateToVersionFromDate(document.getElementById('versionDateTimePicker_input').value)">Save changes</button>
</div>
</div>
</div>
</div>
<div class="container">
<header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="." class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none">
<span class="fs-4" id="heading">Distribution Kernel Configs</span>
</a>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#versionModal">Choose Version</button>
</header>
</div>
<div class="container">
<div class="row g-3">
<div class="col">
<input id="configSelector" class="form-control" list="configurations" placeholder="KConfig entry, type to search..." onchange="addConfig(event.target.value)">
<datalist id="configurations">
</datalist>
</div>
<div class="col-auto">
<button type="button" class="btn btn-primary" onclick="addConfig(document.getElementById('configSelector').value)">Add Config</button>
</div>
</div>
<table class="table table-striped table-hover">
<thead id="header">
<td>Distribution</td>
<td></td>
</thead>
<tbody id="body">
<td>Oracle Linux...</td>
<td>y</td>
</tbody>
</table>
<div class="row">
<div class="col-auto">
<button type="button" class="btn btn-primary" onclick="exportTsv()">Save as TSV</button>
</div>
<div class="col-auto">
<button type="button" class="btn btn-secondary" onclick="exportText()">Save as Text</button>
</div>
</div>
</div>
<script>
var distroToIndex = new Map();
var configMap = new Map();
var selectedConfigs = new Set();
var versionDateMapping = new Map();
var currentVersion = "";
var currentDate = "";
function navigateToVersionFromDate(date) {
version = versionDateMapping.get(date);
if(!version) {
return // if no version present, do not navigate
}
let params = new URLSearchParams(document.location.search);
params.delete("version");
params.delete("date");
params.append("version", version);
url = window.location.pathname + `?${params.toString()}`;
window.location.href = url;
}
function dateString(date) {
const yearStr = date.getUTCFullYear().toString().padStart(4, "0");
const monthStr = (date.getUTCMonth() + 1).toString().padStart(2, "0");
const dayStr = date.getUTCDate().toString().padStart(2, "0");
return `${yearStr}-${monthStr}-${dayStr}`;
}
function populateVersionOptions(data) {
data = JSON.parse(data)
let resp = Array.from(data);
let dates = new Set();
let lastDateStr = undefined;
resp.forEach((res)=>{
const date = new Date(res.commit.committer.date);
const dateStr = dateString(date);
// We encounter commits in reverse chronological order. Use the
// first commit for the date and skip the rest, as we normally
// care about the most recent commit on the date.
if (dateStr === lastDateStr)
return;
lastDateStr = dateStr;
dates.add(date);
versionDateMapping.set(dateStr, res.sha)
// If we started with a SHA, replace it with the date string
// for a better user experience. If we started with a date, no
// need to update the header, but we need to fetch data now.
if (currentVersion == res.sha) {
setHeading(currentVersion, dateStr);
currentDate = dateStr;
} else if (currentDate == dateStr) {
currentVersion = res.sha;
requestData();
}
})
let datepicker = document.getElementById("versionDateTimePicker")
new tempusDominus.TempusDominus(datepicker, {
restrictions: {
enabledDates: Array.from(dates),
},
display: {
viewMode: 'calendar',
components: {
clock: false,
hours: false,
minutes: false,
seconds: false,
useTwentyfourHour: undefined
},
},
localization: {
format: 'yyyy-MM-dd',
},
useCurrent: false,
})
}
function getSummaryURL(version='') {
if(!version) return "summary.json" // By default fetch latest configuration summary
return `https://raw.githubusercontent.com/oracle/kconfigs/${version}/docs/summary.json`
}
function setHeading(version, date) {
let sp = document.getElementById("heading")
if (date)
sp.innerHTML = `Distribution Kernel Configs (date: ${date})`
else
sp.innerHTML = `Distribution Kernel Configs (version: ${version})`
}
function invalidVersion() {
alert("Invalid Version. Please add a valid version");
params.delete("version");
url = window.location.pathname + (params.toString())?`?${params.toString()}`:'';
window.location.href = url;
}
function initVersion() {
let params = new URLSearchParams(document.location.search);
let version = params.get("version");
let date = params.get("date");
/* If version is provided, prefer it */
if (version) {
date = null;
} else if (date) {
currentDate = date;
setHeading(version, date);
} else {
version = "gh-pages";
date = "latest";
}
setHeading(version, date);
return version
}
function loadData(data) {
let index = 0;
for (distro of data.distros) {
distroToIndex.set(distro.unique_name, index);
index++;
}
let cl = document.getElementById("configurations");
for (let [name, list] of Object.entries(data.kconfigs)) {
let element = document.createElement("option");
element.value = name;
cl.appendChild(element);
configMap.set(name, list);
}
changed = false;
for (let cn of selectedConfigs) {
if (!configMap.has(cn)) {
selectedConfigs.delete(cn);
changed = true;
console.log("delete " + cn);
}
}
reload(changed);
}
function requestData() {
const xhr = new XMLHttpRequest();
xhr.open("GET", getSummaryURL(currentVersion), true);
xhr.onload = (event) => {
console.log("Loaded kernel config summary")
if (event.target.status === 200) {
loadData(JSON.parse(event.target.response));
} else {
invalidVersion();
}
}
xhr.send(null);
}
function reload(pushState) {
console.log("Reloading")
let sortedConfigs = Array.from(selectedConfigs.keys());
sortedConfigs.sort();
const distributionElem = document.createElement("th");
distributionElem.innerText = "Distribution";
distributionElem.style = "width: 100%"
let headElems = [distributionElem];
for (cn of sortedConfigs) {
const configurationElem = document.createElement("th");
if (cn === "UTS_RELEASE") {
configurationElem.innerText += cn; // fake config
} else {
const configLink = document.createElement("a");
configLink.href = "https://cateee.net/lkddb/web-lkddb/" + cn + ".html";
configLink.innerText = cn;
configurationElem.appendChild(configLink)
}
configurationElem.innerHTML += " ";
const removeBtn = document.createElement("a");
removeBtn.dataset.target = cn;
removeBtn.classList.add("link-danger");
removeBtn.style = "cursor: pointer";
removeBtn.innerText = "[x]";
removeBtn.onclick = (e) => { removeConfig(e.target.dataset.target) };
configurationElem.appendChild(removeBtn)
headElems.push(configurationElem);
}
let head_row1 = document.createElement("tr");
head_row1.replaceChildren(...headElems)
document.getElementById("header").replaceChildren(head_row1);
let tb = document.getElementById("body");
tb.replaceChildren();
// Sorting should be done in a way that allows numbers to be sorted
// in a human friendly way. 6.10 should come after 6.1, for example.
var collator = new Intl.Collator(undefined, {numeric: true});
let sortedDistros = Array.from(distroToIndex.keys());
sortedDistros.sort(collator.compare);
for (let dn of sortedDistros) {
let elem = document.createElement("td");
elem.innerText = dn;
let rowElems = [elem];
for (let cn of sortedConfigs) {
let valueElem = document.createElement("td");
let index = distroToIndex.get(dn);
let configList = configMap.get(cn);
if (configList !== undefined) {
val = configList[index];
} else {
val = null;
}
if (val === null) {
valueElem.innerHTML = "—";
} else {
valueElem.innerText = configList[index];
}
rowElems.push(valueElem);
}
let row = document.createElement("tr");
row.replaceChildren(...rowElems);
tb.appendChild(row);
}
if (pushState) {
let qs = new URLSearchParams(); for (cn of selectedConfigs) {
qs.append("config", cn);
}
history.pushState(null, "", "?" + qs.toString())
}
}
function setState() {
let qs = new URLSearchParams(document.location.search);
console.log("SETSTATE");
selectedConfigs.clear();
for (cn of qs.getAll("config")) {
selectedConfigs.add(cn);
console.log(cn);
}
if (selectedConfigs.size === 0) {
selectedConfigs.add("UTS_RELEASE");
}
reload(false);
}
function addConfig(text) {
if (configMap.has(text) && !selectedConfigs.has(text)) {
selectedConfigs.add(text);
reload(true);
}
}
function removeConfig(text) {
if (selectedConfigs.has(text)) {
selectedConfigs.delete(text);
reload(true);
}
}
function doDownload(blob, filename) {
let a = document.createElement("a");
let url = URL.createObjectURL(blob);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(() => {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
function exportTsv() {
let text = "Distro";
let sortedConfigs = Array.from(selectedConfigs.keys());
sortedConfigs.sort();
for (cn of sortedConfigs) {
text += "\t" + cn;
}
text += "\n";
let sortedDistros = Array.from(distroToIndex.keys());
sortedDistros.sort();
for (let dn of sortedDistros) {
text += dn;
let index = distroToIndex.get(dn);
for (let cn of sortedConfigs) {
let configList = configMap.get(cn);
if (configList !== undefined) {
val = configList[index];
} else {
val = null;
}
text += "\t"
if (val) {
text += configList[index];
}
}
text += "\n";
}
let file = new Blob([text], {type: "text/tab-separated-values"});
doDownload(file, "kconfigs.tsv");
}
function exportText() {
let sortedConfigs = Array.from(selectedConfigs.keys());
sortedConfigs.sort();
let sortedDistros = Array.from(distroToIndex.keys());
sortedDistros.sort();
let distro_width = 6; /* Distro */
for (let dn of sortedDistros) {
distro_width = Math.max(distro_width, dn.length);
}
let config_widths = [];
for (let cn of sortedConfigs) {
let width = cn.length;
let configList = configMap.get(cn);
if (configList === undefined) continue;
for (let val of configList)
width = Math.max(width, val ? val.length : 2);
config_widths.push(width);
}
let text = "Distro".padEnd(distro_width);
sortedConfigs.map((cn, i) => {
text += cn.padStart(2 + config_widths[i]);
});
text += "\n";
for (let dn of sortedDistros) {
text += dn.padEnd(distro_width);
let index = distroToIndex.get(dn);
sortedConfigs.map((cn, i) => {
let configList = configMap.get(cn);
if (configList === undefined || !configList[index]) {
text += "--".padStart(2 + config_widths[i]);
} else if (configList[index]) {
text += configList[index].padStart(2 + config_widths[i]);
}
});
text += "\n";
}
let file = new Blob([text], {type: "text/plain"});
doDownload(file, "kconfigs.txt");
}
window.onpopstate = setState;
setState();
currentVersion = initVersion();
let vor = new XMLHttpRequest()
vor.open("GET", "https://api.github.com/repos/oracle/kconfigs/commits?sha=gh-pages", true)
vor.onload = (event) => {
console.log("Loaded Versions from Repository");
populateVersionOptions(event.target.response)
}
vor.send(null)
if (currentVersion) {
requestData();
}
</script>
</body>
</html>