-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
71 lines (60 loc) · 1.59 KB
/
script.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
var checkboxValues = JSON.parse(localStorage.getItem("checkboxValues"));
if (checkboxValues === null){
checkboxValues = {};
};
console.log(checkboxValues);
$(document).on("change", "input[type='checkbox']", function () {
$.each($("input[type='checkbox']"), function(){
checkboxValues[this.id] = $("#" + this.id).is(':checked');
});
localStorage.setItem("checkboxValues", JSON.stringify(checkboxValues));
console.log(checkboxValues);
});
var selectedLang = localStorage.getItem("selectedLang");
if (selectedLang === null){
selectedLang = "en";
};
$(document).on("change", "select[id='lang']", function () {
var selectedLang = $(this).children("option:selected").val();
changeText(selectedLang);
});
var changeText = function(lang) {
selectedLang = lang;
$("select[id='lang']").val(selectedLang);
if (selectedLang == "en") {
$(".en").show();
$(".de").hide();
$(".es").hide();
$(".fr").hide();
};
if (selectedLang == "de") {
$(".en").hide();
$(".de").show();
$(".es").hide();
$(".fr").hide();
};
if (selectedLang == "es") {
$(".en").hide();
$(".de").hide();
$(".es").show();
$(".fr").hide();
};
if (selectedLang == "fr") {
$(".en").hide();
$(".de").hide();
$(".es").hide();
$(".fr").show();
};
console.log(selectedLang);
localStorage.setItem("selectedLang", selectedLang);
};
$(window).on("load", function() {
$.each(checkboxValues, function(key, value) {
$("#" + key).prop("checked", value);
});
changeText(selectedLang);
});
var reset = function() {
location.reload();
localStorage.clear();
};