summaryrefslogtreecommitdiff
path: root/static/js/src/youtube.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2012-07-18 00:02:21 -0400
committerJules Laplace <jules@okfoc.us>2012-07-18 00:02:21 -0400
commitc4338d2ae878a167c409e91dea6d1783fc7e30ba (patch)
tree1e54fac722ac3153f9180a5a8332f2b19e11c00c /static/js/src/youtube.js
parentd891a7ae1b205716c086363fba17a3249a665deb (diff)
put away back
Diffstat (limited to 'static/js/src/youtube.js')
-rw-r--r--static/js/src/youtube.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/static/js/src/youtube.js b/static/js/src/youtube.js
new file mode 100644
index 0000000..7b819dc
--- /dev/null
+++ b/static/js/src/youtube.js
@@ -0,0 +1,32 @@
+Youtube = {
+ "timer": 0,
+
+ "startAnimation": function(){
+ if (!Youtube.timer)
+ Youtube.timer = setTimeout(Youtube.animate, 1000)
+ },
+
+ "animate": function(){
+ var thumbs = $(".youtube-thumb")
+ thumbs.each(Youtube.nextThumb)
+ if (thumbs.length == 0){
+ clearTimeout(Youtube.timer)
+ Youtube.timer = 0
+ } else Youtube.timer = setTimeout(Youtube.animate, 1000);
+ },
+
+ "nextThumb": function(){
+ var img = $(this);
+ // yt thumb url is http://i.ytimg.com/vi/0123456789A/1.jpg
+ var v = img.attr("src").substr(22,11)
+ var num = img.attr("src").charAt(34);
+ img.attr("src", (Youtube.nextThumbUrl(v, num)))
+ },
+
+ "nextThumbUrl": function(v, num){
+ if (!num) num = 0;
+ num = (parseInt(num) % 3) + 1 // cycle over 1,2,3
+ return "http://i.ytimg.com/vi/" + v + "/" + num + ".jpg"
+ },
+
+}