forked from Samir500/The-Last-Counter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
501 lines (429 loc) · 14.6 KB
/
script.js
File metadata and controls
501 lines (429 loc) · 14.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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
// let navbar = document.querySelector('.navbar');
// document.querySelector('#menu').onclick = () => {
// navbar.classList.toggle('active');
// }
// window.onscroll = () => {
// navbar.classList.remove('active');
// }
// $(document).ready(function() {
// $(window).scroll(function() {
// var scroll = $(window).scrollTop();
// if (scroll > 350) {
// $(".header").css("background", "black");
// } else {
// $(".header").css("background", "#00000025");
// }
// })
// })
// var myIndex = 0;
// carousel();
// function carousel() {
// var i;
// var x = document.getElementsByClassName("mySlides");
// for (i = 0; i < x.length; i++) {
// x[i].style.display = "none";
// }
// myIndex++;
// if (myIndex > x.length) { myIndex = 1 }
// x[myIndex - 1].style.display = "block";
// setTimeout(carousel, 9000);
// }
$(document).ready(function() {
$('.button').click(function() {
$(this).addClass('active').siblings().removeClass('active');
var filter = $(this).attr('data-filter')
if (filter == 'all') {
$('.gallery .image').show(400);
} else {
$('.gallery .image').not('.' + filter).hide(200);
$('.gallery .image').filter('.' + filter).show(200);
}
});
$('.zoom-gallery').magnificPopup({
delegate: 'a',
type: 'image',
gallery: {
enabled: true,
}
});
});
const music = new Audio('vande.mp3');
// create Array
const songs = [{
id: '1',
songName: ` On My Way <br>
<div class="subtitle">Alan Walker</div>`,
poster: "img/1.jpg"
},
{
id: '2',
songName: ` Alan Walker-Fade <br>
<div class="subtitle">Alan Walker</div>`,
poster: "img/2.jpg"
},
// all object type
{
id: "3",
songName: `Cartoon - On & On <br><div class="subtitle"> Daniel Levi</div>`,
poster: "img/3.jpg",
},
{
id: "4",
songName: `Warriyo - Mortals <br><div class="subtitle">Mortals</div>`,
poster: "img/4.jpg",
},
{
id: "5",
songName: `Ertugrul Gazi <br><div class="subtitle">Ertugrul</div>`,
poster: "img/5.jpg",
},
{
id: "6",
songName: `Electronic Music <br><div class="subtitle">Electro</div>`,
poster: "img/6.jpg",
},
{
id: "7",
songName: `Agar Tum Sath Ho <br><div class="subtitle">Tamashaa</div>`,
poster: "img/7.jpg",
},
{
id: "8",
songName: `Suna Hai <br><div class="subtitle">Neha Kakker</div>`,
poster: "img/8.jpg",
},
{
id: "9",
songName: `Dilber <br><div class="subtitle">Satyameva Jayate</div>`,
poster: "img/9.jpg",
},
{
id: "10",
songName: `Duniya <br><div class="subtitle">Luka Chuppi</div>`,
poster: "img/10.jpg",
},
{
id: "11",
songName: `Lagdi Lahore Di <br><div class="subtitle">Street Dancer 3D</div>`,
poster: "img/11.jpg",
},
{
id: "12",
songName: `Putt Jatt Da <br><div class="subtitle">Putt Jatt Da</div>`,
poster: "img/12.jpg",
},
{
id: "13",
songName: `Baarishein <br><div class="subtitle">Atif Aslam</div>`,
poster: "img/13.jpg",
},
{
id: "14",
songName: `Vaaste <br><div class="subtitle">Dhvani Bhanushali</div>`,
poster: "img/14.jpg",
},
{
id: "15",
songName: `Lut Gaye <br><div class="subtitle">Jubin Nautiyal</div>`,
poster: "img/15.jpg",
},
]
Array.from(document.getElementsByClassName('songItem')).forEach((element, i) => {
if (!songs[i]) return;
element.getElementsByTagName('img')[0].src = songs[i].poster;
element.getElementsByTagName('h5')[0].innerHTML = songs[i].songName;
})
let masterPlay = document.getElementById('masterPlay');
let wave = document.getElementsByClassName('wave')[0];
masterPlay.addEventListener('click', () => {
if (music.paused || music.currentTime <= 0) {
music.play();
masterPlay.classList.remove('bi-play-fill');
masterPlay.classList.add('bi-pause-fill');
wave.classList.add('active2');
} else {
music.pause();
masterPlay.classList.add('bi-play-fill');
masterPlay.classList.remove('bi-pause-fill');
wave.classList.remove('active2');
}
})
const makeAllPlays = () => {
Array.from(document.getElementsByClassName('playListPlay')).forEach((element) => {
element.classList.add('bi-play-circle-fill');
element.classList.remove('bi-pause-circle-fill');
})
}
const makeAllBackgrounds = () => {
Array.from(document.getElementsByClassName('songItem')).forEach((element) => {
element.style.background = "rgb(105, 105, 170, 0)";
})
}
let index = 0;
let poster_master_play = document.getElementById('poster_master_play');
let title = document.getElementById('title');
Array.from(document.getElementsByClassName('playListPlay')).forEach((element) => {
element.addEventListener('click', (e) => {
index = e.target.id;
makeAllPlays();
e.target.classList.remove('bi-play-circle-fill');
e.target.classList.add('bi-pause-circle-fill');
music.src = `audio/${index}.mp3`;
poster_master_play.src = `img/${index}.jpg`;
music.play();
let song_title = songs.filter((ele) => {
return ele.id == index;
})
song_title.forEach(ele => {
let { songName } = ele;
title.innerHTML = songName;
})
masterPlay.classList.remove('bi-play-fill');
masterPlay.classList.add('bi-pause-fill');
wave.classList.add('active2');
music.addEventListener('ended', () => {
masterPlay.classList.add('bi-play-fill');
masterPlay.classList.remove('bi-pause-fill');
wave.classList.remove('active2');
})
makeAllBackgrounds();
Array.from(document.getElementsByClassName('songItem'))[`${index-1}`].style.background = "rgb(105, 105, 170, .1)";
})
})
let currentStart = document.getElementById('currentStart');
let currentEnd = document.getElementById('currentEnd');
let seek = document.getElementById('seek');
let bar2 = document.getElementById('bar2');
let dot = document.getElementsByClassName('dot')[0];
music.addEventListener('timeupdate', () => {
let music_curr = music.currentTime;
let music_dur = music.duration;
let min = Math.floor(music_dur / 60);
let sec = Math.floor(music_dur % 60);
if (sec < 10) {
sec = `0${sec}`
}
currentEnd.innerText = `${min}:${sec}`;
let min1 = Math.floor(music_curr / 60);
let sec1 = Math.floor(music_curr % 60);
if (sec1 < 10) {
sec1 = `0${sec1}`
}
currentStart.innerText = `${min1}:${sec1}`;
let progressbar = parseInt((music.currentTime / music.duration) * 100);
seek.value = progressbar;
let seekbar = seek.value;
bar2.style.width = `${seekbar}%`;
dot.style.left = `${seekbar}%`;
})
seek.addEventListener('change', () => {
music.currentTime = seek.value * music.duration / 100;
})
music.addEventListener('ended', () => {
masterPlay.classList.add('bi-play-fill');
masterPlay.classList.remove('bi-pause-fill');
wave.classList.remove('active2');
})
let vol_icon = document.getElementById('vol_icon');
let vol = document.getElementById('vol');
let vol_dot = document.getElementById('vol_dot');
let vol_bar = document.getElementsByClassName('vol_bar')[0];
vol.addEventListener('change', () => {
if (vol.value == 0) {
vol_icon.classList.remove('bi-volume-down-fill');
vol_icon.classList.add('bi-volume-mute-fill');
vol_icon.classList.remove('bi-volume-up-fill');
}
if (vol.value > 0) {
vol_icon.classList.add('bi-volume-down-fill');
vol_icon.classList.remove('bi-volume-mute-fill');
vol_icon.classList.remove('bi-volume-up-fill');
}
if (vol.value > 50) {
vol_icon.classList.remove('bi-volume-down-fill');
vol_icon.classList.remove('bi-volume-mute-fill');
vol_icon.classList.add('bi-volume-up-fill');
}
let vol_a = vol.value;
vol_bar.style.width = `${vol_a}%`;
vol_dot.style.left = `${vol_a}%`;
music.volume = vol_a / 100;
})
let back = document.getElementById('back');
let next = document.getElementById('next');
back.addEventListener('click', () => {
index -= 1;
if (index < 1) {
index = Array.from(document.getElementsByClassName('songItem')).length;
}
music.src = `audio/${index}.mp3`;
poster_master_play.src = `img/${index}.jpg`;
music.play();
let song_title = songs.filter((ele) => {
return ele.id == index;
})
song_title.forEach(ele => {
let { songName } = ele;
title.innerHTML = songName;
})
makeAllPlays()
document.getElementById(`${index}`).classList.remove('bi-play-fill');
document.getElementById(`${index}`).classList.add('bi-pause-fill');
makeAllBackgrounds();
Array.from(document.getElementsByClassName('songItem'))[`${index-1}`].style.background = "rgb(105, 105, 170, .1)";
})
next.addEventListener('click', () => {
index -= 0;
index += 1;
if (index > Array.from(document.getElementsByClassName('songItem')).length) {
index = 1;
}
music.src = `audio/${index}.mp3`;
poster_master_play.src = `img/${index}.jpg`;
music.play();
let song_title = songs.filter((ele) => {
return ele.id == index;
})
song_title.forEach(ele => {
let { songName } = ele;
title.innerHTML = songName;
})
makeAllPlays()
document.getElementById(`${index}`).classList.remove('bi-play-fill');
document.getElementById(`${index}`).classList.add('bi-pause-fill');
makeAllBackgrounds();
Array.from(document.getElementsByClassName('songItem'))[`${index-1}`].style.background = "rgb(105, 105, 170, .1)";
})
let left_scroll = document.getElementById('left_scroll');
let right_scroll = document.getElementById('right_scroll');
let pop_song = document.getElementsByClassName('pop_song')[0];
left_scroll.addEventListener('click', () => {
pop_song.scrollLeft -= 330;
})
right_scroll.addEventListener('click', () => {
pop_song.scrollLeft += 330;
})
let left_scrolls = document.getElementById('left_scroll');
let right_scrolls = document.getElementById('right_scroll');
let item = document.getElementsByClassName('item')[0];
left_scrolls.addEventListener('click', () => {
item.scrollLeft -= 330;
})
right_scrolls.addEventListener('click', () => {
item.scrollLeft += 330;
})
var swiper = new Swiper(".mySwiper", {
effect: "coverflow",
grabCursor: true,
centeredSlides: true,
slidesPerView: "auto",
coverflowEffect: {
rotate: 30,
stretch: 0,
depth: 200,
modifier: 1,
slideShadows: true,
},
loop: true,
autoplay: {
delay: 2500,
disableOnInteraction: false,
}
});
var testimonials = document.getElementById('testimonials');
var control1 = document.getElementById('control1');
var control2 = document.getElementById('control2');
var control3 = document.getElementById('control3');
control1.onclick = function() {
testimonials.style.transform = "translateX(870px)";
control1.classList.add("active");
control2.classList.remove("active");
control3.classList.remove("active");
}
control2.onclick = function() {
testimonials.style.transform = "translateX(0px)";
control1.classList.remove("active");
control2.classList.add("active");
control3.classList.remove("active");
}
control3.onclick = function() {
testimonials.style.transform = "translateX(-870px)";
control1.classList.remove("active");
control2.classList.remove("active");
control3.classList.add("active");
}
// let sidebar = document.querySelector(".sidebar");
// let closeBtn = document.querySelector("#btn");
// closeBtn.addEventListener("click", () => {
// sidebar.classList.toggle("open");
// menuBtnChange(); //calling the function(optional)
// });
// // searchBtn.addEventListener("click", () => { // Sidebar open when you click on the search iocn
// // sidebar.classList.toggle("open");
// // menuBtnChange(); //calling the function(optional)
// // });
// // following are the code to change sidebar button(optional)
// function menuBtnChange() {
// if (sidebar.classList.contains("open")) {
// closeBtn.classList.replace("bx-menu", "bx-menu-alt-right"); //replacing the iocns class
// } else {
// closeBtn.classList.replace("bx-menu-alt-right", "bx-menu"); //replacing the iocns class
// }
// }
$(document).ready(function() {
$(window).scroll(function() {
// var scroll = $(window).scrollTop();
// var timer = null;
// $(".sidebar").css("opacity", 0);
// window.addEventListener('scroll', function() {
// if (timer !== null) {
// clearTimeout(timer);
// }
// timer = setTimeout(function() {
// $(".sidebar").css("opacity", 1);
// }, 800);
// }, false);
// if (scroll > 350) {
// $(".sidebar").css("background", "transparent");
// } else {
// $(".sidebar").css("background", "#272727");
// }
sidebar.classList.remove("open");
menuBtnChange(); //calling the function(optional)
})
})
// document.addEventListener("click", (evt) => {
// const flyoutEl = document.querySelector(".sidebar");
// let targetEl = evt.target; // clicked element
// do {
// if (targetEl == flyoutEl) {
// // This is a click inside, does nothing, just return.
// return;
// }
// // Go up the DOM
// targetEl = targetEl.parentNode;
// } while (targetEl);
// // This is a click outside.
// $(".sidebar").css("opacity", 0);
// });
let sidebar = document.querySelector(".sidebar");
let closeBtn = document.querySelector("#btn");
let searchBtn = document.querySelector(".bx-search");
closeBtn.addEventListener("click", () => {
sidebar.classList.toggle("open");
menuBtnChange(); //calling the function(optional)
});
// following are the code to change sidebar button(optional)
function menuBtnChange() {
if (sidebar.classList.contains("open")) {
closeBtn.classList.replace("bx-menu", "bx-menu-alt-right"); //replacing the iocns class
} else {
closeBtn.classList.replace("bx-menu-alt-right", "bx-menu"); //replacing the iocns class
}
}
// document.querySelector('.toggleBar').onclick = () => {
// sidebar.classList.toggle('active');
// }
window.onscroll = () => {
sidebar.classList.remove('active');
}