blob: 518406c6a8529f76e99dd77cd5b1cfa1f724a25f (
plain) (
blame)
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
90
91
92
93
94
95
96
|
document.addEventListener("DOMContentLoaded", () => {
pripraviDokument();
});
function pripraviDokument() {
var data;
try {
data = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
} catch (e) {
data = {vpr: []};
}
var el = document.getElementById("vpr");
el.innerHTML = "";
for (const vpr of data.vpr) {
var vprdiv = document.createElement("div");
vprdiv.classList = "vpr";
if (window.location.pathname.endsWith("priprava.html")) {
vprdiv.innerText = vpr.v+" ";
var odg = document.createElement("input");
odg.dataset.odg = vpr.o;
var odgspan = document.createElement("span");
odgspan.hidden = true;
odgspan.classList = "odgspan";
odgspan.innerText = " "+vpr.o;
vprdiv.appendChild(odg);
vprdiv.appendChild(odgspan);
} else {
var vprinput = document.createElement("input");
vprinput.value = vpr.v;
vprinput.onchange = naredichange;
var odg = document.createElement("input");
odg.value = vpr.o;
odg.onchange = naredichange;
vprdiv.appendChild(vprinput);
vprdiv.appendChild(odg)
}
el.appendChild(vprdiv);
}
if (window.location.pathname.endsWith("priprava.html")) {
document.getElementById("naredilink").href =
"naredi.html"+window.location.hash;
} else {
naredichange();
}
}
function preveri() {
var el = document.getElementById("stat");
var els = document.getElementsByClassName("vpr");
var richtig = 0;
var falsch = 0;
for (const vpr of els) {
var odg = vpr.children[0];
if (odg.dataset.odg.toLowerCase() == odg.value.toLowerCase()) {
odg.classList = "richtig";
richtig++;
} else {
odg.classList = "falsch";
falsch++;
}
}
el.innerText = richtig + "/" + (richtig+falsch) + " pravilnih";
}
function pokaziskrij() {
var els = document.getElementsByClassName("odgspan");
for (const el of els) {
el.hidden = !el.hidden;
}
}
function dodaj() {
var vprs = document.getElementById("vpr");
var div = document.createElement("div");
div.classList = "vpr";
var vpr = document.createElement("input");
vpr.onchange = naredichange;
var odg = document.createElement("input");
odg.onchange = naredichange;
div.appendChild(vpr);
div.appendChild(odg);
vprs.appendChild(div);
}
function naredichange() {
var vprs = document.getElementById("vpr").children;
data = {vpr: []};
for (const vpr of vprs) {
vprobj = {
v: vpr.children[0].value,
o: vpr.children[1].value
}
data.vpr.push(vprobj);
}
var datastr = (JSON.stringify(data));
document.getElementById("urejevalnik").href = "#"+datastr;
document.getElementById("vprasalnik").href = "priprava.html#"+datastr;
window.location.hash = "#"+datastr;
}
|