-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
172 lines (133 loc) · 4.08 KB
/
script.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
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
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('down').onclick = function (e) {
smoothScroll('games');
};
window.onload = function() {
let alertShown = localStorage.getItem('msg0');
if (!alertShown) {
alert("Tomb of the mask, mario, mario64, bottle flip 3d, subway surfers, tetris, n-gon, slope, vex-6 and bitlife and now fixed!");
localStorage.setItem('msg0', 'true');
}
}
function smoothScroll(targetId) {
const targetSection = document.getElementById(targetId);
const targetPosition = targetSection.offsetTop;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
let count = document.getElementById('games').getElementsByTagName("li").length;
document.getElementById('games-count').innerHTML = `${count-2} Games`
function myFunction() {
const dropdown = document.getElementById('myInput');
dropdown.classList.toggle('show');
}
});
function search()
{
let myInput = document.getElementById('search-bar');
let games = document.getElementById('games');
games.querySelectorAll('li').forEach((listItem, index) => {
console.log(listItem);
if (listItem.textContent.toLowerCase().includes(myInput.value.toLowerCase()))
{
listItem.style.display = "inline-block";
}
else
{
listItem.style.display = "none";
}
});
}
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var field = document.getElementById("body-top");
var f = field.getContext("2d");
var stars = {};
var starIndex = 0;
var numStars = 0;
var acceleration = 1;
var starsToDraw = (field.width * field.height) / 200;
if (getUrlParameter("stars")) {
starsToDraw = getUrlParameter("stars");
}
if (getUrlParameter("accel")) {
acceleration = getUrlParameter("accel");
}
function Star() {
this.X = field.width / 2;
this.Y = field.height / 2;
this.SX = Math.random() * 10 - 5;
this.SY = Math.random() * 10 - 5;
var start = 0;
if (field.width > field.height)
start = field.width;
else
start = field.height;
this.X += this.SX * start / 10;
this.Y += this.SY * start / 10;
this.W = 1;
this.H = 1;
this.age = 0;
this.dies = 500;
starIndex++;
stars[starIndex] = this;
this.ID = starIndex;
this.C = "#ffffff";
}
Star.prototype.Draw = function () {
this.X += this.SX;
this.Y += this.SY
this.SX += this.SX / (50 / acceleration);
this.SY += this.SY / (50 / acceleration);
this.age++;
if (this.age == Math.floor(50 / acceleration) | this.age == Math.floor(150 / acceleration) | this.age == Math.floor(300 / acceleration)) {
this.W++;
this.H++;
}
if (this.X + this.W < 0 | this.X > field.width |
this.Y + this.H < 0 | this.Y > field.height)
{
delete stars[this.ID];
numStars--;
}
f.fillStyle = this.C;
f.fillRect(this.X, this.Y, this.W, this.H);
}
field.width = window.innerWidth;
field.height = window.innerHeight;
function draw() {
if (field.width != window.innerWidth)
field.width = window.innerWidth;
if (field.height != window.innerHeight)
field.height = window.innerHeight;
// Play with the "a" value to create streams...it's fun!
f.fillStyle = "rgba(0, 0, 0, 0.8)";
f.fillRect(0, 0, field.width, field.height);
for (var i = numStars; i < starsToDraw; i++) {
new Star();
numStars++;
}
for (var star in stars) {
stars[star].Draw();
}
}
field.addEventListener('mouseover', () => {
acceleration = 10;
});
field.addEventListener('mouseout', () => {
acceleration = 1;
});
// Original timing of the screensaver
setInterval(draw, 40);