-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
57 lines (48 loc) · 1.55 KB
/
code.js
File metadata and controls
57 lines (48 loc) · 1.55 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
var n;
var textColor;
var emColor;
function start() {
n = document.getElementById("sonnetNumber").value - 1;
document.getElementById("sonnet").innerHTML = sonnets[n];
buttons();
}
function buttons() {
textColor = getComputedStyle(document.getElementById("wordList")).getPropertyValue("--text");
emColor = getComputedStyle(document.getElementById("emEx")).getPropertyValue("--em");
// create a button for each possible avion of the chosen sonnet
var buttons = [];
var len = (words[n]).length;
for(let i = 0; i < len; i++) {
var w = words[n][i];
buttons.push(
"<tr><td><button id = " + i + " onclick='show(" + i + ")'>" + w + "</button></td></tr>"
)
};
buttons = "<div class='scroll'><table>" + buttons.join("") + "</table><div>"
document.getElementById("wordList").innerHTML = buttons;
document.getElementById("wordCount").innerHTML = "(" + len + ")";
show(0);
}
function show(i) {
// color selected button
for( b of [...document.getElementsByTagName("button")] ){
b.style = "color: " + textColor + "; font-weight: normal"
};
document.getElementById(i + "").style = "color: " + emColor + "; font-weight: bold";
// color avion letters in sonnet text
sonnet = sonnets[n].split("");
for (j of indexes[n][i]) {
sonnet[j] = "<em>" + (sonnet[j]).toUpperCase() + "</em>";
};
document.getElementById("sonnet").innerHTML = sonnet.join("");
}
/////// tooltip ///////
var ttQ = false;
function tt() {
ttQ = !ttQ;
if (ttQ) {
document.getElementById("tt").style.display = "block";
} else {
document.getElementById("tt").style.display = "none";
}
}