From 794febfc6de3a3c31037c0c469c1062322fae302 Mon Sep 17 00:00:00 2001 From: sanj Date: Tue, 13 Jul 2010 00:39:53 +0530 Subject: [PATCH] added js files --- static/js/padmaLayer.js | 93 ++++++++++++++++++++++++++++++++ static/js/padmaSearch.js | 112 +++++++++++++++++++++++++++++++++++++++ static/js/padmaVideo.js | 103 +++++++++++++++++++++++++++++++++++ 3 files changed, 308 insertions(+) create mode 100644 static/js/padmaLayer.js create mode 100644 static/js/padmaSearch.js create mode 100644 static/js/padmaVideo.js diff --git a/static/js/padmaLayer.js b/static/js/padmaLayer.js new file mode 100644 index 0000000..0d351f6 --- /dev/null +++ b/static/js/padmaLayer.js @@ -0,0 +1,93 @@ +var padmaLayer = function(json, video) { + this.id = json.id; + this.video = video.index; //FIXME: Kept for legacy, please clean up. + this.padmaVideo = video; + this.time_in = json.time_in; + this.time_out = json.time_out; + this.time_in_npt = ms2npt(this.time_in); + this.time_out_npt = ms2npt(this.time_out); + this.track = json.track; + this.value = json.value; + this.shortValue = this.value.substring(0,100); //FIXME + this.value_html = json.value_html; + this.creator = json.creator; + var that = this; + this.firstFrameStr = BASE_URL + padmaVideos[this.video].id + "/frame/" + ms2npt(that.time_in); + this.firstFrame128 = this.firstFrameStr + ".128.jpg"; + this.firstFrame320 = this.firstFrameStr + ".320.jpg"; + this.lastFrameStr = BASE_URL + padmaVideos[this.video].id + "/frame/" + ms2npt(that.time_out); + this.lastFrame128 = this.lastFrameStr + ".128.jpg"; + this.lastFrame320 = this.lastFrameStr + ".320.jpg"; + this.videoSrc128 = this.padmaVideo.meta.urls['128'] + "?t=" + ms2npt(that.time_in); + this.videoSrc320 = this.padmaVideo.meta.urls['320'] + "?t=" + ms2npt(that.time_in); +// this.videoSrc128 = BASE_URL + "v/128/" + padmaVideos[this.video].id + ".ogv?t=" + ms2npt(that.time_in); +// this.videoSrc320 = BASE_URL + "v/320/" + padmaVideos[this.video].id + ".ogv?t=" + ms2npt(that.time_in); + } + +padmaLayer.prototype.showResult = function(word) { + var that = this; +// alert(word); + var html = tmpl("tmpl_layerResult", {'layer': that, 'word': word}); + this.resultJq = $('
').addClass("layerResult").addClass(that.track).attr("id", "layer" + that.id).html(html).data("layer", that); + this.padmaVideo.jq.find(".searchResults").append(that.resultJq); + return this; +} + +padmaLayer.prototype.addToClipBin = function() { + var that = this; + var html = tmpl("tmpl_clip", {'layer': that}); + this.clipJq = $('
').addClass('padmaClip').attr("id", "clip" + that.id).data("layer", that).html(html); + var height = Math.ceil(parseInt(that.padmaVideo.meta.stream_width) / that.padmaVideo.meta.aspectratio) + 16; + console.log(height); + $('#playBin').append(that.clipJq); + this.clipJq.css({'height': height + "px"}); +} + +padmaLayer.prototype.getThumbElem = function() { + var that = this; + var e = $('
'); + e.addClass('matchedLayer'); + e.attr("id", that.id); + var img = $(''); + if (that.firstFrame128) { + img.attr("src", that.firstFrame128); + e.append(img); + } + e.attr("data-track", that.track); + e.attr("data-value", that.value_html); + e.mouseover(function() { + var html = ''; + html += padmaVideos[that.video].title; + html += "
"; + html += $(this).attr('data-track'); + html += '
'; + html += $(this).attr('data-value'); + $('#resultDetails').html(html); + }).mouseout(function() { + $('#resultDetails').html(''); + }); + return e; + } + +padmaLayer.prototype.getVideoElem = function() { + var that = this; + var e = $('