-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·121 lines (102 loc) · 3.25 KB
/
Copy pathmain.js
File metadata and controls
executable file
·121 lines (102 loc) · 3.25 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
118
119
120
121
var clear = 0
var anOrCount = 0;
function ratio(start, until, ratio) {
if (clear === 1) {
var container = document.querySelector("#clone-here");
var clones = document.querySelectorAll(".clone-this");
var clonesLeng = clones.length;
var delCount = 1;
while (delCount <= clonesLeng - 1) {
container.removeChild(clones[delCount]);
delCount++;
}
clear = 0;
}
clear++;
var divStart = document.querySelector("#start");
var divUntil = document.querySelector("#until");
var divRatio = document.querySelector("#ratio");
divStart.innerHTML = start;
divUntil.innerHTML = until;
var divColor = '#FFFFEF'
divStart.style.color = divColor;
divUntil.style.color = divColor;
divRatio.style.color = divColor;
function onScreen() {
var container = document.querySelector('#clone-here');
var clone = document.querySelectorAll('.clone-this');
var newClone = clone[clone.length - 1].cloneNode(true);
newClone.classList.remove('hidden');
container.appendChild(newClone);
var printCount = document.querySelectorAll('.printCount');
var printStart = document.querySelectorAll('.printStart');
var newPrintCount = printCount[printCount.length - 1];
var newPrintStart = printStart[printStart.length - 1];
newPrintStart.innerHTML = start;
newPrintCount.innerHTML = count;
}
var count = anOrCount;
if (start <= until) {
divRatio.innerHTML = "+"+ratio;
while (start <= until) {
onScreen();
start += ratio;
count++;
}
} else {
divRatio.innerHTML = "-"+ratio;
while (start >= until) {
onScreen();
start -= ratio;
count++;
}
}
}
function callPrompt() {
var startValue = prompt("Valor inicial:");
var untilValue = prompt("Valor final:");
var ratioValue = prompt("Razão:");
var arrayPromp = [startValue, untilValue, ratioValue];
var arrayAbc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "ç"];
var txt = "🛑 Insira apenas valores numéricos! 🛑";
if ((startValue === "") || (untilValue === "") || (ratioValue === ""))
alert(txt);
else if ((startValue === null) || (untilValue === null) || (ratioValue === null))
alert(txt);
else if (ratioValue == 0)
alert("🛑 A razão não pode ser \"0\". 🛑")
else {
var prompLeng = arrayPromp.length;
var prompCount = 0;
while (prompCount < prompLeng) {
var abcLeng = arrayAbc.length;
var abcCount = 0;
while (abcCount < abcLeng) {
var verify = arrayPromp[prompCount].indexOf(arrayAbc[abcCount]);
if (verify >= 0) {
alert(txt);
prompCount = 9 * 99999;
break;
} else
abcCount++;
}
if (prompCount === prompLeng - 1) {
startValue = +startValue;
untilValue = +untilValue;
ratioValue = +ratioValue;
ratio(startValue, untilValue, ratioValue);
break;
}
prompCount++;
}
}
}
const active = document.querySelector('.term-or-count');
active.addEventListener('click', () => {
active.classList.toggle('active');
if (active.classList.contains('active')) {
anOrCount = 1;
} else {
anOrCount = 0;
}
});