-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathscript.js
More file actions
299 lines (279 loc) · 10.9 KB
/
script.js
File metadata and controls
299 lines (279 loc) · 10.9 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
let today = new Date();
let turkeyDay = new Date(today.getFullYear(), 10, 1);
turkeyDay.setDate(turkeyDay.getDate() + (4 - turkeyDay.getDay()) % 7 + 21); // find 4th Thursday
let flakes = [];
let flakesTotal = 2 + today.getDate() * 4;
let wind = Math.random() - .5;
let isSnowEnabled = false;
// let mouseX;
// let mouseY;
//let clickcount = 0;
// if (today.getMonth() + 1 == 10 && today.getDate() >= 15) {
// spookySeason();
// } else if (today.getMonth() + 1 == 11 && today <= turkeyDay) {
// turkeySeason();
// } else if (today.getMonth() + 1 == 12 && today.getDate() <= 24) {
// snowSeason();
// }
if (today.getMonth() + 1 == 10) {
spookySeason();
} else if (today.getMonth() + 1 == 11) {
turkeySeason();
} else if (today.getMonth() + 1 == 12) {
snowSeason();
}
// <!-- Spooky stuff begins -->
function spookySeason() {
console.log("🎃");
document.body.style.background = "#000000";
document.body.style.background = choice([
"#001100",
"#002200",
"#003300",
"#110011",
"#112200",
"#112211",
"#152511",
"#152515",
"#220022",
"#221122",
"#221525",
"#223322",
"#251125",
"#251522",
"#330000",
"#330033",
"#331111",
"#331133",
"#332233",
"#333300",
"#333311",
"#993300"
]);
const emojis = ["👻","🎃","👻","🎃","👻","🎃","👻","🎃","😱","👹","🧛","🦇","🕸","🧟","👺","🕷️","🍫","🍬","🍭","🤡","🦉","🐈⬛","👿","😈","👽"];
const h1Array = document.getElementsByTagName("h1");
const h2Array = document.getElementsByTagName("h2");
const h3Array = document.getElementsByTagName("h3");
const h4Array = document.getElementsByTagName("h4");
const letters = "ABCDEF";
const anchorArray = document.getElementsByTagName("a");
for (let i = 0; i < anchorArray.length; i++) {
if (!anchorArray[i].classList.contains("nav-link") && !anchorArray[i].classList.contains("navbar-brand") && Math.random() + Math.random() > 15 / today.getDate()) {
anchorArray[i].innerHTML = choice(emojis) + " " + anchorArray[i].innerHTML + " " + choice(emojis);
}
}
setInterval(() => {
for (let i = 0; i < h1Array.length; i++) {
if (Math.random() + Math.random() > 31 / today.getDate()) {
anchorArray[i].style.transition = "all 2s";
anchorArray[i].style.marginLeft = Math.floor(Math.random() * today.getDate()*2) + "px";
anchorArray[i].style.color = "#" + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)];
}
}
for (let i = 0; i < h1Array.length; i++) {
if (Math.random() + Math.random() > 24 / today.getDate()) {
h1Array[i].style.transition = "all 2s";
h1Array[i].style.marginLeft = Math.floor(Math.random() * today.getDate()*2) + "px";
h1Array[i].style.color = "#" + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)];
}
}
for (let i = 0; i < h2Array.length; i++) {
if (Math.random() + Math.random() > 17 / today.getDate()) {
h2Array[i].style.transition = "all 2s";
h2Array[i].style.marginLeft = Math.floor(Math.random() * today.getDate()*2) + "px";
h2Array[i].style.color = "#" + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)];
}
}
for (let i = 0; i < h3Array.length; i++) {
if (Math.random() + Math.random() > 10 / today.getDate()) {
h3Array[i].style.transition = "all 2s";
h3Array[i].style.marginLeft = Math.floor(Math.random() * today.getDate()*2) + "px";
h3Array[i].style.color = "#" + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)];
}
}
for (let i = 0; i < h4Array.length; i++) {
if (Math.random() + Math.random() > 3 / today.getDate()) {
h4Array[i].style.transition = "all 2s";
h4Array[i].style.marginLeft = Math.floor(Math.random() * today.getDate()*2) + "px";
h4Array[i].style.color = "#" + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)] + letters[Math.floor(Math.random() * 6)];
}
}
}, parseInt(150000/today.getDate()));
}
// <!-- Spooky stuff ends -->
// <!-- Turkey stuff begins -->
function choice(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function turkeySeason() {
console.log("🦃");
let emojis = ["😋", "😋", "😋", "🦃", "🦃", "🦃", "🦃", "🍗", "🥧", "🥧", "🥧", "🥧", "🍂", "🍂", "🍂", "🍂", "🍃", "🍃", "🍃", "🎑", "🎑", "🎑", "🌇", "🌇", "🌇", "🍁", "🍁", "🍁", "🍁", "🌽", "🌽", "🌽", "🎩", "🎩", "🎩", "🎈", "🎈", "🎈", "🏈", "🏈", "🏈", "🎉", "🎉", "🎉", "🍞", "🤤", "🤤", "🤤", "🥔", "🥔", "🥔", "🥕", "🥕", "🥕", "🏡", "🏡", "🏡", "🧣", "🧣", "🧣", "🍴", "🍴", "🍴", "☕", "☕", "☕", "🧤", "🧤", "🧤", "🍽️", "🍽️", "🍽️", "🏫", "💯", "👨🏫"];
// These don't work?! "🍽️","🍽️","🍽️"
let h1Array = document.getElementsByTagName("h1");
let h2Array = document.getElementsByTagName("h2");
let h3Array = document.getElementsByTagName("h3");
let h4Array = document.getElementsByTagName("h4");
let anchorArray = document.getElementsByTagName("a");
for (let i = 0; i < anchorArray.length; i++) {
if (!anchorArray[i].classList.contains("nav-link") && !anchorArray[i].classList.contains("navbar-brand") && Math.random() + Math.random() > 16 / today.getDate()) {
anchorArray[i].innerHTML = choice(emojis) + " " + anchorArray[i].innerHTML + " " + choice(emojis);
}
}
for (let i = 0; i < h1Array.length; i++) {
if (Math.random() + Math.random() > 24 / today.getDate()) {
h1Array[i].innerHTML = choice(emojis) + " " + h1Array[i].innerHTML + " " + choice(emojis);
}
}
for (let i = 0; i < h2Array.length; i++) {
if (Math.random() + Math.random() > 20 / today.getDate()) {
h2Array[i].innerHTML = choice(emojis) + " " + h2Array[i].innerHTML + " " + choice(emojis);
}
}
for (let i = 0; i < h3Array.length; i++) {
if (Math.random() + Math.random() > 16 / today.getDate()) {
h3Array[i].innerHTML = choice(emojis) + " " + h3Array[i].innerHTML + " " + choice(emojis);
}
}
for (let i = 0; i < h4Array.length; i++) {
if (Math.random() + Math.random() > 12 / today.getDate()) {
h4Array[i].innerHTML = choice(emojis) + " " + h4Array[i].innerHTML + " " + choice(emojis);
}
}
}
// <!-- Turkey day stuff ends -->
// <!-- Snow stuff begins -->
// snow stuff
// add div to body
// <!-- <div id="snow">
// <label class="switch">
// <input id="snowCheckbox" type="checkbox" onclick="toggleFlakes()">
// <span class="slider round"></span>
// </label>
// </div> -->
function setBrandName(emoji) {
document.getElementById("brandName").innerHTML = emoji + "Bradley" + emoji + "Code" + emoji + "U" + emoji;
}
function snowSeason() {
console.log("❄️");
// create the snowflake toggle checkbox
var divSnow = document.createElement('div');
var brSnow = document.createElement('br');
divSnow.id = "snow";
divSnow.style.cssText = 'position:fixed;top:0;left:0;padding:3px;width:100%;height:1px;z-index:11111;';
var labelSwitch = document.createElement('label');
labelSwitch.style.cssText = 'font-size:8px;position:relative;display:inline-block;width:32px;height:16px;margin:0px!important;';
var inputSnowCheckbox = document.createElement('input');
inputSnowCheckbox.id = "snowCheckbox";
inputSnowCheckbox.type = "checkbox";
inputSnowCheckbox.checked = false;
inputSnowCheckbox.onclick = function() {
toggleFlakes()
};
divSnow.style.cssText = 'position:fixed;top:0;left:0;padding:3px;width:100%;height:1px;z-index:11111;';
var textNode = document.createTextNode("snow");
labelSwitch.appendChild(textNode);
labelSwitch.appendChild(brSnow);
labelSwitch.appendChild(inputSnowCheckbox);
divSnow.appendChild(labelSwitch);
document.body.appendChild(divSnow);
if (localStorage.getItem("isSnowEnabled") === null) {
isSnowEnabled = true;
} else {
isSnowEnabled = localStorage.getItem("isSnowEnabled") === "true";
}
if (isSnowEnabled) {
setBrandName("❄️");
} else {
setBrandName("");
}
document.getElementById("snowCheckbox").checked = isSnowEnabled;
setTimeout(function() {
Snowflake.init(document.getElementById("snow"));
}, 100);
}
function toggleFlakes() {
isSnowEnabled = !isSnowEnabled;
document.getElementById("snowCheckbox").checked = isSnowEnabled;
localStorage.setItem("isSnowEnabled", isSnowEnabled);
if (isSnowEnabled) {
document.getElementById("brandName").innerHTML = "❄️Bradley❄️Code❄️U❄️"
} else {
document.getElementById("brandName").innerHTML = "BradleyCodeU"
}
}
class Snowflake {
constructor(size, x, y, vx, vy) {
this.size = size;
this.x = x;
this.y = y;
this.initialY = y;
this.vx = vx;
this.vy = vy;
this.hit = false;
this.melt = false;
this.div = document.createElement('div');
this.div.classList.add('snowflake');
this.div.style.width = this.size + 'px';
this.div.style.height = this.size + 'px';
}
move() {
if (this.hit) {
if (Math.random() > 0.995) this.melt = true;
} else {
this.x += this.vx + Math.min(Math.max(wind, -10), 10);
this.y += this.vy;
}
// Wrap the snowflake to within the bounds of the page
if (this.x > window.innerWidth + this.size) {
this.x -= window.innerWidth + this.size;
}
if (this.x < -this.size) {
this.x += window.innerWidth + this.size;
}
if (this.y > window.innerHeight + this.size) {
this.x = Math.random() * window.innerWidth;
this.y -= window.innerHeight + this.size * 2;
this.melt = false;
}
// var dx = mouseX - this.x;
// var dy = mouseY - this.y;
// this.hit = !this.melt && dx * dx + dy * dy < 2400;
};
draw() {
this.div.style.transform =
this.div.style.MozTransform =
this.div.style.webkitTransform =
'translate3d(' + this.x + 'px' + ',' + this.y + 'px,0)';
};
static update() {
for (var i = flakes.length; i--;) {
var flake = flakes[i];
if (isSnowEnabled) {
flake.move();
flake.draw();
} else {
flake.y = flake.initialY;
flake.draw();
//flakes.splice(i,1);
}
}
requestAnimationFrame(Snowflake.update);
}
static init(container) {
flakes = [];
for (var i = flakesTotal; i--;) {
var size = (Math.random() + 0.4) * 6 + 1;
var flake = new Snowflake(
size,
Math.random() * window.innerWidth,
-Math.random() * window.innerHeight - 100,
Math.random() - 0.5,
size * 0.3
);
container.appendChild(flake.div);
flakes.push(flake);
}
Snowflake.update();
}
}
// <!-- Snow stuff ends -->