-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
203 lines (177 loc) · 5.87 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
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
document.addEventListener('DOMContentLoaded', function () {
particlesJS('particles', {
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": "#ffffff"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
}
},
"opacity": {
"value": 0.5,
"random": true,
"anim": {
"enable": true,
"speed": 1,
"opacity_min": 0.1,
"sync": false
}
},
"size": {
"value": 3,
"random": true,
"anim": {
"enable": true,
"speed": 40,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": false
},
"move": {
"enable": true,
"speed": 6,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"bounce": false,
"attract": false
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "repulse"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"repulse": {
"distance": 100,
"duration": 0.4
},
"push": {
"particles_nb": 4
}
}
},
"retina_detect": true
});
const musicPlayer = document.getElementById('music-player');
const playPauseButton = document.getElementById('play-pause-button');
const playIcon = playPauseButton.querySelector('.play-icon');
const pauseIcon = playPauseButton.querySelector('.pause-icon');
playPauseButton.addEventListener('click', () => {
if (musicPlayer.paused) {
musicPlayer.play().then(() => {
playIcon.style.display = 'none';
pauseIcon.style.display = 'inline';
}).catch(error => {
console.error('Oynatma hatas©Å: ', error);
});
} else {
musicPlayer.pause();
playIcon.style.display = 'inline';
pauseIcon.style.display = 'none';
}
});
const img = document.getElementById('bouncing-image');
const container = document.body;
let posX = 0;
let posY = 0;
let velX = (Math.random() - 0.5) * 10;
let velY = (Math.random() - 0.5) * 10;
function moveImage() {
const imgWidth = img.offsetWidth;
const imgHeight = img.offsetHeight;
const maxX = container.clientWidth - imgWidth;
const maxY = container.clientHeight - imgHeight;
posX += velX;
posY += velY;
if (posX <= 0 || posX >= maxX) {
velX = (Math.random() - 0.5) * 10;
}
if (posY <= 0 || posY >= maxY) {
velY = (Math.random() - 0.5) * 10;
}
img.style.left = posX + 'px';
img.style.top = posY + 'px';
requestAnimationFrame(moveImage);
}
moveImage();
const introCard = document.querySelector('.intro-card');
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function changeBackgroundColor() {
introCard.style.backgroundColor = getRandomColor();
}
changeBackgroundColor();
setInterval(changeBackgroundColor, 5000);
const slideButton = document.getElementById('slideButton');
slideButton.addEventListener('click', () => {
window.location.href = 'info.html';
});
});
const audio = new Audio('music/xx.mp3');
window.addEventListener('load', () => {
audio.play();
playBtn.style.display = 'none';
pauseBtn.style.display = 'inline-block';
});
const playBtn = document.querySelector('.control-btn.play');
const pauseBtn = document.querySelector('.control-btn.pause');
const progressBar = document.getElementById('progress-bar');
const timeDisplay = document.getElementById('timeDisplay');
playBtn.addEventListener('click', () => {
audio.play();
playBtn.style.display = 'none';
pauseBtn.style.display = 'inline-block';
});
pauseBtn.addEventListener('click', () => {
audio.pause();
pauseBtn.style.display = 'none';
playBtn.style.display = 'inline-block';
});
audio.addEventListener('timeupdate', () => {
const currentTime = audio.currentTime;
const duration = audio.duration;
const progress = (currentTime / duration) * 100;
progressBar.value = progress;
timeDisplay.textContent = formatTime(currentTime) + ' / ' + formatTime(duration);
});
progressBar.addEventListener('input', () => {
const value = progressBar.value;
const duration = audio.duration;
audio.currentTime = (value / 100) * duration;
});
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
const secs = Math.floor(seconds % 60);
return `${minutes}:${secs < 10 ? '0' : ''}${secs}`;
}