From: rwldrn '+ data.artist.bio.summary +'
" + result.translation;
- });
- } else {
- var span = document.createElement('span');
- span.innerHTML = (this.params.salutation || "") + " " + (this.params.name || "");
- span.setAttribute('style', 'font-size:26px;');
- this.target.appendChild(span);
- this.target.innerHTML += "
" + (this.params.role || "");
- }
- };
- this.onOut = function() {
- this.target.innerHTML = "";
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // GoogleNews Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.GoogleNewsCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- this.target = document.createElement('div');
- this.target.setAttribute('style', 'display:none;border:0px;');
- document.getElementById(this.params.target).appendChild(this.target);
- this.target.setAttribute('id', this.id);
- var content = document.getElementById(this.id);
- var options = {
- format : "300x250",
- queryList : [
- {q: this.params.topic || "Top Stories"}
- ]
- };
- var newsShow = new google.elements.NewsShow(content, options);
-
- this.onIn = function() {
- this.target.setAttribute('style', 'display:inline');
- $("a").each(function() {
- this.setAttribute('target', '_blank');
- });
- document.getElementById(this.params.target).style.display = "inline";
- };
- this.onOut = function() {
- this.target.setAttribute('style', 'display:none');
- document.getElementById(this.params.target).style.display = "none";
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // TagThisPerson Command
- ////////////////////////////////////////////////////////////////////////////
-
- var people = function(){
- this.contains = {};
- this.toString = function() {
- var r = [];
- for (var i in this.contains) {
- if (this.contains.hasOwnProperty(i)) {
- r.push(" " + this.contains[i]);
- }
- }
- return r.toString();
- };
- };
- popcorn.TagCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
-
- if (!popcorn.TagCommand[this.params.target]) {
- popcorn.TagCommand[this.params.target] = new people();
- }
-
- this.onIn = function() {
- popcorn.TagCommand[this.params.target].contains[this.text] = this.text;
- document.getElementById(this.params.target).innerHTML = popcorn.TagCommand[this.params.target].toString();
- };
- this.onOut = function() {
- delete popcorn.TagCommand[this.params.target].contains[this.text];
- document.getElementById(this.params.target).innerHTML = popcorn.TagCommand[this.params.target].toString();
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // Map Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.MapCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
-
- // All data from Universal Subtitles comes from the text attribute
- // so the data from that needs to enter the appropriate fields
- if (typeof this.text === "string" && this.text !== "") {
- // Universal Subtitles has no target attribute, so we create a default
- this.params.target = "mapdiv";
- var split = this.text.split(", ");
- this.params.lat = split[0];
- this.params.long = split[1];
- this.params.zoom = split[2];
- }
- this.params.zoom = parseInt(this.params.zoom, 10);
- // load the map
- // http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions <-- Map API
- this.location = new google.maps.LatLng(this.params.lat, this.params.long);
- if (!popcorn.MapCommand[this.params.target]) {
- popcorn.MapCommand[this.params.target] = new google.maps.Map(document.getElementById(this.params.target), {mapTypeId: google.maps.MapTypeId.HYBRID});
- popcorn.MapCommand[this.params.target].setCenter(new google.maps.LatLng(0, 0));
- popcorn.MapCommand[this.params.target].setZoom(0);
- }
- this.onIn = function() {
- popcorn.MapCommand[this.params.target].setCenter(this.location);
- popcorn.MapCommand[this.params.target].setZoom(this.params.zoom);
- if (this.params.src && this.params.mapinfo) {
- var link = document.createElement("a");
- link.setAttribute("href", this.params.src);
- link.setAttribute("target", "_blank");
- link.appendChild(document.createTextNode(this.params.description||this.params.src));
- document.getElementById(this.params.mapinfo).appendChild(link);
- }
- };
- this.onOut = function() {
- popcorn.MapCommand[this.params.target].setCenter(new google.maps.LatLng(0, 0));
- popcorn.MapCommand[this.params.target].setZoom(0);
- if (this.params.mapinfo) {
- document.getElementById(this.params.mapinfo).innerHTML = "";
- }
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // Lastfm Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.LastfmCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- // Setup a default, hidden div to hold the images
- var target = document.createElement('div');
- target.setAttribute('id', this.id);
- document.getElementById(this.params.target).appendChild(target);
- // Div is hidden by default
- target.setAttribute('style', 'display:none');
- var htmlString = '';
-
- // This uses jquery
- $.getJSON("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ this.params.artist +"&api_key=30ac38340e8be75f9268727cb4526b3d&format=json&callback=?",
- function(data){
- htmlString += ''+data.artist.name+'
';
- htmlString += '';
- htmlString += '
Tags
';
- $.each(data.artist.tags.tag, function(i,val) {
- htmlString += '
" + data.title + "
"; - $.each(data.items, function(i, item) { - if (i < count) { - var link = document.createElement('a'); - link.setAttribute('href', item.link); - link.setAttribute("target", "_blank"); - var image = document.createElement('img'); - image.setAttribute('src', item.media.m); - image.setAttribute('height', height); - image.setAttribute('width', width); - image.setAttribute('style', 'border:' + border + ';padding:' + padding); - link.appendChild(image); - target.appendChild(link); - } else { - return false; - } - }); - }); - this.target = target; - - this.onIn = function() { - this.target.style.display = "inline";//.setAttribute('style', 'display:inline'); - document.getElementById(this.params.target).style.display = "inline"; - }; - this.onOut = function() { - this.target.style.display = "none";//.setAttribute('style', 'display:none'); - document.getElementById(this.params.target).style.display = "none"; - }; - }; - - //////////////////////////////////////////////////////////////////////////// - // Wiki Command - //////////////////////////////////////////////////////////////////////////// - - popcorn.WikiCommand = function(name, params, text, videoManager) { - popcorn.VideoCommand.call(this, name, params, text, videoManager); - - // All data from Universal Subtitles comes from the text attribute - // so the data from that needs to enter the appropriate fields - if (typeof text === "string" && text !== "") { - this.params.src = text; - // Universal Subtitles has no target attribute, so we create a default - this.params.target = "wikidiv"; - } - - //L10n - var src = this.params.src; - var lang = this.params.lang; - if (typeof lang === 'undefined') {lang="en";} - //end L10n - - var length = this.params.numberOfWords || 200; - // Setup a default, hidden div to hold the images - var target = document.createElement('div'); - target.setAttribute('id', this.id); - document.getElementById(this.params.target).appendChild(target); - // Div is hidden by default - target.setAttribute('style', 'display:none'); - // This uses jquery - $.getJSON("http://"+lang+".wikipedia.org/w/api.php?action=parse&props=text&page=" + ( this.params.title || src.slice(src.lastIndexOf("/")+1) ) + "&format=json&callback=?", function(data){ - if(data) { - //make a link to the document - var link = document.createElement('a'); - link.setAttribute('href', src); - link.setAttribute('target', '_blank'); - var p = document.createElement('p'); - p.innerHTML = data.parse.displaytitle; - link.appendChild(p); - // get the first 140 characters of the wiki content - var desc = document.createElement('p'); - var text = data.parse.text["*"].substr(data.parse.text["*"].indexOf(''));
- text = text.replace(/((<(.|\n)+?>)|(\((.*?)\) )|(\[(.*?)\]))/g, "");
- desc.innerHTML = text.substr(0, ( length || 140 )) + " ...";
- target.appendChild(link);
- target.appendChild(desc);
- }
- });
-
- this.target = target;
- this.onIn = function() {
- this.target.setAttribute('style', 'display:inline');
- document.getElementById(this.params.target).style.display = "block";
-
- };
- this.onOut = function() {
- this.target.setAttribute('style', 'display:none');
- document.getElementById(this.params.target).style.display = "none";
- };
- };
- ////////////////////////////////////////////////////////////////////////////
- // Footnote Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.FootnoteCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- this.onIn = function() {
- document.getElementById(this.params.target).innerHTML = this.text;
- };
- this.onOut = function() {
- document.getElementById(this.params.target).innerHTML = "";
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // Attribution Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.AttributionCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- var attribution = "";
- var image = "";
-
- if (this.params.nameofworkurl) {
- attribution += "";
- }
- if (this.params.nameofwork) {
- attribution += this.params.nameofwork;
- }
- if (this.params.nameofworkurl) {
- attribution += "";
- }
- if (this.params.copyrightholderurl) {
- attribution += "";
- }
- if (this.params.copyrightholder) {
- attribution += ", " + this.params.copyrightholder;
- }
- if (this.params.copyrightholderurl) {
- attribution += "";
- }
- if (this.params.license) {
- if (this.params.license.toUpperCase() === "CC-BY" ) {
- image = "";
- } else if (this.params.license.toUpperCase() === "CC-BY-SA") {
- image = "
";
- } else if (this.params.license.toUpperCase() === "CC-BY-ND") {
- image = "
";
- } else if (this.params.license.toUpperCase() === "CC-BY-NC") {
- image = "
";
- } else if (this.params.license.toUpperCase() === "CC-BY-NC-SA") {
- image = "
";
- } else if (this.params.license.toUpperCase() === "CC-BY-NC-ND") {
- image = "
";
- }
- if (image) {
- attribution = image + " " +attribution;
- } else {
- attribution += ", license: " + this.params.license;
- }
- }
- if (this.params.licenseurl) {
- attribution += ", License URL";
- }
- //if the user did not specify any parameters just pull the text from the tag
- if (attribution === "") {
- attribution = this.text;
- }
- this.onIn = function() {
- document.getElementById(this.params.target).innerHTML = attribution;
- document.getElementById(this.params.target).style.display = "block";//setAttribute('style', 'display:inline');
- };
- this.onOut = function() {
- document.getElementById(this.params.target).innerHTML = "";
- document.getElementById(this.params.target).style.display = "none";//.setAttribute('style', 'display:none');
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // Warp Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.SeekCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- this.params["in"] = toSeconds(this.params.seekfrom);
- this.params["out"] = toSeconds(this.params.seekfrom) + 1;
- this.params.seekto = toSeconds(this.params.seekto);
- this.onIn = function() {
- this.videoManager.videoElement.currentTime = this.params.seekto;
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // Script Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.ScriptCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
- this.start = eval(this.params.start) || function() {};
- this.stop = eval(this.params.stop) || function() {};
- this.onIn = function() {
- this.start();
- };
- this.onOut = function() {
- this.stop();
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // WebPage Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.WebPageCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
-
- // Setup a default, iframe to hold the website
- var target = document.createElement('iframe');
- target.setAttribute('src', this.params.src);
- target.setAttribute('width', this.params.width);
- target.setAttribute('height', this.params.height);
- target.setAttribute('id', this.id);
- document.getElementById(this.params.target).appendChild(target);
- // iframe is hidden by default
- target.setAttribute('style', 'display:none');
- // toggle display of the iframe
- this.target = target;
- this.onIn = function() {
- this.target.setAttribute('style', 'display:inline');
- };
- this.onOut = function() {
- this.target.setAttribute('style', 'display:none');
- };
- };
- ////////////////////////////////////////////////////////////////////////////
- // Image Command
- ////////////////////////////////////////////////////////////////////////////
-
- popcorn.ImageCommand = function(name, params, text, videoManager) {
- popcorn.VideoCommand.call(this, name, params, text, videoManager);
-
- var src = this.params.src;
- // Setup a default, hidden div to hold the image
- var target = document.createElement('div');
- target.setAttribute('id', this.id);
-
- // Div is hidden by default
- target.setAttribute('style', 'display:none');
- var image = document.createElement('img');
- image.setAttribute('src', this.params.src);
- image.setAttribute('height', this.params.height);
- image.setAttribute('width', this.params.width);
- target.appendChild(image);
- //apend to the target div provided in the xml
- document.getElementById(this.params.target).appendChild(target);
-
- this.target = target;
- this.onIn = function() {
- this.target.setAttribute('style', 'display:inline');
- document.getElementById(this.params.target).style.display = "block";
-
- };
- this.onOut = function() {
- this.target.setAttribute('style', 'display:none');
- document.getElementById(this.params.target).style.display = "none";
- };
- };
- // Wrapper for accessing commands by name
- // commands[name].create() returns a new command of type name
- // Not sure if this is the best way; maybe it's too fancy?
- // I liked it more than a switch, though
- var commands = {
- subtitle: {
- create: function(name, params, text, videoManager) {
- return new popcorn.SubtitleCommand(name, params, text, videoManager);
- }
- },
- flickr: {
- create: function(name, params, text, videoManager) {
- return new popcorn.FlickrCommand(name, params, text, videoManager);
- }
- },
- videotag: {
- create: function(name, params, text, videoManager) {
- return new popcorn.TagCommand(name, params, text, videoManager);
- }
- },
- location: {
- create: function(name, params, text, videoManager) {
- return new popcorn.MapCommand(name, params, text, videoManager);
- }
- },
- footnote: {
- create: function(name, params, text, videoManager) {
- return new popcorn.FootnoteCommand(name, params, text, videoManager);
- }
- },
- twitter: {
- create: function(name, params, text, videoManager) {
- return new popcorn.TwitterCommand(name, params, text, videoManager);
- }
- },
- attribution: {
- create: function(name, params, text, videoManager) {
- return new popcorn.AttributionCommand(name, params, text, videoManager);
- }
- },
- googlenews: {
- create: function(name, params, text, videoManager) {
- return new popcorn.GoogleNewsCommand(name, params, text, videoManager);
- }
- },
- wiki: {
- create: function(name, params, text, videoManager) {
- return new popcorn.WikiCommand(name, params, text, videoManager);
- }
- },
- lastfm: {
- create: function(name, params, text, videoManager) {
- return new popcorn.LastfmCommand(name, params, text, videoManager);
- }
- },
- lowerthird: {
- create: function(name, params, text, videoManager) {
- return new popcorn.LowerThirdCommand(name, params, text, videoManager);
- }
- },
- seek: {
- create: function(name, params, text, videoManager) {
- return new popcorn.SeekCommand(name, params, text, videoManager);
- }
- },
- script: {
- create: function(name, params, text, videoManager) {
- return new popcorn.ScriptCommand(name, params, text, videoManager);
- }
- },
- webpage: {
- create: function(name, params, text, videoManager) {
- return new popcorn.WebPageCommand(name, params, text, videoManager);
- }
- },
- image: {
- create: function(name, params, text, videoManager) {
- return new popcorn.ImageCommand(name, params, text, videoManager);
- }
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // XML Converter
- ////////////////////////////////////////////////////////////////////////////
-
- // Converts xml into command objects and adds them to the video manager
- var convertXML = function(xmlDoc, videoManager) {
-
- var parseNode = function(node, attributes, manifest) {
- var allAttributes = attributes.slice(0);
- allAttributes.push(node.attributes);
- var childNodes = node.childNodes;
- if (childNodes.length < 1 || (childNodes.length === 1 && childNodes[0].nodeType === 3)) {
- if (!manifest) {
- videoManager.addCommand(commands[node.nodeName].create(node.nodeName, allAttributes, node.textContent, videoManager));
- } else {
- videoManager.addManifestObject(allAttributes);
- }
- } else {
- for (var i = 0; i < childNodes.length; i++) {
- if (childNodes[i].nodeType === 1) {
- parseNode(childNodes[i], allAttributes, manifest);
- }
- }
- }
- };
-
- var x = xmlDoc.documentElement.childNodes;
- for (var i = 0, xl = x.length; i < xl; i++) {
- if (x[i].nodeType === 1) {
- if (x[i].nodeName === "manifest") {
- parseNode(x[i], [], true);
- } else {
- parseNode(x[i], [], false);
- }
- }
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////
- // JSON Converter
- ////////////////////////////////////////////////////////////////////////////
-
- // Converts json into command objects and adds them to the video manager
- var convertJSON = function(jsonData, videoManager, type) {
-
- // loops through subtitles in the json
- for (var j = 0, jl = jsonData.length; j < jl; j++) {
- var allAttributes = [],
- attributes = [],
- l = 0,
- text = "";
- // loops through attributes inside command, and packages them similar to how the xml data looks
- for (var attribute in jsonData[j]) {
- if (jsonData[j].hasOwnProperty(attribute)) {
- if (attribute === "text") {
- text = jsonData[j][attribute];
- } else {
- attributes.push({"nodeName":attribute,"nodeValue":jsonData[j][attribute]});
- l++;
- }
- }
- }
- allAttributes = [];
- // this object mimics the object used for xml
- allAttributes.push({
- "att": attributes.slice(0),
- "item": (function() {
- return function(i) {
- return this.att[i];
- };
- }()),
- "length": l
- });
- videoManager.addCommand(commands[type].create(type, allAttributes, text, videoManager));
- }
- };
-
- var convertData = function(video, manager, data, convert, type) {
- var si = setInterval(function() {
- if (video.readyState < 1) { return; }
- clearInterval(si);
- convert(data, manager, type);
- manager.loaded();
- }, 50);
- };
-
- // Loads an external xml file, and returns the xml object
- var getTimelineData = function(name) {
- var xhttp = new XMLHttpRequest();
- if (xhttp) {
- xhttp.open("GET", name, false);
- xhttp.send();
- return xhttp;
- } else {
- return false;
- }
- };
-
- // Automatic Initialization Method
- var init = function() {
- getScript('http://code.jquery.com/jquery.js', typeof jQuery, function() {
- var video = document.getElementsByTagName('video');
- for (var i = 0, l = video.length; i < l; i++) {
- var ind = i;
- var videoSources = video[ind].getAttribute('data-timeline-sources');
- if (videoSources) {
- var filename = videoSources,
- dataXML = "",
- dataJSON = "";
- var ext = (filename.toLowerCase()).match(/\.xml$/);
- var manager = new popcorn.VideoManager(video[ind]);
- if (ext !== null) {
- convertData(video[ind], manager, getTimelineData(filename).responseXML, convertXML);
- } else {
- $.getJSON("http://dev.universalsubtitles.org/api/subtitles/?video_url=" + filename + "&callback=?", (function() {
- return function(data) {
- convertData(video[ind], manager, data, convertJSON, "subtitle");
- $.getJSON("http://dev.universalsubtitles.org/api/subtitles/?video_url=" + filename + "&language=meta-geo&callback=?", (function() {
- return function(data) {
- convertData(video[ind], manager, data, convertJSON, "location");
- $.getJSON("http://dev.universalsubtitles.org/api/subtitles/?video_url=" + filename + "&language=meta-tw&callback=?", (function() {
- return function(data) {
- convertData(video[ind], manager, data, convertJSON, "twitter");
- $.getJSON("http://dev.universalsubtitles.org/api/subtitles/?video_url=" + filename + "&language=meta-wiki&callback=?", (function() {
- return function(data) {
- convertData(video[ind], manager, data, convertJSON, "wiki");
- };
- }()));
- };
- }()));
- };
- }()));
- };
- }()));
-=======
(function(global, document) {
// Cache refs to speed up calls to native utils
@@ -1918,20 +878,10 @@
// Only play the video if it was specified to do so
if ( !!popcornVideo.autoplay ) {
popcornVideo.play();
->>>>>>> 1bbbbc011cb63ac2a33b7de34c1a52387d5963f2
}
}
}
});
-<<<<<<< HEAD
- };
-
- document.addEventListener('DOMContentLoaded', init, false);
-
-}());
-
-=======
}, false );
})(window, window.document);
->>>>>>> 1bbbbc011cb63ac2a33b7de34c1a52387d5963f2