Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
480 lines (402 loc) · 15.6 KB
/
Copy pathscript.js
File metadata and controls
480 lines (402 loc) · 15.6 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
const cvData = [
{
id: 'edu',
title: 'Eğitim',
radius: 70,
color: 'rgba(255, 105, 180, 0.3)',
image: '',
details: 'Üniversite 2. Sınıf - İnorganik Kimya ağırlıklı temel bilimler eğitimi.',
links: []
},
{
id: 'sys',
title: 'İşletim Sistemleri',
radius: 90,
color: 'rgba(0, 191, 255, 0.3)',
image: '',
details: 'Qubes OS, Kali Linux, Fedora ve Arch Linux üzerinde kurulum, konfigürasyon ve donanım izolasyonu tecrübesi.',
links: [{ text: 'Ghidra C Çıktıları', url: '#' }]
},
{
id: 'hw',
title: 'Gömülü Sistemler & Donanım',
radius: 100,
color: 'rgba(144, 238, 144, 0.3)',
image: '',
details: 'Raspberry Pi 4B, Compute Module 5 (CM5) ve STM8A geliştirme kartları ile düşük seviyeli programlama ve pin konfigürasyonları.',
links: [{ text: 'Donanım Projelerim', url: '#' }]
},
{
id: 'mech',
title: 'Mekanik & Tasarım',
radius: 85,
color: 'rgba(255, 215, 0, 0.3)',
image: '',
details: 'PETG filament ile basınçlı hava destekli Venturi su pompası tasarımı. Ayrıca web arayüzleri için Flexbox tabanlı HTML/CSS geliştirmeleri.',
links: [{ text: 'SVG Şemaları', url: '#' }, { text: 'Web Tasarımları', url: '#' }]
}
];
const introScreen = document.getElementById('intro-screen');
const introImg = document.getElementById('intro-img');
const clickText = document.getElementById('click-text');
const isTouchDevice = window.matchMedia('(pointer: coarse)').matches;
const isMobileViewport = window.matchMedia('(max-width: 768px)').matches;
// Ses dosyanın yolunu buraya yazmalısın (örn: 'click.mp3')
const clickSound = new Audio('ses_efekti.mp3');
let introCompleted = false;
function startIntroTransition() {
if (introCompleted || !introScreen) return;
introCompleted = true;
try {
clickSound.play().catch(err => console.log('Tarayıcı ses çalmayı engelledi:', err));
} catch (err) {
console.log('Ses çalma hatası:', err);
}
if (navigator.vibrate) {
navigator.vibrate(200);
}
introScreen.style.backgroundColor = '#000000';
clickText.style.display = 'none';
introImg.src = 'ikinci_gorsel.jpg';
setTimeout(() => {
introScreen.style.opacity = '0';
setTimeout(() => {
introScreen.style.display = 'none';
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
}, 500);
}, 500);
}
if (introScreen) {
introScreen.addEventListener('pointerdown', (event) => {
if (event.isPrimary === false) return;
event.preventDefault();
startIntroTransition();
}, { passive: false });
}
document.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
startIntroTransition();
}
});
const container = document.getElementById('bubble-container');
const modalOverlay = document.getElementById('modal-overlay');
const modalTitle = document.getElementById('modal-title');
const modalBody = document.getElementById('modal-body');
const closeBtn = document.getElementById('close-btn');
const centerBtn = document.getElementById('center-btn');
const searchModal = document.getElementById('search-modal');
const searchInput = document.getElementById('search-input');
const closeSearchBtn = document.getElementById('close-search');
const searchSubmitBtn = document.getElementById('search-submit');
let bubblesArray = [];
let searchOpen = false;
function getSearchButtonState() {
if (!centerBtn || centerBtn.classList.contains('hidden')) return null;
const rect = centerBtn.getBoundingClientRect();
return {
x: rect.left + rect.width / 2,
y: rect.top + rect.height / 2,
radius: isTouchDevice || isMobileViewport ? 0 : rect.width / 2
};
}
function setSearchVisibility(isVisible) {
if (!centerBtn || !searchModal || !searchInput) return;
if (isVisible) {
centerBtn.classList.remove('hidden');
searchModal.classList.add('hidden');
} else {
centerBtn.classList.add('hidden');
searchModal.classList.remove('hidden');
searchInput.focus();
}
}
function resetSearchFilter() {
bubblesArray.forEach(bubble => {
bubble.element.classList.remove('hidden-bubble');
bubble.element.classList.remove('search-highlight');
});
}
function highlightSearchMatch(query) {
let matchedBubble = null;
bubblesArray.forEach(bubble => {
if (query === '') {
bubble.element.classList.remove('search-highlight');
return;
}
const titleMatch = bubble.data.title.toLowerCase().includes(query);
const detailsMatch = bubble.data.details.toLowerCase().includes(query);
const isMatch = titleMatch || detailsMatch;
if (isMatch && !matchedBubble) {
matchedBubble = bubble;
}
bubble.element.classList.toggle('search-highlight', bubble === matchedBubble);
});
}
function openSearch() {
searchOpen = true;
setSearchVisibility(false);
searchInput.value = '';
resetSearchFilter();
searchInput.focus();
}
// Çarpışma fiziği için yardımcı fonksiyonlar
function rotate(velocity, angle) {
return {
x: velocity.x * Math.cos(angle) - velocity.y * Math.sin(angle),
y: velocity.x * Math.sin(angle) + velocity.y * Math.cos(angle)
};
}
function resolveCollision(particle, otherParticle) {
const xVelocityDiff = particle.dx - otherParticle.dx;
const yVelocityDiff = particle.dy - otherParticle.dy;
const xDist = otherParticle.x - particle.x;
const yDist = otherParticle.y - particle.y;
// Balonların birbirine yapışmasını önlemek için sadece birbirlerine doğru hareket ediyorlarsa sekme uygula
if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) {
const angle = -Math.atan2(otherParticle.y - particle.y, otherParticle.x - particle.x);
// Kütle (Yarıçap baz alınarak momentum hesaplanır)
const m1 = particle.radius;
const m2 = otherParticle.radius;
const u1 = rotate({ x: particle.dx, y: particle.dy }, angle);
const u2 = rotate({ x: otherParticle.dx, y: otherParticle.dy }, angle);
// 1 Boyutlu esnek çarpışma denklemi
const v1 = { x: u1.x * (m1 - m2) / (m1 + m2) + u2.x * 2 * m2 / (m1 + m2), y: u1.y };
const v2 = { x: u2.x * (m1 - m2) / (m1 + m2) + u1.x * 2 * m1 / (m1 + m2), y: u2.y };
const vFinal1 = rotate(v1, -angle);
const vFinal2 = rotate(v2, -angle);
particle.dx = vFinal1.x;
particle.dy = vFinal1.y;
otherParticle.dx = vFinal2.x;
otherParticle.dy = vFinal2.y;
}
}
class Bubble {
constructor(data, x, y) {
this.data = data;
this.radius = data.radius;
// Konum merkez baz alınarak tutuluyor
this.x = x;
this.y = y;
this.dx = (Math.random() - 0.5) * 3; // Hız (X ekseni)
this.dy = (Math.random() - 0.5) * 3; // Hız (Y ekseni)
this.element = document.createElement('div');
this.initElement();
}
initElement() {
this.element.classList.add('bubble');
this.element.style.width = `${this.radius * 2}px`;
this.element.style.height = `${this.radius * 2}px`;
this.element.style.boxShadow = `inset 10px 10px 20px rgba(255, 255, 255, 0.5), inset -10px -10px 20px ${this.data.color}, 0 10px 20px rgba(0, 0, 0, 0.1)`;
if (this.data.image) {
const img = document.createElement('img');
img.src = this.data.image;
img.classList.add('bubble-bg-image');
this.element.appendChild(img);
}
const titleSpan = document.createElement('span');
titleSpan.classList.add('bubble-title');
titleSpan.innerText = this.data.title;
this.element.appendChild(titleSpan);
this.element.addEventListener('click', () => {
resetSearchFilter();
openModal(this.data);
});
container.appendChild(this.element);
}
update(bubbles) {
// Çerçeveye çarpma (Ekran sınırları)
if (this.x + this.radius >= window.innerWidth) {
this.x = window.innerWidth - this.radius;
this.dx = -Math.abs(this.dx);
} else if (this.x - this.radius <= 0) {
this.x = this.radius;
this.dx = Math.abs(this.dx);
}
if (this.y + this.radius >= window.innerHeight) {
this.y = window.innerHeight - this.radius;
this.dy = -Math.abs(this.dy);
} else if (this.y - this.radius <= 0) {
this.y = this.radius;
this.dy = Math.abs(this.dy);
}
// Diğer balonlara çarpma kontrolü
for (let i = 0; i < bubbles.length; i++) {
if (this === bubbles[i]) continue;
const dist = Math.hypot(this.x - bubbles[i].x, this.y - bubbles[i].y);
if (dist - (this.radius + bubbles[i].radius) < 0) {
resolveCollision(this, bubbles[i]);
}
}
this.x += this.dx;
this.y += this.dy;
const buttonState = getSearchButtonState();
if (buttonState) {
const dx = this.x - buttonState.x;
const dy = this.y - buttonState.y;
const distance = Math.hypot(dx, dy) || 0.0001;
const minDistance = this.radius + buttonState.radius;
if (distance < minDistance) {
const nx = dx / distance;
const ny = dy / distance;
const overlap = minDistance - distance;
this.x += nx * (overlap + 2);
this.y += ny * (overlap + 2);
const velocityDot = this.dx * nx + this.dy * ny;
if (velocityDot < 0) {
this.dx -= 2 * velocityDot * nx;
this.dy -= 2 * velocityDot * ny;
}
}
}
// Ekrana çizdirme (Sol üst köşe hesabına çevirerek)
this.element.style.transform = `translate(${this.x - this.radius}px, ${this.y - this.radius}px)`;
}
}
// Balonların başlangıçta iç içe doğmasını engellemek için konum hesaplama
function spawnBubbles() {
cvData.forEach(item => {
let x, y;
let overlapping = true;
while (overlapping) {
x = Math.random() * (window.innerWidth - item.radius * 2) + item.radius;
y = Math.random() * (window.innerHeight - item.radius * 2) + item.radius;
overlapping = false;
for (let i = 0; i < bubblesArray.length; i++) {
const dist = Math.hypot(x - bubblesArray[i].x, y - bubblesArray[i].y);
if (dist < item.radius + bubblesArray[i].radius + 5) { // +5px güvenlik marjı
overlapping = true;
break;
}
}
}
bubblesArray.push(new Bubble(item, x, y));
});
}
spawnBubbles();
function animate() {
requestAnimationFrame(animate);
bubblesArray.forEach(bubble => bubble.update(bubblesArray));
}
animate();
window.addEventListener('resize', () => {
bubblesArray.forEach(bubble => {
if(bubble.x + bubble.radius > window.innerWidth) bubble.x = window.innerWidth - bubble.radius;
if(bubble.y + bubble.radius > window.innerHeight) bubble.y = window.innerHeight - bubble.radius;
});
});
function openModal(data) {
modalTitle.innerText = data.title;
let contentHTML = `<p>${data.details}</p>`;
if (data.links && data.links.length > 0) {
data.links.forEach(link => {
contentHTML += `<a href="${link.url}" target="_blank" class="modal-link">${link.text}</a>`;
});
}
modalBody.innerHTML = contentHTML;
modalOverlay.classList.remove('hidden');
}
closeBtn.addEventListener('click', () => {
modalOverlay.classList.add('hidden');
});
modalOverlay.addEventListener('click', (e) => {
if (e.target === modalOverlay) {
modalOverlay.classList.add('hidden');
}
});
if (centerBtn) {
centerBtn.addEventListener('pointerdown', (event) => {
event.preventDefault();
openSearch();
});
}
if (closeSearchBtn) {
closeSearchBtn.addEventListener('click', () => {
closeSearchPanel();
});
}
if (searchInput) {
searchInput.addEventListener('input', (e) => {
const query = e.target.value.toLowerCase().trim();
let firstMatch = null;
bubblesArray.forEach(bubble => {
const titleMatch = bubble.data.title.toLowerCase().includes(query);
const detailsMatch = bubble.data.details.toLowerCase().includes(query);
const isMatch = query === '' || titleMatch || detailsMatch;
bubble.element.classList.toggle('hidden-bubble', !isMatch);
if (isMatch && !firstMatch) {
firstMatch = bubble;
}
});
bubblesArray.forEach(bubble => {
bubble.element.classList.toggle('search-highlight', bubble === firstMatch && query !== '');
});
});
searchInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
submitSearch();
}
});
}
function submitSearch() {
const query = searchInput ? searchInput.value.toLowerCase().trim() : '';
if (!query) {
closeSearchPanel();
return;
}
applySearch(query);
closeSearchPanel(true);
}
function applySearch(query) {
let firstMatch = null;
bubblesArray.forEach(bubble => {
const titleMatch = bubble.data.title.toLowerCase().includes(query);
const detailsMatch = bubble.data.details.toLowerCase().includes(query);
const isMatch = titleMatch || detailsMatch;
bubble.element.classList.toggle('hidden-bubble', !isMatch);
if (isMatch && !firstMatch) {
firstMatch = bubble;
}
});
bubblesArray.forEach(bubble => {
bubble.element.classList.toggle('search-highlight', bubble === firstMatch);
});
}
function closeSearchPanel(preserveResults = false) {
if (!searchModal) return;
searchModal.classList.add('hidden');
searchOpen = false;
if (centerBtn) {
centerBtn.classList.remove('hidden');
}
if (searchInput) {
searchInput.value = '';
}
if (!preserveResults) {
resetSearchFilter();
}
}
if (searchModal) {
searchModal.addEventListener('click', (e) => {
if (e.target === searchModal) {
closeSearchPanel();
}
});
}
if (searchSubmitBtn) {
searchSubmitBtn.addEventListener('click', submitSearch);
}
document.addEventListener('keydown', (e) => {
if (searchModal && e.key === 'Escape' && !searchModal.classList.contains('hidden')) {
closeSearchPanel();
}
if (searchModal && (e.key === 'Enter' || e.key === 'Search') && !searchModal.classList.contains('hidden')) {
e.preventDefault();
submitSearch();
}
if (e.key === 'Search' && searchModal && searchModal.classList.contains('hidden')) {
e.preventDefault();
openSearch();
}
});