-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-frontend.js
More file actions
88 lines (88 loc) · 3.01 KB
/
Copy pathscript-frontend.js
File metadata and controls
88 lines (88 loc) · 3.01 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
function buildSelect(id, list) {
var innerHTML = "";
for (var i = 0; i < list.length; i++) {
innerHTML += makeOption(
list[i].value,
list[i].description,
list[i].disabled
);
}
document.getElementById(id).innerHTML = innerHTML;
}
function makeOption(value, description, disabled) {
var option = "<option value='" + value + "'";
if (disabled) {
option += " disabled";
}
option += ">" + description + "</option>";
return option;
}
function buildGUI(item, type) {
if (type === "character") {
buildCharacterGUI(item);
} else if (type === "numeric") {
buildNumberGUI(item);
} else if (type === "words") {
recursiveCall(
function(i) {
buildCharacterGUI(
getCharItemByCharacter(item.characters.charAt(i - 1))
);
},
function() {
buildWordGUI(item);
},
1000,
1,
item.characters.length + 1,
true
);
}
}
function buildCharacterGUI(item) {
document.getElementById("main").classList.remove("small");
document.getElementById("main").classList.remove("medium");
document.getElementById("main").classList.add("large");
document.getElementById("detail1").classList.add("offset");
document.getElementById("detail2").classList.add("offset");
document.getElementById("main").innerHTML = item.character;
document.getElementById("detail1").innerHTML = item.pronunciation;
document.getElementById("detail2").innerHTML = item.example;
}
function buildNumberGUI(item) {
document.getElementById("main").classList.remove("small");
document.getElementById("main").classList.remove("large");
document.getElementById("main").classList.add("medium");
document.getElementById("detail1").classList.remove("offset");
document.getElementById("detail2").classList.remove("offset");
document.getElementById("main").innerHTML = item.characters;
document.getElementById("detail1").innerHTML = item.pronunciation;
document.getElementById("detail2").innerHTML =
item.numeric + ":" + item.english;
}
function buildWordGUI(item) {
document.getElementById("main").classList.remove("medium");
document.getElementById("main").classList.remove("large");
document.getElementById("main").classList.add("small");
document.getElementById("detail1").classList.remove("offset");
document.getElementById("detail2").classList.remove("offset");
document.getElementById("main").innerHTML = item.characters;
document.getElementById("detail1").innerHTML = getPronunciationString(
item.characters
);
document.getElementById("detail2").innerHTML = item.english;
}
function revealAnswer() {
document.getElementById("detail1").classList.remove("hidden");
document.getElementById("detail2").classList.remove("hidden");
}
function hideAnswer() {
document.getElementById("detail1").classList.add("hidden");
document.getElementById("detail2").classList.add("hidden");
}
function enableRetry() {
document.getElementById("retry").disabled = false;
}
function disableRetry() {
document.getElementById("retry").disabled = true;
}