Repository navigation
Expand file tree
/
Copy pathslideshow.js
More file actions
70 lines (42 loc) · 2.31 KB
/
Copy pathslideshow.js
File metadata and controls
70 lines (42 loc) · 2.31 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
var currentSlideIndex = -1;
var slides = ['<img class = "fadeinanimation" src = "./Images/slideshow1.jpg" style="width:100%">','<img class = "fadeinanimation" src = "./Images/slideshow2.png" style="width:100%">','<img class = "fadeinanimation" src = "./Images/slideshow3.png" style="width:100%;">'];
var dots = ['<span class = "dot" class = "active" id="dot1" onclick="currentSlide(1)" style = "background-color:#F0A500;"></span> <span class = "dot" id="dot2" onclick="currentSlide(2)"></span><span class = "dot" id="dot3" onclick="currentSlide(3)"></span>'
,'<span class = "dot" id="dot1" onclick="currentSlide(1)"></span> <span class = "dot" class = "active" id="dot2" onclick="currentSlide(2)" style = "background-color:#F0A500;"></span><span class = "dot" id="dot3" onclick="currentSlide(3)"></span>',
'<span class = "dot" id="dot1" onclick="currentSlide(1)"></span> <span class = "dot" id="dot2" onclick="currentSlide(2)"></span><span class = "dot" class = "active" id="dot3" onclick="currentSlide(3)" style = "background-color:#F0A500;"></span>'];
var userInteracts = true;
autoSlideMovement();
function autoSlideMovement(){
if(userInteracts){
currentSlideIndex++;
if(currentSlideIndex ==slides.length){
currentSlideIndex = 0;
}
document.getElementById("dotid").innerHTML = dots[currentSlideIndex];
document.getElementById("slideshow-image").innerHTML=slides[currentSlideIndex];
setTimeout(autoSlideMovement, 3000);
}
}
function currentSlide(x){
if (currentSlideIndex == slides.length) {
currentSlideIndex = 0;
}
if (currentSlideIndex < 0) {
currentSlideIndex = slides.length-1;
}
currentSlideIndex = x-1;
userInteracts = false;
document.getElementById("dotid").innerHTML = dots[currentSlideIndex];
document.getElementById("slideshow-image").innerHTML=slides[currentSlideIndex];
}
function plusSlides(n){
currentSlideIndex = currentSlideIndex + n;
if(currentSlideIndex == -1){
currentSlideIndex = slides.length - 1;
}
if(currentSlideIndex ==slides.length){
currentSlideIndex = 0;
}
userInteracts = false;
document.getElementById("dotid").innerHTML = dots[currentSlideIndex];
document.getElementById("slideshow-image").innerHTML=slides[currentSlideIndex];
}