-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
82 lines (65 loc) · 2.56 KB
/
config.js
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
const config_store_key = 'afu_test_config'
const config_test_select_id = 'test_select'
const config_print_avoid_page_break = 'print_no_page_break'
const config_print_more_margin = 'print_more_margin'
class Config {
_config = {
current_test: 'V', // default "Vorschriften"
print_avoid_page_break: false,
print_more_margin: false
}
store() {
localStorage.setItem(config_store_key, JSON.stringify(this._config))
}
load() {
let config_str = localStorage.getItem(config_store_key)
if (config_str) {
let conf = JSON.parse(config_str)
if (conf) this._config = conf
}
}
get current_test() {
return this._config.current_test
}
set current_test(test) {
this._config.current_test = test
}
_selectElement(id, valueToSelect) {
let element = document.getElementById(id);
element.value = valueToSelect;
}
set_test_select_option(test) {
this._selectElement(config_test_select_id,test)
}
apply_print_avoid_page_break() {
let element = document.getElementById(config_print_avoid_page_break)
element.checked = this._config.print_avoid_page_break
document.getElementById("questions").classList.remove('avoid_break')
if (this._config.print_avoid_page_break) document.getElementById("questions").classList.add('avoid_break')
}
apply_print_more_margin() {
let element = document.getElementById(config_print_more_margin)
element.checked = this._config.print_more_margin
document.getElementById("questions").classList.remove('more_margin')
if (this._config.print_more_margin) document.getElementById("questions").classList.add('more_margin')
}
apply_print_options() {
this.apply_print_avoid_page_break()
this.apply_print_more_margin()
}
change_print_avoid_page_break() {
let element = document.getElementById(config_print_avoid_page_break)
let avoid_break = element.checked
if (avoid_break) this._config.print_avoid_page_break = true; else this._config.print_avoid_page_break = false;
this.store()
this.apply_print_avoid_page_break()
}
change_print_more_margin() {
let element = document.getElementById(config_print_more_margin)
let more_margin = element.checked
if (more_margin) this._config.print_more_margin = true; else this._config.print_more_margin = false;
this.store()
this.apply_print_more_margin()
}
}
export { Config }