-
Notifications
You must be signed in to change notification settings - Fork 62
/
index.js
55 lines (45 loc) · 1.25 KB
/
index.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
var slideIndex = 0;
showSlide();
// var timer = setInterval(showSlide, 2000);
var slideContainer = document.getElementById('slideshow-container');
var slideControl = document.getElementById('slide-control');
slideContainer.onmouseover = function() {
clearInterval(timer);
}
slideControl.onmouseover = function() {
clearInterval(timer);
}
slideContainer.onmouseleave = function() {
// timer = setInterval(showSlide, 2000);
}
slideControl.onmouseleave = function() {
// timer = setInterval(showSlide, 2000);
}
function showSlide() {
var i;
var slides = document.getElementsByClassName('slide-item');
var dots = document.getElementsByClassName('dot');
for (var i = 0; i < slides.length; i++) {
slides[i].style.display = 'none';
}
for (var i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slideIndex++;
if (slideIndex > slides.length) slideIndex = 1;
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
function chooseSlide(n) {
slideIndex = n;
showSlide();
clearInterval(timer);
}
function showMenu() {
var topNav = document.getElementById('topnav');
if (topNav.className === "navbar") {
topNav.className += " show";
} else {
topNav.className = "navbar";
}
}