forked from yangzhong-freebsd/lua-httpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keymap.html
96 lines (80 loc) · 2.87 KB
/
keymap.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{lang["Install FreeBSD"][cur_lang]}}</title>
<link rel="stylesheet" href="/style">
</head>
<body>
<script>
function setLayout () {
let layout = document.getElementById("keymap").value;
let variant = document.getElementById("variant").value;
fetch("/setkeymap", {
method : 'POST',
body : JSON.stringify({"layout" : layout, "variant" : variant})
}).then(data =>
data.text().then(console.log));
}
function showVariants (text) {
let variant_selector = document.getElementById("variant");
let variants = JSON.parse(text);
variant_selector.textContent = "";
for (let i = 0; i < variants.length; ++i) {
let option = document.createElement("option");
option.value = variants[i].variant;
option.innerHTML = variants[i].desc;
variant_selector.appendChild(option);
}
setLayout();
}
function getVariants (e) {
let layout = e.target.value;
fetch("/keymap/variants/" + layout).then(data =>
data.text().then(showVariants));
}
function startup () {
console.log("testing");
let layout_select = document.getElementById("keymap");
layout_select.addEventListener("change", getVariants);
let variant_select = document.getElementById("variant");
variant_select.addEventListener("change", setLayout);
}
window.addEventListener("load", startup);
</script>
<div class="wrapper">
<menu class="breadcrumbs">
<a href="/">{{lang["Home"][cur_lang]}}</a> > {{lang["Keyboard"][cur_lang]}}
</menu>
<header class="section">
<h1 class="title">{{lang["Configure your keyboard"][cur_lang]}}</h1>
</header>
<form action="/writekeymap" method="POST">
<div class="section-box">
<label>
<span class="label">{{lang["Keyboard layout"][cur_lang]}}</span>
<select id="keymap" name="keymap">
<option value="" selected disabled>{{lang["Select..."][cur_lang]}}</option>
{% for _, map in ipairs(x_list) do %}
<option {{selected(map.layout == selected_layout)}} value="{{map.layout}}">{{map.desc}}</option>
{% end %}
</select>
</label>
<label>
<span class="label">{{lang["Variant"][cur_lang]}}</span>
<select id="variant" name="variant">
{% for _, var in ipairs(x_variants) do %}
<option {{selected(var.variant == selected_variant)}} value="{{var.variant}}">{{var.desc}}</option>
{% end %}
</select>
</label>
<textarea placeholder="test your keyboard here..." class="textarea" rows=10 cols=70></textarea>
</div>
<div class="section">
<button class="button primary" type="submit">{{lang["Confirm"][cur_lang]}}</button>
</div>
</form>
</div>
</body>
</html>