From 829f1a31b3e8c3fc33f2c9f65c54ffaa83f4ff48 Mon Sep 17 00:00:00 2001 From: sanj Date: Sun, 14 Nov 2010 07:27:18 +0530 Subject: [PATCH] added license, some optimizations --- COPYING | 14 ++++ padma.layers.js | 46 ++++++++++--- padma.links.js | 18 +++++- text.css | 147 ++++++++++++++++++++++++++++++++++++++++++ text.js | 167 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 379 insertions(+), 13 deletions(-) create mode 100644 COPYING create mode 100644 text.css create mode 100644 text.js diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..5a8e332 --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/padma.layers.js b/padma.layers.js index 4a875bf..2607464 100644 --- a/padma.layers.js +++ b/padma.layers.js @@ -8,7 +8,9 @@ var padmaVideo = function(videoId) { this.hasLayersData = false; this.hasAllData = false; this.video = {}; - this.layers = {}; + this.layers = {}; + var that = this; + padmaVideo.cache.push(that); } padmaVideo.prototype.getAllData = function(callback, data) { @@ -55,20 +57,31 @@ padmaVideo.prototype.noop = function() { } padmaVideo.prototype.getVideoData = function(callback, data) { + + var that = this; - $.getScript(that.videoUrl, function() { - that.video = video; - that.hasVideoData = true; + if (this.hasVideoData) { callback(that, data); - }); + } else { + $.getScript(that.videoUrl, function() { + that.video = video; + that.hasVideoData = true; + callback(that, data); + }); + } } -padmaVideo.prototype.getLayersData = function() { +padmaVideo.prototype.getLayersData = function(callback, data) { var that = this; - $.getScript(layersUrl, function() { - that.layers = layers; - that.hasLayersData = true; - }); + if (this.hasLayersData) { + callback(that, data); + } else { + $.getScript(that.layersUrl, function() { + that.layers = layers; + that.hasLayersData = true; + callback(that, data); + }); + } } padmaVideo.prototype.getLayerById = function(id) { @@ -124,3 +137,16 @@ function filterLayersByContributors(layers, users) { } return matchedLayers; } + +padmaVideo.cache = []; + +padmaVideo.getFromCache = function(videoId) { + var cache = padmaVideo.cache; + for (var i=0; i 0) { + var annotHtml = transcripts[0].value_html; + } else { + var annotHtml = ''; + } + $('.annotationText').html(annotHtml); + /* + var closeBtn = $('
') + .addClass("close") + .click(function() { + sidebarAnimateOut(); + }) + .text("x") + .appendTo('.padmaViewer'); + */ + var videoElem = $('video'); + // var videoObj = video; + + videoElem.bind("play", function() { + var that = this + videoObj.interval = setInterval(function() { + var currentTime = parseInt(that.currentTime * 1000); + var time_ms = currentTime + npt2ms(linkData.tcIn); + var allLayers = videoObj.getLayersAtTimecode(time_ms); + if (videoObj.currentLayers == allLayers) { + return; + } + // GLOBAL_FOO = allLayers; + var transcript = filterLayersByTracks(allLayers, ['transcript'])[0].value_html; + if (transcript != $('.annotationText').html()) { + $('.annotationText').html(transcript); + } + }, 150); + }); + + videoElem.bind("pause", function() { + clearInterval(videoObj.interval); + }); + + videoElem.bind("ended", function() { + clearInterval(videoObj.interval); + // cleanupVideo(videoObj); + sidebarAnimateOut(); + }); + } + function sidebarAnimateIn() { + /* + $container.animate({'width': '400px'}, function() { + $(this).animate({'backgroundColor': '#000000'}); + }); + var docWidth = $(document).width(); + var newWidth = docWidth - 440; + $('#essay').animate({'width': newWidth + "px"}); + */ +// $container.show(); + $('#aboutTxt').fadeOut(); + } + + function sidebarAnimateOut() { + $container.find('.padmaViewer').empty(); + $('#aboutTxt').show(); + + /* + $container.animate({'width': '0px'}, function() { + $(this).animate({'backgroundColor': '#ffffff'}); + }); + $('#essay').animate({'width': '100%'}); + */ + } + + function isSidebarVisible() { + if (padmaContainer.width() > 0) { + return true; + } else { + return false; + } + } + }); +} + +//All functions that destroy the video must call this to ensure clean-ups are handled +//FIXME: actually handle the cleanups. +// parameter is a padmaVideo object. +function cleanupVideo(videoObj) { + $('video')[0].pause(); + clearInterval(videoObj.interval); + $('.padmaViewer').remove(); + padmaContainer.data("currentVideo", false); +}