-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
218 lines (218 loc) · 10.1 KB
/
index.js
File metadata and controls
218 lines (218 loc) · 10.1 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
function hideOptions() {
document.querySelector(".intro").style.display = "none";
document.querySelector("html").setAttribute("class", "scrollEnabled");
}
function getMonthInText(number) {
if (number == 1) {
return "January"
}
if (number == 2) {
return "February"
}
if (number == 3) {
return "March"
}
if (number == 4) {
return "April"
}
if (number == 5) {
return "May"
}
if (number == 6) {
return "June"
}
if (number == 7) {
return "July"
}
if (number == 8) {
return "August"
}
if (number == 9) {
return "September"
}
if (number == 10) {
return "October"
}
if (number == 11) {
return "November"
}
if (number == 12) {
return "December"
}
}
var oldPercentage = 0;
var newPercentage = 0;
var finish = 100;
var number = Math.floor(Math.random()*100);
var percentageUpdater;
var limit = 10;
var underPercentage = 0;
var month = getMonthInText(new Date().getMonth()+1);
var logo = document.querySelector(".logo");
var loadinglogo = document.querySelector(".loadinglogo");
var funfacts = {
regular: [
"Did you know every 165-200 earth years, Neptune will have a new year!?",
"Did you know you can go back to your childhood if you go to a different planet?",
"Did you know your age changes when you go to a planet like Neptune?",
"Did you know most likely, you might be over 100 years old if you went to Neptune?",
"Did you know FunJunk is made by Itzgametime Vip? Subscribe to him!",
"I can't think of a fun fact right now.. Please reload to find one!"
],
halloween: [
"Did you know that original jack 'o lanterns were not pumpkins?",
"Did you know wearing costumes started as a way to avoid ghosts?",
"Did you know candy corn was invented in the 1880s and was not originally a Halloween candy?",
"Did you know the average trick-or-treater consumes about 7,000 calories' worth of candy on Halloween?",
"Did you know average americans spend over $12 billion to buy candy and halloween costumes!?"
],
christmas: [
"Did you know the first artificial Christmas trees were made from goose feathers in Germany?",
"Did you know Jingle Bells was originally a Thanksgiving song?",
"Did you know Rudolph the Red-Nosed Reindeer was a marketing gimmick? Rudolph is fake!?",
"Is it a theory that Santa is fake or real!? Is he is fake, is he A LEGEND!?"
]
}
var introColors = {
regular: [
"linear-gradient(40deg, rgb(227, 109, 117), rgb(154, 223, 235))",
"linear-gradient(40deg, rgb(109, 223, 227), rgb(235, 154, 204))",
"linear-gradient(40deg, rgba(103, 4, 10, 1), rgba(154, 168, 235, 1))",
"linear-gradient(rgb(41, 41, 204), rgb(235, 154, 204))"
],
halloween: [
"linear-gradient(40deg, orange, rgba(176, 111, 6, 1))",
"linear-gradient(40deg, rgba(103, 4, 10, 1), rgba(154, 168, 235, 1))",
"linear-gradient(rgb(41, 41, 204), rgb(235, 154, 204))"
],
christmas: [
"linear-gradient(40deg, rgba(58, 202, 29, 1), darkred)",
"linear-gradient(40deg, darkred, rgba(58, 202, 29, 1)",
"linear-gradient(40deg, rgba(103, 4, 10, 1), rgba(154, 168, 235, 1))",
"linear-gradient(40deg, rgb(109, 223, 227), rgb(235, 154, 204))",
"linear-gradient(rgb(41, 41, 204), rgb(235, 154, 204))"
],
newyear: [
"linear-gradient(40deg, lightblue, blue)",
"linear-gradient(40deg, blue, darkblue)",
"linear-gradient(rgb(41, 41, 204), rgb(235, 154, 204))"
]
};
var icons = [
"icon.png",
"newicon.png"
];
var chosenIcon = icons[Math.floor(Math.random()*icons.length)];
document.querySelector(".iconImg").href = chosenIcon;
if (month == "January") {
var chosenIntroColor = introColors.newyear[Math.floor(Math.random()*introColors.newyear.length)];
var chosenIntroFact = funfacts.regular[Math.floor(Math.random()*funfacts.regular.length)];
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector("#titleEventSponsor").innerHTML = "Use FunJunk as your default playtime app:";
document.querySelector("#imgEventSponsor").src = "./banners/defaultplaysource.png";
document.querySelector("#descEventSponsor").innerHTML = "Make FunJunk your default playtime app by installing it!";
document.querySelector("#linkEventSponsor").href = "./link/frombanner/defaultplaytimeapp.html";
logo.src = "logo.png";
loadinglogo.src = "logo.png";
}
else if (month == "October") {
var chosenIntroColor = introColors.halloween[Math.floor(Math.random()*introColors.halloween.length)];
var chosenIntroFact = funfacts.halloween[Math.floor(Math.random()*funfacts.halloween.length)];
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector("#titleEventSponsor").innerHTML = "Is there something fun to do on FunJunk in Halloween?";
document.querySelector("#imgEventSponsor").src = "./banners/halloween.png";
document.querySelector("#descEventSponsor").innerHTML = "Yes! You absolutely can! Click the link down below to start:";
document.querySelector("#linkEventSponsor").href = "./link/frombanner/halloween.html";
logo.src = "halloweenLogoVariant.png";
loadinglogo.src = "halloweenLogoVariant.png";
}
else if (month == "November") {
var chosenIntroColor = introColors.christmas[Math.floor(Math.random()*introColors.christmas.length)];
var chosenIntroFact = funfacts.christmas[Math.floor(Math.random()*funfacts.christmas.length)];
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector("#titleEventSponsor").innerHTML = "Is there something fun to do while we wait for Christmas?";
document.querySelector("#imgEventSponsor").src = "./banners/christmasBanner.png";
document.querySelector("#descEventSponsor").innerHTML = "Yes! You absolutely can! Click the link down below to start (Ho Ho Ho):";
document.querySelector("#linkEventSponsor").href = "./link/frombanner/christmas.html";
logo.src = "christmasLogoVariant.png";
loadinglogo.src = "christmasLogoVariant.png";
}
else if (month == "December") {
var chosenIntroColor = introColors.christmas[Math.floor(Math.random()*introColors.christmas.length)];
var chosenIntroFact = funfacts.christmas[Math.floor(Math.random()*funfacts.christmas.length)];
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector("#titleEventSponsor").innerHTML = "Is there something fun to do while we wait for Christmas?";
document.querySelector("#imgEventSponsor").src = "./banners/christmasBanner.png";
document.querySelector("#descEventSponsor").innerHTML = "Yes! You absolutely can! Click the link down below to start (Ho Ho Ho):";
document.querySelector("#linkEventSponsor").href = "./link/frombanner/christmas.html";
logo.src = "christmasLogoVariant.png";
loadinglogo.src = "christmasLogoVariant.png";
}
else {
var chosenIntroColor = introColors.regular[Math.floor(Math.random()*introColors.regular.length)];
var chosenIntroFact = funfacts.regular[Math.floor(Math.random()*funfacts.regular.length)];
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector(".funfact").innerHTML = chosenIntroFact;
document.querySelector("#titleEventSponsor").innerHTML = "Use FunJunk as your default playtime app:";
document.querySelector("#imgEventSponsor").src = "./banners/defaultplaysource.png";
document.querySelector("#descEventSponsor").innerHTML = "Make FunJunk your default playtime app by installing it!";
document.querySelector("#linkEventSponsor").href = "./link/frombanner/defaultplaytimeapp.html";
logo.src = "logo.png";
loadinglogo.src = "logo.png";
}
document.querySelector(".intro").style.background = chosenIntroColor;
document.body.style.background = chosenIntroColor;
function updatePercentage() {
percentageUpdater = setInterval(() => {
number = Math.floor(Math.random()*101);
if (number >= newPercentage) {
newPercentage = number;
document.querySelector(".percentage").innerHTML = newPercentage + "%";
finished();
} else if (newPercentage == finish) {
finished();
} else {
underPercentage += 1;
if (underPercentage == limit) {
newPercentage += 1;
underPercentage = 0;
document.querySelector(".percentage").innerHTML = newPercentage + "%";
}
}
}, 150);
}
function finishedAction(action) {
action();
}
function finished() {
if (newPercentage == finish) {
clearInterval(percentageUpdater);
console.log(newPercentage);
finishedAction(() => {
document.querySelector(".intro").style.display = "flex";
document.querySelector(".intro").style.opacity = 0;
setTimeout(hideOptions, 2500);
});
}
}
updatePercentage();
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js')
.then((reg) => {
console.log('Service worker registered:', reg);
})
.catch((error) => {
console.error('Service worker registration failed:', error);
});
});
}
var menu = document.querySelector(".menu");
var closeBtnMenu = menu.querySelector(".close");
var options = document.querySelector(".options");
options.addEventListener("click", () => {
menu.setAttribute("style", "position: fixed; top: 0; left: 0;");
});
closeBtnMenu.addEventListener("click", () => {
menu.setAttribute("style", "position: fixed; top: 0; left: 100%;");
});