-
Notifications
You must be signed in to change notification settings - Fork 0
/
Template.html
90 lines (76 loc) · 2.72 KB
/
Template.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
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<title>Template</title>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<link rel='stylesheet' href='../resources/VitalStyle.css' />
<style></style>
</head>
<body>
<h1>Template</h1>
<!-- Settings -->
<details id='settings'>
<summary>Settings</summary>
<div style='display: flex;
flex-wrap: wrap;
align-items: baseline;
column-gap: 2px;
overflow: auto;'
>
<label id='langLabel' for='lang'>Language</label>
<select
name='language'
id='lang'
onchange='setLanguage()'
style='flex-grow: 1;'
>
<option value='eng'>English [Vitaly Ulyanov]</option>
<option value='rus'>Русский [Виталий Ульянов]</option>
</select>
</div>
</details>
<!-- Page main body -->
<p id='author' class='box' style='font-style: italic'>
Made by Vitaly Pavlovich Ulyanov.
</p>
<!-- Автор — Виталий Павлович Ульянов. -->
<script src='../resources/VitalLogic.js'></script>
<script>
// Elements
/** @type {HTMLSelectElement} */
let lang = document.getElementById('lang');
lang.value = localStorage.getItem('lang') ?? 'eng';
if (lang.value !== 'eng') setLanguage();
function setLanguage() {
/** @type {{
id: string,
props: {}[]
}[]} */
let elements = [];
localStorage.setItem('lang', lang.value);
switch (lang.value) {
case 'eng':
elements = [];
break;
case 'rus':
elements = [];
break;
default:
break;
}
elements.forEach((e) => {
const el = document.getElementById(e.id);
if (!el) {
console.log(`Translation error: element with ID '${e.id}' not found!`);
return;
}
for (const prop in e.props) {
el[prop] = e.props[prop];
}
});
}
</script>
</body>
</html>