-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
238 lines (216 loc) · 7.13 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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vokabeltrainer</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/>
<style>
.main-container {
margin: 10px 50px 0 50px;
}
body {
font-weight: 600;
}
h1 {
text-align: center;
}
.vokabel {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20px 0;
}
.vokabel input {
flex-grow: 1;
margin-right: 10px;
}
.vokabel button {
background-color: blue;
color: white;
padding: 5px 10px;
border: none;
cursor: pointer;
}
.vokabel button:hover {
background-color: darkblue;
}
.result {
margin: 20px 0;
}
.footer {
margin: 20% 50px 0 50px;
display: flex;
gap: 10px;
}
.footer a {
color: black;
}
@media (screen) and (max-width: 768px) {
.input-style {
width: 200px;
}
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Vokabeltrainer</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a
class="nav-link active"
aria-current="page"
href="https://webdeveloper438.github.io"
>Home</a
>
</li>
<li class="nav-item">
<a class="nav-link" href="vokabeln.json">Vokabelliste</a>
</li>
<li class="nav-item">
<a
class="nav-link"
href="https://static.tomiak.eu/docs/vokabeltrainer-dokumentation.pdf"
>Dokumentation</a
>
</li>
</ul>
</div>
</div>
</nav>
<div class="main-container">
<h5>Sprache: Englisch</h5>
<h6>Vokabeln für: 20.03.2024 | S. 160 'drum' - S. 162 'move'</h6>
<p>
Bitte beachte: Die Vokabeln werden ohne jegliche Sonderbuchstaben
abgefragt (s. Vokabelliste)
</p>
<div id="vokabel-container"></div>
<div class="result"></div>
<button onclick="test()" class="btn btn-primary">Prüfen</button>
<button onclick="skip()" class="btn btn-secondary">Überspringen</button>
</div>
<div class="footer">
<p>© 2024 <a href="https://tomiak.eu">F. Tomiak</a></p>
<p>Dieses Projekt befindet sich in der Betaphase.</p>
<p>Version: 2.3.5</p>
<button class="btn btn-secondary" onclick="refresh()">Aktualisieren</button>
</div>
<script>
const vokabelContainer = document.getElementById("vokabel-container");
const result = document.querySelector(".result");
const input = document.createElement("input");
function loadVokabeln() {
return fetch("vokabeln.json")
.then((response) => response.json())
.then((vokabeln) => vokabeln);
}
let currentVokabel = {};
function showVokabel() {
const vokabelDeutsch = document.createElement("div");
vokabelDeutsch.textContent = currentVokabel.deutsch;
vokabelDeutsch.classList.add("vokabel");
input.type = "text";
input.placeholder = "Übersetzung eingeben...";
input.style.width = "400px";
input.classList.add("form-control");
// Define the media query
const mediaQuery = window.matchMedia("(max-width: 768px)");
// Define the callback function
const updateElementWidth = () => {
if (mediaQuery.matches) {
input.style.width = "300px";
} else {
input.style.width = "";
}
};
// Add the callback function to the media query
mediaQuery.addListener(updateElementWidth);
// Initial call to update the element width
updateElementWidth();
const vokabelEnglisch = document.createElement("div");
vokabelEnglisch.textContent = currentVokabel.englisch;
vokabelEnglisch.classList.add("vokabel");
vokabelContainer.innerHTML = "";
vokabelContainer.appendChild(vokabelDeutsch);
vokabelContainer.appendChild(input);
}
function test() {
if (input.value.length >= 1) {
if (
currentVokabel.englisch === document.querySelector("input").value
) {
result.textContent = "Richtig!";
setTimeout(
//create a timer that will clear the text after 2 seconds
function () {
//Blackbox Function
result.textContent = "";
},
2000
);
loadVokabeln().then((newVokabel) => {
currentVokabel =
newVokabel[Math.floor(Math.random() * newVokabel.length)];
console.log(currentVokabel);
showVokabel();
});
result.style.color = "green";
input.value = "";
} else {
result.textContent = `Falsch! Die richtige Vokabel ist: ${currentVokabel.englisch}`;
setTimeout(function () {
result.textContent = "";
}, 2000);
result.style.color = "red";
input.value = "";
}
} else {
result.textContent = "Bitte gebe etwas ein!";
setTimeout(function () {
result.textContent = "";
}, 2000);
result.style.color = "red";
}
}
loadVokabeln().then((vokabeln) => {
currentVokabel = vokabeln[Math.floor(Math.random() * vokabeln.length)];
showVokabel();
});
function skip() {
loadVokabeln().then((vokabeln) => {
currentVokabel =
vokabeln[Math.floor(Math.random() * vokabeln.length)];
showVokabel();
});
}
function refresh() {
location.reload(true);
}
</script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"
></script>
</body>
</html>