-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
55 lines (47 loc) · 1.4 KB
/
options.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
var slider = document.getElementById('limit');
var slider_dis = document.getElementsByClassName('range-val')[0];
var fromLang = document.getElementById('fromLang');
var toLang = document.getElementById('toLang');
var languages = [
new lang("English","en"),
new lang("Geraman","de"),
new lang("Japanese","ja"),
new lang("French","fr"),
new lang("Spanish","es"),
new lang("Russian","ru"),
new lang("Chinese","zh"),
new lang("Polish","pl"),
new lang("Italian","it"),
new lang("Hindi","hi")
]
document.addEventListener("DOMContentLoaded",function(){
applySelection(languages, fromLang);
applySelection(languages, toLang);
fromLang.value= localStorage.fromLang;
toLang.value = localStorage.toLang;
slider.value = localStorage.limit;
slider_dis.innerHTML = slider.value;
});
slider.addEventListener("change", function(){
//dynamic
localStorage.limit = slider.value;
slider_dis.innerHTML = slider.value;
})
fromLang.addEventListener("change", function(){
//dynamic
localStorage.fromLang = this.value;
})
toLang.addEventListener("change", function(){
//dynamic
localStorage.toLang = this.value;
})
// custom functions
function lang(fullname, short){
this.fullname = fullname;
this.short = short;
}
function applySelection(lan, dom){
for (var i = 0; i < lan.length; i++) {
dom.innerHTML += "<option value='"+lan[i].short+"'>"+lan[i].fullname+"</option>";
}
}