-
Notifications
You must be signed in to change notification settings - Fork 5
/
sequencer.js
62 lines (41 loc) · 1.44 KB
/
sequencer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(function() {
var getElementsByClassName = function( node, classname ) {
// use native implementation if available
if (node.getElementsByClassName) {
return node.getElementsByClassName(classname);
} else {
return (function getElementsByClass(searchClass,node) {
if ( node === null ) {
node = document;
}
var classElements = [],
els = node.getElementsByTagName("*"),
elsLen = els.length,
pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"), i, j;
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
})(classname, node);
}
};
dashBoard.widget( "sequence", function( id, options ){
var sequences = getElementsByClassName( document.getElementById( id ), id ),
index = 0,
showSequence = function() {
sequences[ index++ ].style.display = "none";
if ( !sequences[ index ] ) {
index = 0;
}
sequences[ index ].style.display = "block";
setTimeout( showSequence, options.duration * 1000 );
};
for ( var i = 1, sl = sequences.length; i < sl; i++ ) {
sequences[ i ].style.display = "none";
}
setTimeout( showSequence, options.duration * 1000 );
});
})();