-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (33 loc) · 798 Bytes
/
script.js
File metadata and controls
42 lines (33 loc) · 798 Bytes
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
$(document).ready(function () {
var gas = new Array("assets/img/gas1.jpg")
var gasNumber = 2;
var gasTotal = 24;
while (gasNumber < gasTotal) {
gasNumber++;
gas.push("assets/img/gas" + gasNumber + ".jpg")
}
var max = gas.length;
var currentImage = $("img").attr("src");
var currentID = currentImage.replace(/.*\.*\.jpg/, '$1');
var currentIndex = 0
while (currentIndex < max) {
if (gas[currentIndex] == currentID) {
break;
}
currentIndex++;
}
$(function() {
$("img").click(function(){
currentIndex = (currentIndex + 1) % max;
$("img").attr('src', gas[currentIndex]);
});
});
function timer() {
setInterval( function() {
currentIndex = (currentIndex + 1) % max;
$("img").attr('src', gas[currentIndex]);
}, 4000)
clearTimeout();
}
window.onload=timer();
});