From 14dbbd09fda4c976935ed6bd46e3cd7fde325aba Mon Sep 17 00:00:00 2001 From: Anna Sobiepanek Date: Tue, 14 Dec 2010 13:04:49 -0500 Subject: [PATCH] initial wiki work [#158] --- plugins/wikipedia/popcorn.wikipedia.html | 57 +++++++++++++ plugins/wikipedia/popcorn.wikipedia.js | 62 ++++++++++++++ plugins/wikipedia/popcorn.wikipedia.unit.html | 43 ++++++++++ plugins/wikipedia/popcorn.wikipedia.unit.js | 80 +++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 plugins/wikipedia/popcorn.wikipedia.html create mode 100644 plugins/wikipedia/popcorn.wikipedia.js create mode 100644 plugins/wikipedia/popcorn.wikipedia.unit.html create mode 100644 plugins/wikipedia/popcorn.wikipedia.unit.js diff --git a/plugins/wikipedia/popcorn.wikipedia.html b/plugins/wikipedia/popcorn.wikipedia.html new file mode 100644 index 00000000..8d931374 --- /dev/null +++ b/plugins/wikipedia/popcorn.wikipedia.html @@ -0,0 +1,57 @@ + + + + Popcorn WebPage Plug-in Demo + + + + + + +

Popcorn WebPage Plug-in Demo

+

A Webpage displaying webmademovies.org will appear at 5 seconds and disappear at 15 seconds.

+

A Webpage displaying zenit Processing.js wiki will appear at 20 seconds and disappear at 45 seconds.

+
+ +
+
+
+
+ + diff --git a/plugins/wikipedia/popcorn.wikipedia.js b/plugins/wikipedia/popcorn.wikipedia.js new file mode 100644 index 00000000..136970dd --- /dev/null +++ b/plugins/wikipedia/popcorn.wikipedia.js @@ -0,0 +1,62 @@ +// PLUGIN: WEBPAGE + +(function (Popcorn) { + + /** + * Wikipedia popcorn plug-in + * Displays a wikipedia aricle in the target specified by the user + * Options parameter will need a start, end, target, lang, src, and numOfWords. + * Start is the time that you want this plug-in to execute + * End is the time that you want this plug-in to stop executing + * Target is the id of the document element that the iframe needs to be attached to, + * this target element must exist on the DOM + * Lang (optional, defaults to english)is the language in which the article is in. + * Src is the url of the article + * NumOfWords (optional, defaults to 200) is the number of words you want displaid. + * + * @param {Object} options + * + * Example: + var p = Popcorn('#video') + .wikipedia({ + id: "webpages-a", + start: 5, // seconds + end: 15, // seconds + src: 'http://www.webmademovies.org', + target: 'webpagediv' + } ) + * + */ + Popcorn.plugin( "wikipedia" , (function(){ + + var temp, length; + + + return { + /** + * @member wikipedia + * The start function will be executed when the currentTime + * of the video reaches the start time provided by the + * options variable + */ + start: function(event, options){ + if (typeof options.lang === 'undefined') {options.lang="en";} + temp = document.getElementById( options.target ); + length = options.numOfWords || 200; + + }, + /** + * @member wikipedia + * The end function will be executed when the currentTime + * of the video reaches the end time provided by the + * options variable + */ + end: function(event, options){ + temp.removeChild(iframe); + } + + }; + + })()); + +})( Popcorn ); \ No newline at end of file diff --git a/plugins/wikipedia/popcorn.wikipedia.unit.html b/plugins/wikipedia/popcorn.wikipedia.unit.html new file mode 100644 index 00000000..238ff9d6 --- /dev/null +++ b/plugins/wikipedia/popcorn.wikipedia.unit.html @@ -0,0 +1,43 @@ + + + + Popcorn API + + + + + + + + + + +

Popcorn Webpage UI

+

+
+

+
    +
    + + +
    + + diff --git a/plugins/wikipedia/popcorn.wikipedia.unit.js b/plugins/wikipedia/popcorn.wikipedia.unit.js new file mode 100644 index 00000000..a402670c --- /dev/null +++ b/plugins/wikipedia/popcorn.wikipedia.unit.js @@ -0,0 +1,80 @@ +test("Popcorn Webpage Plugin", function () { + + var popped = Popcorn("#video"), + expects = 11, + count = 0, + iframeInterval, + iframeInterval2, + iframeInterval3, + iframeInterval4; + theiFrame = document.getElementsByTagName('iframe'); + expect(expects); + + function plus() { + if ( ++count===expects) { + start(); + } + } + + stop(); + + ok ('webpage' in popped, "webpages is a mehtod of the popped instance"); + plus(); + + equals (theiFrame.length, 0, "initially, there is no iframes on the page" ); + plus(); + + popped.webpage({ + id: "webpages-a", + start: 5, // seconds + end: 25, // seconds + src: 'http://webmademovies.org', + target: 'webpagediv' + }) + .webpage({ + id: "webpages-b", + start: 35, // seconds + end: 50, // seconds + src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js', + target: 'webpagediv' + }) + .play(); + + + iframeInterval = setInterval( function() { + if( popped.currentTime() > 7 && popped.currentTime() <= 25 ) { + ok (!!theiFrame[0], "iframe was created" ); + plus(); + equals (theiFrame.length, 1, "there is only one iframe on the page" ); + plus(); + equals (theiFrame[0].id, "webpages-a", "iframe has the id 'webpages-a'" ); + plus(); + equals (theiFrame[0].src, "http://webmademovies.org/", "iframe has the src 'http://webmademovies.org/'" ); + plus(); + clearInterval( iframeInterval ); + } + }, 5000); + + iframeInterval2 = setInterval( function() { + if( popped.currentTime() > 27 && popped.currentTime() < 35 ) { + equals (theiFrame.length, 0, "the iframe has been removed" ); + plus(); + clearInterval( iframeInterval2 ); + } + }, 5000); + + iframeInterval3 = setInterval( function() { + if( popped.currentTime() > 37 && popped.currentTime() <= 50 ) { + ok (!!theiFrame[0], "iframe was created" ); + plus(); + equals (theiFrame.length, 1, "there is only one iframe on the page" ); + plus(); + equals (theiFrame[0].id, "webpages-b", "iframe has the id 'webpages-b'" ); + plus(); + equals (theiFrame[0].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" ); + plus(); + clearInterval( iframeInterval3 ); + } + }, 5000); + +});