'use strict'; (function($) { $.fn.padmavideo = function(id, options) { var opts = $.extend({ 'layers': ['transcripts'], 'url': "http://pad.ma/api/", 'time_in': 0, 'time_out': 0, 'padma_base': 'http://pad.ma/', 'resolution': '480p', 'width': '640', 'interval': 400, 'action': 'get' //action POST param to send to url }, options); var $this = this; var keys = ['layers']; //FIXME: add more apt keys var $loading = $('
').addClass("padmaLoading").text("Loading video...").appendTo($this); var sendData = JSON.stringify({'id': id, 'keys': keys}); //alert("hi"); var deferred = $.post(opts.url, {'action': opts.action, 'data': sendData}, function(response) { $loading.hide().remove(); var padma = new PadmaVideo(id, response.data, $this, opts); padma.render(); }, "json"); deferred.error(function(data) { alert("failed to load video data"); }); }; var PadmaVideo = function(id, data, $el, opts) { this.id = id; this.data = data; this.$el = $el; this.o = opts; this.videoURL = opts.padma_base + id + "/" + opts.resolution + ".webm"; this.render = function() { var that = this; this.$el.empty(); this.$el.append(that.getWidget()); }; this.getWidget = function() { var that = this; var $container = this.$container = $('
').addClass("padmaContainer"); var $video = this.$video = $('