-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
83 lines (72 loc) · 2.09 KB
/
app.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
let items = document.querySelectorAll('.slider .list .item');
let next = document.getElementById('next');
let prev = document.getElementById('prev');
let thumbnails = document.querySelectorAll('.thumbnail .item');
// config param
let countItem = items.length;
let itemActive = 0;
// event next click
next.onclick = function(){
itemActive = itemActive + 1;
if(itemActive >= countItem){
itemActive = 0;
}
showSlider();
}
//event prev click
prev.onclick = function(){
itemActive = itemActive - 1;
if(itemActive < 0){
itemActive = countItem - 1;
}
showSlider();
}
// auto run slider
let refreshInterval = setInterval(() => {
next.click();
}, 10000)
function showSlider(){
// remove item active old
let itemActiveOld = document.querySelector('.slider .list .item.active');
let thumbnailActiveOld = document.querySelector('.thumbnail .item.active');
itemActiveOld.classList.remove('active');
thumbnailActiveOld.classList.remove('active');
// active new item
items[itemActive].classList.add('active');
thumbnails[itemActive].classList.add('active');
// clear auto time run slider
clearInterval(refreshInterval);
refreshInterval = setInterval(() => {
next.click();
}, 10000)
}
// click thumbnail
thumbnails.forEach((thumbnail, index) => {
thumbnail.addEventListener('click', () => {
itemActive = index;
showSlider();
})
})
function abrirPDF() {
window.location.href = 'ruta/del/archivo.pdf';
}
function redirigir() {
window.location.href = "html/projects.html";
}
function rest_food(){
window.location.href = "https://github.com/ValenMorales/RestFood";
}
function sharability(){
window.location.href = "https://github.com/ValenMorales/practice";
}
function codebeaters()
{
window.location.href = "https://github.com/JustTwoDevs";
}
function chatapp()
{
window.location.href = "https://github.com/ValenMorales/chat-app";
}
function datastructures(){
window.location.href = "https://github.com/ValenMorales/final-proyect";
}