-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
345 lines (293 loc) · 11.2 KB
/
script.js
File metadata and controls
345 lines (293 loc) · 11.2 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('particles'), alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
const particles = new THREE.BufferGeometry();
const particleCount = 1000;
const posArray = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 5;
}
particles.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const material = new THREE.PointsMaterial({ size: 0.006, color: 0x00ff00 });
const particlesMesh = new THREE.Points(particles, material);
scene.add(particlesMesh);
camera.position.z = 3;
function animateParticles() {
requestAnimationFrame(animateParticles);
particlesMesh.rotation.x += 0.0001;
particlesMesh.rotation.y += 0.0001;
renderer.render(scene, camera);
}
animateParticles();
const username = 'RocketGod-git';
let perPage = 12;
let currentPage = 1;
let allRepos = [];
async function fetchRepos() {
try {
let page = 1;
let hasNextPage = true;
while (hasNextPage) {
const response = await fetch(`https://api.github.com/users/${username}/repos?per_page=100&page=${page}&type=owner`);
const repos = await response.json();
if (repos.length === 0) {
hasNextPage = false;
} else {
allRepos = allRepos.concat(repos);
page++;
}
}
allRepos = allRepos.filter(repo => !repo.fork)
.sort((a, b) => b.stargazers_count - a.stargazers_count);
updateRepoList();
updateStats();
} catch (error) {
document.getElementById('loading').textContent = 'Error loading repositories. Please try again later.';
}
}
function updateRepoList() {
const repoList = document.getElementById('repo-list');
repoList.innerHTML = '';
const startIndex = (currentPage - 1) * perPage;
const endIndex = startIndex + perPage;
const currentRepos = allRepos.slice(startIndex, endIndex);
if (currentRepos.length === 0) {
document.getElementById('loading').textContent = 'No repositories found.';
return;
}
currentRepos.forEach(repo => {
const repoCard = document.createElement('div');
repoCard.className = 'repo-card';
repoCard.innerHTML = `
<h3><a href="${repo.html_url}" target="_blank">${repo.name}</a></h3>
<p>⭐ ${repo.stargazers_count} | 🍴 ${repo.forks_count}</p>
<p>${repo.description || 'No description available.'}</p>
`;
repoList.appendChild(repoCard);
});
document.getElementById('loading').style.display = 'none';
document.getElementById('prev-page').disabled = currentPage === 1;
document.getElementById('next-page').disabled = currentPage >= Math.ceil(allRepos.length / perPage);
document.getElementById('repo-count').textContent = `Showing ${startIndex + 1}-${Math.min(endIndex, allRepos.length)} of ${allRepos.length} repositories`;
}
function updateStats() {
const totalStars = allRepos.reduce((sum, repo) => sum + repo.stargazers_count, 0);
const totalForks = allRepos.reduce((sum, repo) => sum + repo.forks_count, 0);
document.getElementById('total-stars').textContent = totalStars;
document.getElementById('total-forks').textContent = totalForks;
}
document.getElementById('prev-page').addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
updateRepoList();
}
});
document.getElementById('next-page').addEventListener('click', () => {
if (currentPage < Math.ceil(allRepos.length / perPage)) {
currentPage++;
updateRepoList();
}
});
document.getElementById('view-all').addEventListener('click', () => {
perPage = allRepos.length;
currentPage = 1;
updateRepoList();
document.querySelector('.pagination').style.display = 'none';
});
fetchRepos();
const bouncingImage = document.getElementById('bouncing-image');
bouncingImage.src = base64Image;
let x = Math.random() * (window.innerWidth - 150);
let y = Math.random() * (window.innerHeight - 150);
let velocityX = (Math.random() > 0.5 ? 1 : -1) * 2;
let velocityY = (Math.random() > 0.5 ? 1 : -1) * 2;
const baseSpeed = 2;
const maxSpeed = 15;
const hitForceMultiplier = 0.4;
const friction = 0.99;
const hitRadius = 100;
let lastTouchPos = { x: 0, y: 0 };
let currentTouchId = null;
let lastTime = performance.now();
function checkImageHit(clientX, clientY, velocity) {
const imageCenter = {
x: x + 75,
y: y + 75
};
const distance = Math.sqrt(
Math.pow(clientX - imageCenter.x, 2) +
Math.pow(clientY - imageCenter.y, 2)
);
if (distance < hitRadius) {
velocityX += velocity.x * hitForceMultiplier;
velocityY += velocity.y * hitForceMultiplier;
const currentSpeed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
if (currentSpeed > maxSpeed) {
const scale = maxSpeed / currentSpeed;
velocityX *= scale;
velocityY *= scale;
}
return true;
}
return false;
}
function animateBounce(currentTime) {
const deltaTime = (currentTime - lastTime) / 16.67;
lastTime = currentTime;
x += velocityX * deltaTime;
y += velocityY * deltaTime;
if (x + 150 > window.innerWidth) {
x = window.innerWidth - 150;
velocityX = -Math.abs(velocityX) * 0.8;
}
if (x < 0) {
x = 0;
velocityX = Math.abs(velocityX) * 0.8;
}
if (y + 150 > window.innerHeight) {
y = window.innerHeight - 150;
velocityY = -Math.abs(velocityY) * 0.8;
}
if (y < 0) {
y = 0;
velocityY = Math.abs(velocityY) * 0.8;
}
velocityX *= friction;
velocityY *= friction;
const currentSpeed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
if (currentSpeed < baseSpeed && currentSpeed > 0.1) {
const scale = baseSpeed / currentSpeed;
velocityX *= scale;
velocityY *= scale;
}
bouncingImage.style.transform = `translate(${x}px, ${y}px)`;
requestAnimationFrame(animateBounce);
}
function handleTouchStart(e) {
if (!currentTouchId) {
const touch = e.touches[0];
currentTouchId = touch.identifier;
lastTouchPos.x = touch.clientX;
lastTouchPos.y = touch.clientY;
checkImageHit(touch.clientX, touch.clientY, { x: 0, y: 0 });
}
}
function handleTouchMove(e) {
const touch = Array.from(e.touches).find(t => t.identifier === currentTouchId);
if (touch) {
const clientX = touch.clientX;
const clientY = touch.clientY;
const velocity = {
x: (clientX - lastTouchPos.x) * 0.5,
y: (clientY - lastTouchPos.y) * 0.5
};
checkImageHit(clientX, clientY, velocity);
lastTouchPos.x = clientX;
lastTouchPos.y = clientY;
}
}
function handleTouchEnd(e) {
if (e.touches.length === 0 || !Array.from(e.touches).some(t => t.identifier === currentTouchId)) {
currentTouchId = null;
}
}
function handleMouseMove(e) {
const clientX = e.clientX;
const clientY = e.clientY;
const velocity = {
x: (clientX - lastTouchPos.x) * 0.5,
y: (clientY - lastTouchPos.y) * 0.5
};
checkImageHit(clientX, clientY, velocity);
lastTouchPos.x = clientX;
lastTouchPos.y = clientY;
}
document.addEventListener('DOMContentLoaded', function() {
const h1Element = document.querySelector('h1');
const headerText = h1Element.textContent;
h1Element.textContent = '';
h1Element.id = 'rocketgod-header';
for (let i = 0; i < headerText.length; i++) {
const span = document.createElement('span');
span.className = 'header-letter';
span.textContent = headerText[i];
h1Element.appendChild(span);
}
const letterElements = document.querySelectorAll('.header-letter');
const letterObjects = Array.from(letterElements).map(letter => {
const rect = letter.getBoundingClientRect();
return {
element: letter,
x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height,
centerX: rect.left + rect.width / 2,
isActive: false
};
});
function updateLetterPositions() {
letterObjects.forEach(letter => {
const rect = letter.element.getBoundingClientRect();
letter.x = rect.left;
letter.y = rect.top;
letter.width = rect.width;
letter.height = rect.height;
letter.centerX = rect.left + rect.width / 2;
});
}
window.addEventListener('resize', updateLetterPositions);
function handleHeaderInteraction(clientX, clientY) {
letterObjects.forEach(letter => {
const distX = Math.abs(clientX - letter.centerX);
const distY = Math.abs(clientY - letter.y);
const interactionRadius = 80;
if (distX < interactionRadius && distY < interactionRadius) {
const strength = 1 - Math.min(1, Math.sqrt(distX * distX + distY * distY) / interactionRadius);
const drip = 1 + strength * 1.5;
letter.element.style.transform = `scaleY(${drip})`;
letter.element.classList.add('dripping');
letter.isActive = true;
} else if (letter.isActive) {
letter.element.style.transform = '';
letter.element.classList.remove('dripping');
letter.isActive = false;
}
});
}
document.addEventListener('mousemove', (e) => {
handleHeaderInteraction(e.clientX, e.clientY);
});
document.addEventListener('touchmove', (e) => {
Array.from(e.touches).forEach(touch => {
handleHeaderInteraction(touch.clientX, touch.clientY);
});
}, { passive: true });
function resetAllLetters() {
letterObjects.forEach((letter, index) => {
setTimeout(() => {
letter.element.style.transform = '';
letter.element.classList.remove('dripping');
letter.isActive = false;
}, index * 50);
});
}
document.addEventListener('mouseleave', resetAllLetters);
document.addEventListener('touchend', resetAllLetters);
updateLetterPositions();
});
document.addEventListener('touchstart', handleTouchStart, { passive: true });
document.addEventListener('touchmove', handleTouchMove, { passive: true });
document.addEventListener('touchend', handleTouchEnd, { passive: true });
document.addEventListener('mousemove', handleMouseMove, { passive: true });
requestAnimationFrame(animateBounce);
window.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
});
gsap.fromTo('.project-card',
{ opacity: 0, y: 20 },
{ opacity: 1, y: 0, stagger: 0.05, duration: 0.5, ease: 'power2.out' }
);