-
Notifications
You must be signed in to change notification settings - Fork 1
/
section-01.html
47 lines (44 loc) · 1.15 KB
/
section-01.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="./main.css" rel="stylesheet">
</head>
<body>
<form>
<label for="input">Input</label>
<textarea id="input" rows="2"></textarea>
<button id="submit" type="button">Submit</button>
<hr>
<label>Output</label>
<pre id="output"></pre>
</form>
</body>
<script>
/*
We're organising all the keyboard logic into a single 'KeyboardApp'.
*/
class KeyboardApp {
constructor () {
// Let's register all the HTML elements to make them easier to access later.
this.html = {
input: document.getElementById('input'),
submit: document.getElementById('submit'),
output: document.getElementById('output'),
}
// Let's register all the event handling
this.html.submit.onclick = this.submit.bind(this)
}
/*
This 'submit' logic is just placeholder for what you actually want to do.
Normally, this is where we'd submit the input data to a server. For our
example, we just print the text into the output field.
*/
submit () {
const text = input.value
output.innerText = text
}
}
var app = new KeyboardApp() // Let's start the app!
</script>
</html>