From c09ed1cd691cbbc2375a931d1c79329220390eb7 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 12 May 2012 12:36:02 +0530 Subject: [PATCH] use more efficient check to see if annots have changed, with basic idea from https://wiki.0x2620.org/browser/oxjs/source/Ox.UI/js/Video/Ox.AnnotationFolder.js --- index.html | 6 +- padmavideo.js | 326 -------------------------------------------------- 2 files changed, 3 insertions(+), 329 deletions(-) delete mode 100644 padmavideo.js diff --git a/index.html b/index.html index 4c63a12..0a46e1d 100644 --- a/index.html +++ b/index.html @@ -2,15 +2,15 @@ - + -
+
diff --git a/padmavideo.js b/padmavideo.js deleted file mode 100644 index ec3652a..0000000 --- a/padmavideo.js +++ /dev/null @@ -1,326 +0,0 @@ -'use strict'; - -(function($) { - $.fn.padmavideo = function(options) { - - //get options, giving preference, in order, to data- attributes defined on the html element, options passed when instantiatiing $(element).padmavideo(options), defaults. - var options = options || {}, - namespace = options.namespace || "padma", - $this = this; - - - var optionTypes = { - 'strings': ['api', 'base', 'resolution', 'action', 'id'], - 'integers': ['in', 'out', 'width', 'interval'], - 'arrays': ['layers', 'keys'], - 'booleans': [] - //'functions': ['callback'] FIXME: lets not. - }; - - var dataOptions = $.extend(options, $this.getDataOptions(optionTypes, namespace)); - - var opts = $.extend({ - 'id': 'ABC', //FIXME: throw an error if id is undefined at this point - 'layers': ['transcripts', 'descriptions', 'keywords', 'places'], - 'keys': ['layers'], //FIXME: add more apt keys - 'api': "http://pad.ma/api/", - 'in': 0, - 'out': 0, - 'padma_base': 'http://pad.ma/', - 'resolution': '480p', - 'width': '640', - 'interval': 400, - 'action': 'get', //action POST param to send to url - 'callback': function() { $.noop(); } //function to call after done instantiating PadmaVideo object, called with the object. - }, dataOptions); - - //get the padma id and instantiate a PadmaVideo object with the current element and render it and execute optional callback - var id = opts.id, - $loading = $('
').addClass("padmaLoading").text("Loading video...").appendTo($this), - sendData = JSON.stringify({'id': id, 'keys': opts.keys}); - - var deferred = $.post(opts.api, {'action': opts.action, 'data': sendData}, function(response) { - $loading.hide().remove(); - var padma = new PadmaVideo(id, response.data, $this, opts); - padma.render(); - opts.callback(padma); - }, "json"); - - deferred.error(function(data) { - alert("failed to load video data"); - }); - }; - - /* - PadmaVideo class - Parameters: - id: pandora video id - data: data for the video object - $el: - opts: options object - - */ - var PadmaVideo = function(id, data, $el, opts) { - this.id = id; - this.data = data; - this.$el = $el; - this.o = opts; - this.getVideoURL = function() { - return opts.padma_base + id + "/" + opts.resolution + ".webm"; - }; - //empties element, appends video widget - this.render = function() { - var that = this; - this.$el.empty(); - this.$el.append(that.getWidget()); - }; - - /* - Use this to set options on the player from the outside. - Example: - padmaVideoObject.setOption("width", 250); - */ - this.setOption = function(key, val) { - var that = this; - this.o[key] = val; - if ($.inArray(key, ['resolution']) != -1) { - this.destroy(); - this.render(); - return this; - } - if ($.inArray(key, ['in', 'out', 'layers']) != -1) { - this.updatePlayer(); - return this; - } - if ($.inArray(key, ['width']) != -1) { - this.$video.animate({'width': that.o.width + "px"}); - return this; - } - console.log("attempt to set invalid option or option which will make no difference to player state"); - }; - - - /* - Returns currently defined option for key specified - Parameters: - key: eg. 'width' - */ - this.getOption = function(key) { - return this.o[key] || "invalid option"; - }; - - - //returns widget for this PadmaVideo object - this.getWidget = function() { - var that = this; - var $container = this.$container = $('
').addClass("padmaContainer"); - var $video = this.$video = $('