From 6262e918c2ba72f468f09809e035de61727cf4fe Mon Sep 17 00:00:00 2001 From: Anna Sobiepanek Date: Wed, 30 Jun 2010 10:29:09 -0400 Subject: [PATCH] preliminary wiki stuff --- index.html | 1 + popcorn.js | 46 +++++++++++++++++++++++++++++++++++++++++++ xml/webMadeMovies.xml | 3 ++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 032be81..64d1631 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@

+



In this video:

diff --git a/popcorn.js b/popcorn.js index 03621ae..6a504e8 100644 --- a/popcorn.js +++ b/popcorn.js @@ -317,7 +317,48 @@ this.target.setAttribute('style', 'display:none'); }; }; + + //////////////////////////////////////////////////////////////////////////// + // Wiki Command + //////////////////////////////////////////////////////////////////////////// + + var WikiCommand = function(name, params, text, videoManager) { + VideoCommand.call(this, name, params, text, videoManager); + + var src = this.params.src; + // 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://en.wikipedia.org/w/api.php?action=parse&props=text&page=" + this.params.title+ "&format=json&callback=?", function(data){ + //$.each(data.parse, function(i, item) { + var link = document.createElement('a'); + link.setAttribute('href', src); + var p = document.createElement('p'); + p.innerHTML = data.parse.displaytitle; + link.appendChild(p); + var desc = document.createElement('p'); + //((<(.|\n)+?>)|\[(.*?)\]|\((.*?)\)) + var text = data.parse.text.*.substr(data.parse.text.*.indexOf('

')); + text = text.replace(/(<(.|\n)+?>)|\((.*?)\)|\[(.*?)\]/g, ""); + alert(text);desc.innerHTML = text; + target.appendChild(link); + target.appendChild(desc); + //}); + }); + this.target = target; + //this.onIn = function() { + this.target.setAttribute('style', 'display:inline'); + //}; + this.onOut = function() { + //this.target.setAttribute('style', 'display:none'); + }; + }; //////////////////////////////////////////////////////////////////////////// // Footnote Command //////////////////////////////////////////////////////////////////////////// @@ -440,6 +481,11 @@ create: function(name, params, text, videoManager) { return new FlickrCommand(name, params, text, videoManager); } + }, + wiki: { + create: function(name, params, text, videoManager) { + return new WikiCommand(name, params, text, videoManager); + } } }; diff --git a/xml/webMadeMovies.xml b/xml/webMadeMovies.xml index 33ca285..3879aec 100644 --- a/xml/webMadeMovies.xml +++ b/xml/webMadeMovies.xml @@ -23,7 +23,7 @@ - + @@ -60,6 +60,7 @@ + A Shared Culture, Jesse Dylan -- 2.43.0