From ca25c2252b342ae04afe96d476cb737108eda2c2 Mon Sep 17 00:00:00 2001 From: Anna Sobiepanek Date: Wed, 30 Jun 2010 12:59:46 -0400 Subject: [PATCH] final touches [#33 state:peer-review-requested] --- index.html | 5 ++--- popcorn.js | 23 ++++++++++++----------- xml/webMadeMovies.xml | 4 +++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 88921f5..58f6bbc 100644 --- a/index.html +++ b/index.html @@ -168,9 +168,8 @@ Collapse -
- Use the #Evernote Fx Add-on to save, organize, & search info you find on the Web http://bit.ly/evernotewebclipper /via @rockyourfirefox - more +
+
diff --git a/popcorn.js b/popcorn.js index 089be9b..7f8ec8a 100644 --- a/popcorn.js +++ b/popcorn.js @@ -317,7 +317,7 @@ }; }; - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// // Wiki Command //////////////////////////////////////////////////////////////////////////// @@ -325,37 +325,38 @@ VideoCommand.call(this, name, params, text, videoManager); var src = this.params.src; + var length = this.params.numberOfWords; // 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) { + $.getJSON("http://en.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); 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'); - //((<(.|\n)+?>)|\[(.*?)\]|\((.*?)\)) var text = data.parse.text.*.substr(data.parse.text.*.indexOf('

')); - text = text.replace(/(<(.|\n)+?>)|\((.*?)\)|\[(.*?)\]/g, ""); - alert(text);desc.innerHTML = text; + 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.onIn = function() { this.target.setAttribute('style', 'display:inline'); - //}; + }; this.onOut = function() { - //this.target.setAttribute('style', 'display:none'); + this.target.setAttribute('style', 'display:none'); }; }; //////////////////////////////////////////////////////////////////////////// diff --git a/xml/webMadeMovies.xml b/xml/webMadeMovies.xml index 6adfca6..22576a2 100644 --- a/xml/webMadeMovies.xml +++ b/xml/webMadeMovies.xml @@ -21,6 +21,7 @@ + @@ -60,7 +61,8 @@ - + + A Shared Culture, Jesse Dylan -- 2.43.0