-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
163 lines (134 loc) · 5.22 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
<html>
<head>
<title>xkeyboard-config layouts</title>
<style>
table {
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
tbody tr :nth-child(3),
tbody tr :nth-child(4) {
color: grey;
}
tbody tr:nth-child(odd) {
background-color: #f2f2f2;
}
</style>
<script type="module">
var layouts = (await(await fetch("layouts.json")).json()).layouts;
var iso3166 = await(await fetch("iso3166.json")).json();
var iso639 = await(await fetch("iso639.json")).json();
function xkb_name(layout) {
if (layout.variant) {
return `${layout.layout}(${layout.variant})`
} else {
return layout.layout;
}
}
layouts.sort((a, b) => xkb_name(a).localeCompare(xkb_name(b)));
layouts.sort((a, b) => a.description.localeCompare(b.description));
function getLanguageName(x) { return iso639[x] || x };
function getCountryName(x) { return iso3166[x] || x };
const tbody = document.getElementById("tbody");
var languageSet = new Set();
var countrySet = new Set();
layouts.forEach(layout => {
if (layout.layout == 'custom') {
return;
}
layout.iso639.map(x => languageSet.add(x));
layout.iso3166.map(x => countrySet.add(x));
const tr = document.createElement("tr");
tr.id = xkb_name(layout);
layout.iso639.map(x => tr.classList.add(x));
layout.iso3166.map(x => tr.classList.add(x));
var xkb = document.createElement("td");
var a = document.createElement("a");
a['href'] = "https://hickford.github.io/xkb_ldml/html/" + xkb_name(layout) + ".html";
a.appendChild(document.createTextNode(xkb_name(layout)));
xkb.appendChild(a);
tr.appendChild(xkb);
var description = document.createElement("td");
description.appendChild(document.createTextNode(layout.description));
tr.appendChild(description);
var langg = document.createElement("td");
langg.appendChild(document.createTextNode(layout.iso639.join(", ")));
tr.appendChild(langg);
var countt = document.createElement("td");
countt.appendChild(document.createTextNode(layout.iso3166.join(", ")));
tr.appendChild(countt);
tbody.appendChild(tr);
});
const language = document.getElementById("language");
var languageList = Array.from(languageSet);
languageList.sort((a, b) => getLanguageName(a).localeCompare(getLanguageName(b)));
languageList.forEach(x => {
var option = document.createElement("option");
option.value = x;
option.appendChild(document.createTextNode(getLanguageName(x)));
language.appendChild(option);
}
);
const country = document.getElementById("country");
var countryList = Array.from(countrySet);
countryList.sort((a, b) => getCountryName(a).localeCompare(getCountryName(b)));
countryList.forEach(x => {
var option = document.createElement("option");
option.value = x;
option.appendChild(document.createTextNode(getCountryName(x)));
country.appendChild(option);
});
function filter(v) {
document.querySelectorAll("tbody tr").forEach(td => td.style.display = v ? 'none' : '');
document.querySelectorAll(`tbody tr.${v}`).forEach(td => td.style.display = '');
};
document.getElementById("country").oninput = e => {
document.getElementById("language").value = "";
filter(e.target.value);
}
document.getElementById("language").oninput = e => {
document.getElementById("country").value = "";
filter(e.target.value);
}
document.getElementById("reset").onclick = e => filter("");
</script>
</head>
<body>
<h1>XKB layout explorer</h1>
<p>Table to explore layouts in xkeyboard-config. <a href="https://github.com/hickford/xkb-layout-explorer">Feedback
welcome on GitHub</a>.</p>
<form>
<label for="language">Language:</label>
<select id="language">
<option value=""></option>
<!-- <option value="eng">English</option> -->
</select>
<label for="country">Country:</label>
<select id="country">
<option value=""></option>
<!-- <option value="AM">Armenia</option>
<option value="BG">Bulgaria</option> -->
</select>
<input id="reset" type="reset" value="Reset filters">
</form>
<table>
<thead>
<tr>
<th>Layout</th>
<th>Description</th>
<th>Languages</th>
<th>Countries</th>
</tr>
</thead>
<tbody id="tbody">
<!-- <tr>
<td>us(chr)</td>
<td>Cherokee</td>
<td>chr</td>
<td>US</td>
</tr> -->
</tbody>
</table>
</body>
</html>