-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
116 lines (103 loc) · 3.01 KB
/
functions.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function meow() {
// Get the snackbar DIV
var x = document.getElementById("snackbar");
// Add the "show" class to DIV
x.className = "show";
// After 3 seconds, remove the show class from DIV
setTimeout(function () {
x.className = x.className.replace("show", "");
}, 3000);
}
function clickCounter() {
clicks += 1;
document.getElementById("clicks").innerHTML = "Clicks: " + clicks;
}
function calculateAmountinTime() {
document.getElementById("output1").innerHTML = "";
var x = document.getElementById("cps").value;
var y = document.getElementById("time").value;
if (x == "" || y == "") {
document.getElementById("output1").innerHTML = "";
noValue();
} else {
var timeformat = "";
let formatvar = "";
let format = document.forms[0];
let i;
for (i = 0; i < format.length; i++) {
if (format[i].checked) {
formatvar = formatvar + format[i].value + "";
}
}
console.log(formatvar);
timeformat = formatvar;
if (timeformat == "seconds") {
document.getElementById("output1").innerHTML =
"You will make " + (z = x * y) + " cookies in " + y + " seconds!";
console.log("1 run succ");
return;
} else if (timeformat == "minutes") {
document.getElementById("output1").innerHTML =
"You will make " + (z = x * 60 * y) + " cookies in " + y + " minutes!";
console.log("2 run succ");
return;
} else if (timeformat == "hours") {
z = x * 60;
z = z * 60;
document.getElementById("output1").innerHTML =
"You will make " + z + " cookies in " + y + " hours!";
console.log("3 run succ");
return;
}
}
}
function calculateTimeforAmount() {
var x = document.getElementById("cps2").value;
var y = document.getElementById("amount").value;
if (x == "" || y == "") {
document.getElementById("output2").innerHTML = "";
noValue();
} else {
z = y / x;
console.log(z);
var z = Number(z);
var h = Math.floor(z / 3600);
var m = Math.floor((z % 3600) / 60);
var s = Math.floor((z % 3600) % 60);
console.log(h);
console.log(m);
console.log(s);
document.getElementById("output2").innerHTML =
"It will take " +
("0" + h).slice(-2) +
"hr " +
("0" + m).slice(-2) +
"min " +
("0" + s).slice(-2) +
"sec " +
" to make " +
y +
" cookies at " +
x +
" cookies per second!";
}
}
function noValue() {
var x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function () {
x.className = x.className.replace("show", "");
}, 3000);
}
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}