-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebkit_slider.js
44 lines (44 loc) · 1.49 KB
/
webkit_slider.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
//next slide
var slide = 1;
//total slides
var slides = 2;
function changeslide(){
switch(slide){
case 1:
//url for slide 1
slide1url = "/img/dummies/slides/1.webified.jpg";
//title for slide 1
slide1title = "Guinea Pig";
document.getElementById("sliderimg").style.backgroundImage="url(\""+slide1url+"\")";
document.getElementById("slidertitle").innerHTML=slide1title;
document.getElementById("slidernum").innerHTML=slide+"/"+slides;
if(slide == slides){
slide = 1;
}else{
slide++;
}
break;
case 2:
//url for slide 2
slide2url = "/img/dummies/slides/2.webified.jpg";
//title for slide 2
slide2title = "Carnivorous Flower";
document.getElementById("sliderimg").style.backgroundImage="url(\""+slide2url+"\")";
document.getElementById("slidertitle").innerHTML=slide2title;
document.getElementById("slidernum").innerHTML=slide+"/"+slides;
if(slide == slides){
slide = 1;
}else{
slide++;
}
break;
default:
slide = 1;
console.error("Fatal Error: Invalid slide!");
changeslide();
break;
}
}
changeslide();
//time in ms to automatically change slide
setInterval(changeslide, 8000);