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
63
64
65
66
67
68
69
70
71
var TwitterTicker = function(options) {
	var twitter_reply = function(text) {
		return text.replace(/@([\w]+)/, '<a href="http://twitter.com/$1/" title="Twitter - $1">$&</a>');
	};
	
	var twitter_link = function(text) {
		return text.replace(/(http:\/\/[^ ]+)/, '<a href="$1" title="Enlace a $1">$1</a>');
	};
	
	options = jQuery.extend({
		box : jQuery('#twitter_box'),
		data : [],
		speed : 'slow',
		timeout : 5000
	}, options);
	
	var box = options.box;
	box.css('overflow', 'hidden');
	
	var twitWidth = box.width() + parseInt(box.css('padding-left')) + parseInt(box.css('padding-right'));
	var currentTwit = 0;
	var twitCount = options.data.length;
	var totalWidth = twitWidth*twitCount;
	
	var allTwitsDiv = jQuery('<div id="twitter_container"/>').css({
		'width' : totalWidth,
		'position' : 'relative'
	});
	allTwitsDiv.appendTo(box);	
	
	jQuery.each(options.data, function(i, item) {
		var body = twitter_reply(twitter_link('<span>' + item.text + '</span>'));
		var link = 'http://twitter.com/YoNoSoyTu/statuses/' + item.id;
		var twitDiv = jQuery('<div class="twitt" />')
		twitDiv.css({
			'float' : 'left',
			'position' : 'relative',
			'width' : twitWidth
		});
		twitDiv.append(jQuery(body));
		twitDiv.append(jQuery('<a class="no-underline" href="' + link + '" title="Twitter"> ⌘</a>'));
		allTwitsDiv.append(twitDiv);
	});
	
	var twit_rotator = function() {
		currentTwit = (currentTwit + 1) % twitCount;
		allTwitsDiv.animate({left : -currentTwit * twitWidth}, options.speed);
	};
	
	var rotator = setInterval(twit_rotator, options.timeout);
	
	box.hover(function() {
		clearInterval(rotator);
	}, function() {
		rotator = setInterval(twit_rotator, options.timeout);
		twit_rotator();
	});
};
 
if (!jQuery.browser.msie) {
jQuery(function() {
	var content = jQuery('#content');
	var twit_box = jQuery('<div id="twitter_box"/>');
	var feed_url = 'http://twitter.com/statuses/user_timeline/YoNoSoyTu.json?count=5&callback=?';
	jQuery.getJSON(feed_url, function(d) {
		new TwitterTicker({box : twit_box, data : d});
	});
	twit_box.prependTo(content);
	content.prepend(jQuery('<div id="pre_twitter_box" />'))
});
}