Repository navigation
Expand file tree
/
Copy pathprocessing.js
More file actions
89 lines (89 loc) · 3.2 KB
/
Copy pathprocessing.js
File metadata and controls
89 lines (89 loc) · 3.2 KB
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
83
84
85
86
87
88
89
var total = 0;
var current = 0;
function loadcounter() {
const per = Math.round((current / total) * 100);
document.getElementById("counter").innerHTML = current.toString() + "/" + total.toString() + " books (" + per + "%)"
}
function activate(id) {
if (document.getElementById(id).checked == true){
current += 1;
loadcounter();
localStorage.setItem(id, true)
} else {
current -= 1;
loadcounter();
localStorage.setItem(id, false)
}
}
function changetheme() {
const currenttheme = localStorage.getItem("theme");
if (currenttheme == "dark") {
localStorage.setItem("theme", "light")
const allElements = document.querySelectorAll('*')
allElements.forEach(element => {
element.style.color = "black";
});
document.body.style.backgroundColor = "white"
document.getElementById("theme").style.color = 'rgb(64, 64, 255)';
} else {
localStorage.setItem("theme", "dark")
const allElements = document.querySelectorAll('*')
allElements.forEach(element => {
element.style.color = "white";
});
document.body.style.backgroundColor = "black"
document.getElementById("theme").style.color = 'rgb(64, 64, 255)';
}
}
async function load() {
const currenttheme = localStorage.getItem("theme");
if (currenttheme == "dark") {
const allElements = document.querySelectorAll('*')
allElements.forEach(element => {
element.style.color = "white";
});
document.body.style.backgroundColor = "black"
document.getElementById("theme").style.color = 'rgb(64, 64, 255)';
} else {
const allElements = document.querySelectorAll('*')
allElements.forEach(element => {
element.style.color = "black";
});
document.body.style.backgroundColor = "white"
document.getElementById("theme").style.color = 'rgb(64, 64, 255)';
}
let id = 0;
const res = await fetch('./data.json');
const json = await res.json();
const serieslength = (json.children.length) - 1;
for (let s = 0; s <= serieslength; s++) {
const header = document.createElement("label");
header.innerHTML = "<h2>[" + json.children[s].name + "]</h2>";
document.body.appendChild(header);
const length = await (json.children[s].children.length) - 1;
for (let i = 0; i <= length; i++) {
total += 1;
const checkbox = document.createElement("input");
const label = document.createElement("label");
const div = document.createElement("div");
checkbox.type = "checkbox";
checkbox.id = id.toString();
label.innerHTML = "<h3 style='display:inline-block;'>" + json.children[s].children[i].name + "</h3>";
label.appendChild(checkbox);
div.appendChild(label);
header.appendChild(div);
label.style.display = "inline-block";
checkbox.style.display = "inline-block";
if (localStorage.getItem(id) == "true"){
current += 1;
checkbox.checked = true;
}
checkbox.onclick = function() {
activate(checkbox.id);
}
id += 1;
}
}
loadcounter();
}
document.addEventListener('DOMContentLoaded', load)