-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarousel_fax_rotator.js
43 lines (36 loc) · 1.02 KB
/
carousel_fax_rotator.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
//Questo script si occupa di rendere visibile un DIV alla volta di quelli contrassegnati con
//class="carousel1...6"
cimage = 0;
function changeCarouselImage() {
var allElements = document.querySelectorAll('[class]');
var counter=0;
//If you want... we can count the number of DIVs to rotate in real-time...
/*
Array.prototype.forEach.call( allElements, function( el, i ) {
//"el" is your element
if (el.className.startsWith("carousel") ) {
counter++;
}
});
*/
//Or you can set a fixed number of DIVs.
counter=6; //Number of DIVs to rotate...
if ( cimage >= counter ) {
cimage=1;
} else {
cimage++;
}
Array.prototype.forEach.call( allElements, function( el, i ) {
//"el" is your element
if (el.className.startsWith("carousel") ) {
if (el.className.endsWith(cimage)) {
//Make it visible
el.style.display = "block";
} else {
//Make it invisible
el.style.display = "none";
}
}
});
}
setInterval(changeCarouselImage, 500);