-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrefresh.js
More file actions
57 lines (40 loc) · 1.53 KB
/
refresh.js
File metadata and controls
57 lines (40 loc) · 1.53 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
var refreshCounter = 0;
var amountInstagram = 0;
var amountTwitter = 0;
var maxAmount = 125; //refresh data every x times we've rotated
function refresh(){
var howOften = 5; //number often in seconds to rotate
//do a refresh on first run and when the list was completed
if (refreshCounter == 0 || refreshCounter % (maxAmount) == 0){
console.log("reloading instagram pictures");
refreshInstagram();
console.log("reloading twitter pictures");
refreshTwitter();
}
//if all Twitter and Instagram pictures are shown, restart both, else first finish either twitter or instagram list
if(amountTwitter == twitterPictures.length && amountInstagram == instagramPictures.length){
amountTwitter = 0;
amountInstagram = 0;
}
//switch between rotating instagram and twitter
//if (amountInstagram < instagramPictures.length|| amountTwitter <0){
if(refreshCounter % 2 == 0 && amountInstagram < instagramPictures.length){
console.log("going to rotate instagram picture");
rotateInstagram();
amountInstagram++;
} else if(amountTwitter < twitterPictures.length) {
console.log("going to rotate twitter picture");
rotateTweet();
amountTwitter++;
}else if (amountInstagram < instagramPictures.length){
console.log("going to rotate instagram picture because twitter was completed");
rotateInstagram();
amountInstagram--;
}
if(refreshCounter % 4 == 0){ //rotate every fourth run
console.log("going to rotate sponsor");
rotateSponsor();
}
refreshCounter++;
setTimeout("refresh()",howOften*1000);
}