Passed
Pull Request — master (#36)
by
unknown
01:55
created

MainClass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A initialize 0 7 1
A addEventHandlers 0 11 1
1
// Class imports
2
import classValidText from './classes/ValidText/classValidText';
3
import classProcessInputForm from './classes/ProcessInputForm/classProcessInputForm';
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
  }
40
}
41
42
const Main = new MainClass();
43