-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (45 loc) · 1.46 KB
/
index.js
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
import { clearMarkers, addMapMarker } from "./locations.js";
import {
addResultRow,
clearTable,
getFilteredResults,
populateInputs,
} from "./results.js";
import { error } from "./logging.js";
window.onerror = (e) => showError(e);
// event is of type PromiseRejectionEvent
window.addEventListener("unhandledrejection", (event) => {
event.preventDefault(); // This will not print the error in the console });
error(event.reason);
});
function showError(errorMsg, url, lineNumber) {
error(errorMsg);
return true;
}
await populateInputs();
document.getElementById("input-submit").onclick = async () => {
clearTable();
clearMarkers();
let inputYear = document.getElementById("input-year");
let yearIndices = inputYear.selectedOptions;
let inputNummer = document.getElementById("input-nummer");
let nummer = parseInt(inputNummer.value);
let inputSpeciale = document.getElementById("input-speciale");
let specialer = Array.from(inputSpeciale.selectedOptions).map((o) => o.label);
let inputEnhed = document.getElementById("input-enhed");
let enheder = Array.from(inputEnhed.selectedOptions).map((o) => o.label);
let filteredResults = await getFilteredResults(
yearIndices,
nummer,
specialer,
enheder
);
filteredResults
.sort((a, b) => a.nummer - b.nummer)
.forEach((r) => {
addResultRow(r);
});
enheder
.filter((e) => filteredResults.map((f) => f.enhed).includes(e))
.forEach((e) => addMapMarker(e));
};