-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotative.js
More file actions
40 lines (38 loc) · 1.18 KB
/
rotative.js
File metadata and controls
40 lines (38 loc) · 1.18 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
(function(global){
var adlayer = global.adlayer || {};
adlayer.plugins = adlayer.plugins || {};
var rotative = {
widget: 'spaces',
events: {},
cache: {},
init: function(spaces, timeout, cache){
var timeout = timeout * 1000;
rotative.events.placement = function(space){
if(spaces.indexOf(space.element.id) !== -1){
var interval = setInterval(function(){
rotative.cache[space.id] = rotative.cache[space.id] || [];
rotative.cache[space.id].push(space.element.innerHTML);
if(space.ads.length > 0) {
space.renderSpace(space);
} else {
clearInterval(interval);
var index = 0;
var cacheInterval = setInterval(function(){
space.element.innerHTML = '';
space.element.innerHTML = rotative.cache[space.id][index];
if(index < rotative.cache[space.id]['length']){
index++;
} else {
index = 0;
}
}, timeout);
}
},timeout);
}
}
}
}
adlayer.plugins.rotative = rotative;
})(window);
var spaces = ['5c659223469fc3bc283d555afb0b68e9', '5c659223469fc3bc283d555afb0b7fbc', '7be958944e5281d397971968070ae93e'];
adlayer.plugins.rotative.init(spaces, 20, true);