-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript.js
93 lines (75 loc) · 2.68 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// JavaScript source code
var commentsHidden = false;
var classHidden = false;
var functionHidden = false;
function toggleVisibilityComments(classname) {
var elements = document.getElementsByClassName(classname);
if (commentsHidden)
commentsHidden = false;
else
commentsHidden = true;
console.log(commentsHidden);
for (var i = 0; i < elements.length; i++)
elements[i].hidden = commentsHidden;
var elementButton = document.getElementById("comments-button");
console.log(elementButton.innerHTML);
if (commentsHidden)
elementButton.innerHTML = "Show comments";
else
elementButton.innerHTML = "Hide Comments"
}
function toggleVisibilityClass(classname) {
var elements = document.getElementsByClassName(classname);
if (classHidden)
classHidden = false;
else
classHidden = true;
console.log(classHidden);
for (var i = 0; i < elements.length; i++)
elements[i].hidden = classHidden;
var elementsButton = document.getElementsByClassName("class-button");
for (var i = 0; i < elementsButton.length; i++)
if (classHidden)
elementsButton[i].innerHTML = "+";
else
elementsButton[i].innerHTML = "-"
var elementButton = document.getElementById("class-button");
console.log(elementButton.innerHTML);
if (classHidden)
elementButton.innerHTML = "Show classes";
else
elementButton.innerHTML = "Hide classes"
}
function toggleVisibilityFunction(classname) {
var elements = document.getElementsByClassName(classname);
if (functionHidden)
functionHidden = false;
else
functionHidden = true;
console.log(functionHidden);
for (var i = 0; i < elements.length; i++)
elements[i].hidden = functionHidden;
var elementsButton = document.getElementsByClassName("function-button");
for (var i = 0; i < elementsButton.length; i++)
if (functionHidden)
elementsButton[i].innerHTML = "+";
else
elementsButton[i].innerHTML = "-"
var elementButton = document.getElementById("function-button");
console.log(elementButton.innerHTML);
if (functionHidden)
elementButton.innerHTML = "Show functions";
else
elementButton.innerHTML = "Hide functions"
}
function toggleVisibilityByID(idName) {
var element = document.getElementById(idName);
console.log(element.hidden);
element.hidden = !element.hidden
var elementButton = document.getElementById(idName + "-button");
console.log(elementButton.innerHTML);
if (elementButton.innerHTML == "+")
elementButton.innerHTML = "-";
else
elementButton.innerHTML = "+"
}