Total Complexity | 2 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | // Class imports |
||
4 | |||
5 | /** |
||
6 | * Main class |
||
7 | * @property {HTMLElement} #textInput Value from text input in form. Used to add event listener for when we type text. |
||
8 | * @property {HTMLElement} #textForm Reference to form on page. Used to add event listener for form submit. |
||
9 | */ |
||
10 | class MainClass { |
||
11 | #textInput = window.document.getElementById('bilinformasjon'); |
||
12 | #textForm = window.document.getElementById('regnrform'); |
||
13 | |||
14 | /** |
||
15 | * Call the initialize method which sets up the event handlers |
||
16 | */ |
||
17 | constructor() { |
||
18 | this.initialize(); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Initialize the class and add the event handlers |
||
23 | * @return void |
||
24 | */ |
||
25 | private initialize() { |
||
26 | this.addEventHandlers(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Add the event handlers to textInput and textForm |
||
31 | * @return void |
||
32 | */ |
||
33 | private addEventHandlers() { |
||
34 | const sendForm = new classProcessInputForm(); |
||
35 | const checkValidText = new classValidText(); |
||
36 | |||
37 | this.#textInput!.addEventListener('input', checkValidText.checkValidText); |
||
38 | this.#textForm!.addEventListener('submit', sendForm.sendForm); |
||
39 | } |
||
43 |