-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocks.js
More file actions
117 lines (101 loc) · 2.97 KB
/
blocks.js
File metadata and controls
117 lines (101 loc) · 2.97 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
function toggle(el){
if(el.value=='-')
{
el.value='+';
el.parentElement.nextElementSibling.style.display='none';
}
else
{
el.value='-';
el.parentElement.nextElementSibling.style.display='block';
}
}
function toggleAll(btn){
if(btn.value=='-')
btn.value="+"
else
btn.value="-";
var elements = document.getElementsByTagName('input');
for (var i = 0; i < elements.length;i++) {
if (elements[i].type="button")
toggle(elements[i]);
}
}
function AddToggleButtons(){
var childDivs = document.getElementsByTagName('h2');
for( i=0; i< childDivs.length; i++ )
{
var childDiv = childDivs[i];
const para = document.createElement("input");
para.setAttribute("value","-");
para.setAttribute("type","button");
para.setAttribute("onclick","toggle(this)");
para.setAttribute("class","toggleButton");
childDiv.prepend(para);
}
}
function AddToggleButtonsToH2andH3(){
for(j=2;j<=3;j++)
{
var childDivs = document.getElementsByTagName('h'+j.toString());
for( i=0; i< childDivs.length; i++ )
{
var childDiv = childDivs[i];
const para = document.createElement("input");
para.setAttribute("value","-");
para.setAttribute("type","button");
para.setAttribute("onclick","toggle(this)");
para.setAttribute("class","toggleButton");
childDiv.prepend(para);
}
}
}
// you can use the next function by 'then': ReplaceLtGt().then(f2);
function ReplaceLtGt() {
return new Promise((resolve, reject) => {
len = $("code").length;
for (i = 0; i < len; i++) {
if ($("code").eq(i)[0] == undefined) return;
s = $("code").eq(i)[0].innerHTML
//s=s.replaceAll("<"," < ")
s = s.replaceAll("<", "<")
//s=s.replaceAll(">",">")
//s=s.replaceAll("&","&")
$("code").eq(i).innerHTML=s
resolve();
}
});
}
//n can be 3 or 4
function AddToggleButtonsToH(n){
for(j=2;j<=n;j++)
{
var childDivs = document.getElementsByTagName('h'+j.toString());
for( i=0; i< childDivs.length; i++ )
{
var childDiv = childDivs[i];
const para = document.createElement("input");
para.setAttribute("value","-");
para.setAttribute("type","button");
para.setAttribute("onclick","toggle(this)");
para.setAttribute("class","toggleButton");
childDiv.prepend(para);
}
}
}
function FontSizeIncrease() {
var paragraphs = document.getElementsByTagName("p");
for (var i = 0; i < paragraphs.length; i++) {
var fontSize = window.getComputedStyle(paragraphs[i], null).getPropertyValue("font-size");
var currentSize = parseFloat(fontSize);
paragraphs[i].style.fontSize = (currentSize + 1) + "px";
}
}
function FontSizeDecrease() {
var paragraphs = document.getElementsByTagName("p");
for (var i = 0; i < paragraphs.length; i++) {
var fontSize = window.getComputedStyle(paragraphs[i], null).getPropertyValue("font-size");
var currentSize = parseFloat(fontSize);
paragraphs[i].style.fontSize = (currentSize -1) + "px";
}
}