-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
352 lines (294 loc) · 10.7 KB
/
script.js
File metadata and controls
352 lines (294 loc) · 10.7 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
/**
* MedusaBest - Kişisel Biyografi Web Sitesi
* script.js - Ana JavaScript dosyası
*/
// DOM içeriği yüklendiğinde çalışacak fonksiyonlar
document.addEventListener('DOMContentLoaded', function() {
console.log('web sitesi yüklendi!');
// Tema değiştirici
setupThemeToggle();
// Matrix animasyonu
setupMatrixBackground();
// Mobil menü toggle
setupMobileMenu();
// Yazı animasyonu
setupTypingAnimation();
// Smooth scrolling
setupSmoothScrolling();
// Özel imleç
setupCustomCursor();
// Footer yılını otomatik güncelle
updateFooterYear();
// Sayfada fade-in animasyonlarını aktif et
setupScrollAnimations();
});
/**
* Tema değiştirici işlevselliğini ayarlar (Koyu/Açık mod)
*/
function setupThemeToggle() {
const themeToggleBtn = document.getElementById('theme-toggle');
// Kullanıcı tercihini localStorage'dan al (varsa)
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
document.body.className = savedTheme;
}
themeToggleBtn.addEventListener('click', function() {
// Temayı değiştir
if (document.body.classList.contains('dark-mode')) {
document.body.classList.remove('dark-mode');
document.body.classList.add('light-mode');
localStorage.setItem('theme', 'light-mode');
} else {
document.body.classList.remove('light-mode');
document.body.classList.add('dark-mode');
localStorage.setItem('theme', 'dark-mode');
}
});
}
/**
* Matrix stilinde arkaplan animasyonu oluşturur
*/
function setupMatrixBackground() {
const canvas = document.getElementById('matrix-canvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
// Karakterler
const characters = "01アァカサタナハマヤャラワガザダバパイィキシチニヒミリヰギジヂビピウゥクスツヌフムユュルグズブヅプエェケセテネヘメレヱゲゼデベペオォコソトノホモヨョロヲゴゾドボポヴッン";
const fontSize = 14;
const columns = canvas.width / fontSize;
// Dikey pozisyonları tutan dizi
const drops = [];
for (let i = 0; i < columns; i++) {
drops[i] = 1;
}
// Animasyon fonksiyonu
function drawMatrix() {
// Yarı saydam siyah arkafon, kuyruk etkisi için
ctx.fillStyle = "rgba(0, 0, 0, 0.05)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Yeşil text
ctx.fillStyle = "#0f0";
ctx.font = fontSize + "px 'Fira Code'";
// Her sütun için karakterleri çiz
for (let i = 0; i < drops.length; i++) {
// Rastgele bir karakter seç
const text = characters[Math.floor(Math.random() * characters.length)];
// Karakteri çiz
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
// Karakterin Y pozisyonunu güncelle
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
// Canvas boyutunu pencere boyutuyla güncelle
window.addEventListener('resize', function() {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
});
// Animasyon döngüsü
setInterval(drawMatrix, 50);
}
/**
* Mobil menü toggle fonksiyonu
*/
function setupMobileMenu() {
const navToggle = document.getElementById('nav-toggle');
const navLinks = document.getElementById('nav-links');
navToggle.addEventListener('click', function() {
navLinks.classList.toggle('show');
});
// Menü linklerine tıklandığında mobil menüyü kapat
const menuLinks = document.querySelectorAll('.nav-link');
menuLinks.forEach(link => {
link.addEventListener('click', function() {
navLinks.classList.remove('show');
});
});
// Sayfa kaydırıldığında menüyü küçült
let lastScrollTop = 0;
window.addEventListener('scroll', function() {
const navbar = document.getElementById('navbar');
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if (scrollTop > lastScrollTop) {
// Aşağı kaydırma
navbar.style.transform = "translateY(-100%)";
} else {
// Yukarı kaydırma
navbar.style.transform = "translateY(0)";
}
// Sayfanın en üstündeyken her zaman görünür
if (scrollTop <= 50) {
navbar.style.transform = "translateY(0)";
}
lastScrollTop = scrollTop;
});
}
/**
* Yazı animasyonu oluşturur
*/
function setupTypingAnimation() {
const typedElement = document.getElementById('home-typed');
if (!typedElement) return;
const texts = [
"echo 'Siber dünyaya hoş geldiniz!'",
"sudo nmap -sS -sV -O medusa.best",
"cat /etc/passwd | grep 'security'",
"python3 zafiyet_tarayici.py --hedef=website.com",
"git commit -m 'Güvenlik açığı giderildi'"
];
let textIndex = 0;
let charIndex = 0;
let isDeleting = false;
let typingSpeed = 100;
function typeText() {
const currentText = texts[textIndex];
if (isDeleting) {
// Silme işlemi
typedElement.textContent = currentText.substring(0, charIndex - 1);
charIndex--;
typingSpeed = 50;
} else {
// Yazma işlemi
typedElement.textContent = currentText.substring(0, charIndex + 1);
charIndex++;
typingSpeed = 100;
}
// Yazma tamamlandıysa, silmeye başla
if (!isDeleting && charIndex === currentText.length) {
isDeleting = true;
typingSpeed = 1500; // Silmeden önce bekle
}
// Silme tamamlandıysa, sonraki metne geç
if (isDeleting && charIndex === 0) {
isDeleting = false;
textIndex = (textIndex + 1) % texts.length;
}
setTimeout(typeText, typingSpeed);
}
// Yazı animasyonunu başlat
typeText();
}
/**
* Sayfa içi linklerde yumuşak kaydırma sağlar
*/
function setupSmoothScrolling() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 70,
behavior: 'smooth'
});
}
});
});
}
/**
* Özel imleç efekti oluşturur
*/
function setupCustomCursor() {
const cursor = document.querySelector('.cursor');
if (!cursor) return;
document.addEventListener('mousemove', e => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Linklere ve butonlara hover olduğunda imleç efekti
const hoverables = document.querySelectorAll('a, button, .btn');
hoverables.forEach(hoverable => {
hoverable.addEventListener('mouseenter', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(1.5)';
cursor.style.opacity = '0.5';
});
hoverable.addEventListener('mouseleave', () => {
cursor.style.transform = 'translate(-50%, -50%) scale(1)';
cursor.style.opacity = '0.7';
});
});
// Mobil cihazlarda özel imleci gizle
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
cursor.style.display = 'none';
}
}
/**
* Footer'daki yılı otomatik günceller
*/
function updateFooterYear() {
const yearElement = document.getElementById('current-year');
if (yearElement) {
yearElement.textContent = new Date().getFullYear();
}
}
/**
* Sayfa kaydırıldıkça öğelerin fade-in animasyonunu aktif eder
*/
function setupScrollAnimations() {
// Tüm ana bölümler
const sections = document.querySelectorAll('.section');
// Intersection Observer ile ekrana giren öğeleri tespit et
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
// Terminal pencerelerindeki yazı animasyonu
if (entry.target.querySelector('.terminal-content')) {
const terminalContent = entry.target.querySelector('.terminal-content');
terminalContent.style.opacity = '0';
setTimeout(() => {
terminalContent.style.transition = 'opacity 1s ease';
terminalContent.style.opacity = '1';
}, 300);
}
// Gözlemlemeyi durdur
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.2
});
// Bölümleri gözlemle
sections.forEach(section => {
observer.observe(section);
});
// Proje kartları için animasyon
const projectCards = document.querySelectorAll('.project-card');
const projectObserver = new IntersectionObserver((entries, observer) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}, index * 100); // Kademeli animasyon
}
});
}, {
threshold: 0.1
});
projectCards.forEach(card => {
projectObserver.observe(card);
});
// Blog kartları için animasyon
const blogCards = document.querySelectorAll('.blog-card');
const blogObserver = new IntersectionObserver((entries, observer) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}, index * 100); // Kademeli animasyon
}
});
}, {
threshold: 0.1
});
blogCards.forEach(card => {
blogObserver.observe(card);
});
}