-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.tickertype.js
More file actions
executable file
·61 lines (56 loc) · 1.43 KB
/
jquery.tickertype.js
File metadata and controls
executable file
·61 lines (56 loc) · 1.43 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
58
59
60
61
// when the DOM is ready...
var tickerIterations = 0;
var currentTickerIteration = 0;
$(document).ready(function () {
// load the ticker
createTicker();
});
function createTicker(){
if (typeof $('#ticker-area').attr('alt') != 'undefined'){
tickerIterations = $('#ticker-area').attr('alt');
}
// put all list elements within #ticker-area into array
var tickerLIs = $("#ticker-area ul").children();
tickerItems = new Array();
tickerLIs.each(function(el) {
tickerItems.push( jQuery(this).html() );
});
i = 0
rotateTicker();
}
function rotateTicker(){
if( i == tickerItems.length ){
i = 0;
if( tickerIterations > 0 ){
console.log( "tickerIterations: " +tickerIterations );
currentTickerIteration++;
console.log( "currentTickerIteration: " + currentTickerIteration );
if( currentTickerIteration >= tickerIterations ){
console.log( "Done iterating" );
return false;
}
}
}
tickerText = tickerItems[i];
c = 0;
typetext();
setTimeout( "rotateTicker()", 5000 );
i++;
}
var isInTag = false;
function typetext() {
var thisChar = tickerText.substr(c, 1);
if( thisChar == '<' ){ isInTag = true; }
if( thisChar == '>' ){ isInTag = false; }
$('#ticker-area').html(" " + tickerText.substr(0, c++));
if(c < tickerText.length+1)
if( isInTag ){
typetext();
}else{
setTimeout("typetext()", 28);
}
else {
c = 1;
tickerText = "";
}
}