Skip to content

Commit

Permalink
merge branch 'annasob/0.5' into plugin-inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
db48x committed Mar 29, 2011
2 parents aed6dd4 + d060d5a commit 599e860
Show file tree
Hide file tree
Showing 14 changed files with 1,047 additions and 665 deletions.
5 changes: 0 additions & 5 deletions demos/semantic_video/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<title>HTML5 Video Demo Using popcorn.js</title>
<meta charset="UTF-8" />
<script src="http://code.jquery.com/jquery.js"></script>
<script src="http://google.com/jsapi"></script>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>google.load("language", "1");</script>
<script>google.load("elements", "1", {packages : ["newsshow"]});</script>
<script src="../../popcorn.js"></script>

<script src="../../plugins/webpage/popcorn.webpage.js"></script>
Expand All @@ -22,7 +18,6 @@
<script src="../../plugins/attribution/popcorn.attribution.js"></script>
<script src="../../plugins/lastfm/popcorn.lastfm.js"></script>


<script src="../../parsers/parserXML/popcorn.parserXML.js"></script>

<link href="style.css" rel="stylesheet" type="text/css" />
Expand Down
49 changes: 49 additions & 0 deletions parsers/parserJSON/data/audio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"title":"Crockford Lives!",
"remote":"http://dl.dropbox.com/u/3531958/crockford.ogv",
"data": [
{
"webpage": {
"start":"0.0897589878863602",
"end":"2.001204869833337",
"target":"audio-iframe-container",
"src":"http://json.org"
}
},
{
"footnote": {
"start":"0.23530116023787565",
"end":"2.0193976413772767",
"target":"audio-footnote-container",
"text":"I invented JSON"
}
},
{
"googlemap": {
"start":"0.09096385771969716",
"end":"8.617349362660605",
"target":"audio-map-container",
"type":"ROADMAP",
"lat":37.7749295,
"lng":-122.4194155,
"location":"San Francisco, CA"
}
},
{
"webpage": {
"start":"2.073975956009095",
"end":"10.278915922325776",
"target":"audio-iframe-container",
"src":"http://jslint.org"
}
},
{
"footnote": {
"start":2.145542172351516,
"end":10.145542172351513,
"target":"audio-footnote-container",
"text":"I wrote JSLint"
}
}
]
}
49 changes: 49 additions & 0 deletions parsers/parserJSON/data/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"title":"Crockford Lives!",
"remote":"http://dl.dropbox.com/u/3531958/crockford.ogv",
"data": [
{
"webpage": {
"start":"0.0897589878863602",
"end":"2.001204869833337",
"target":"video-iframe-container",
"src":"http://json.org"
}
},
{
"footnote": {
"start":"0.23530116023787565",
"end":"2.0193976413772767",
"target":"video-footnote-container",
"text":"I invented JSON"
}
},
{
"googlemap": {
"start":"0.09096385771969716",
"end":"8.617349362660605",
"target":"video-map-container",
"type":"ROADMAP",
"lat":37.7749295,
"lng":-122.4194155,
"location":"San Francisco, CA"
}
},
{
"webpage": {
"start":"2.073975956009095",
"end":"10.278915922325776",
"target":"video-iframe-container",
"src":"http://jslint.org"
}
},
{
"footnote": {
"start":2.145542172351516,
"end":10.145542172351513,
"target":"video-footnote-container",
"text":"I wrote JSLint"
}
}
]
}
18 changes: 15 additions & 3 deletions parsers/parserJSON/popcorn.parserJSON.unit.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,26 @@ <h2 id="qunit-userAgent"></h2>
<p>Your user agent does not support the HTML5 Video element.</p>

</video>

<audio id='audio' src="../../test/italia.ogg" data-timeline-sources="data/audio.json" controls>
</audio>

<style>
.displays {
width: 300px;
height: 300px;
}
</style>
<div class="displays" id="iframe-container"></div>
<div class="displays" id="map-container"></div>
<div class="displays" id="footnote-container"></div>
<hr>
<div style="width:300px;float:left">
<div class="displays" id="video-iframe-container"></div>
<div class="displays" id="video-map-container"></div>
<div class="displays" id="video-footnote-container"></div>
</div>
<div style="width:300px;float:left">
<div class="displays" id="audio-iframe-container"></div>
<div class="displays" id="audio-map-container"></div>
<div class="displays" id="audio-footnote-container"></div>
</div>
</body>
</html>
102 changes: 93 additions & 9 deletions parsers/parserJSON/popcorn.parserJSON.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
finished = false,
trackData,
trackEvents,
interval,
poppercorn = Popcorn( "#video" );

function plus() {
if ( ++count === expects ) {
start();
// clean up added events after tests
clearInterval( interval );
}
}

poppercorn.parseJSON("data/data.json");
poppercorn.parseJSON("data/video.json");

expect(expects);

Expand All @@ -29,14 +26,17 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
trackEvents = trackData.trackEvents;

Popcorn.xhr({
url: 'data/data.json',
url: 'data/video.json',
success: function( data ) {

var idx = 0;

//console.log( data );

Popcorn.forEach( data.json.data, function (dataObj) {
Popcorn.forEach( dataObj, function ( obj, key ) {

//console.log( dataObj );
Popcorn.forEach( dataObj, function ( obj, key ) {

equals( trackData.history[idx].indexOf(key), 0, "history item '" + trackData.history[idx] + "' matches data key '"+ key+ "' at correct index" );
plus();
Expand All @@ -59,11 +59,11 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
plus();


equals( $("#iframe-container").children().length, 2, '$("#iframe-container").children().length' )
equals( $("#video-iframe-container").children().length, 2, '$("#video-iframe-container").children().length' )
plus();
equals( $("#map-container").children().length, 1, '$("#map-container").children().length' );
equals( $("#video-map-container").children().length, 1, '$("#video-map-container").children().length' );
plus();
equals( $("#footnote-container").children().length, 2, '$("#footnote-container").children().length' );
equals( $("#video-footnote-container").children().length, 2, '$("#video-footnote-container").children().length' );
plus();

this.pause();
Expand All @@ -80,3 +80,87 @@ test("Popcorn 0.3 JSON Parser Plugin", function () {
}, 500);

});

test("Popcorn 0.3 JSON Parser Plugin - AUDIO", function () {

var expects = 9,
count = 0,
timeOut = 0,
numLoadingEvents = 5,
finished = false,
trackData,
trackEvents,
interval,
audiocorn = Popcorn.getInstanceById("audio");

function plus() {
if ( ++count === expects ) {
start();
// clean up added events after tests
clearInterval( interval );
}
}

expect(expects);

stop( 5000 );


trackData = audiocorn.data;
trackEvents = trackData.trackEvents;


Popcorn.xhr({
url: 'data/audio.json',
success: function( data ) {

var idx = 0;

Popcorn.forEach( data.json.data, function (dataObj) {
Popcorn.forEach( dataObj, function ( obj, key ) {


equals( trackData.history[idx].indexOf(key), 0, "history item '" + trackData.history[idx] + "' matches data key '"+ key+ "' at correct index" );
plus();

idx++;
});
});


}
});
audiocorn.listen("timeupdate", function ( event ) {


if ( Math.round( this.currentTime()) === 3 && !finished ) {

finished = true;

equals( trackEvents.byStart.length, numLoadingEvents + 2 , "trackEvents.byStart.length === (5 loaded, 2 padding) " );
plus();


equals( $("#audio-iframe-container").children().length, 2, '$("#audio-iframe-container").children().length' )
plus();
equals( $("#audio-map-container").children().length, 1, '$("#audio-map-container").children().length' );
plus();
equals( $("#audio-footnote-container").children().length, 2, '$("#audio-footnote-container").children().length' );
plus();

this.pause();

}


});


setTimeout(function () {

audiocorn.currentTime(0).play()

}, 500);

});

50 changes: 28 additions & 22 deletions plugins/googlefeed/popcorn.googlefeed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
// PLUGIN: Google Feed
(function (Popcorn) {

var i = 1,
scriptLoaded = false,
callBack = function( data ) {

if ( typeof google !== 'undefined' && google.load ) {

google.load( "feeds", "1", { callback: function () { scriptLoaded = true; } } );
} else {

setTimeout( function() {

callBack( data );
}, 1);
}
};

Popcorn.getScript( "http://www.google.com/jsapi", callBack );
Popcorn.getScript( "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js" );

//Doing this because I cannot find something similar to getScript() for css files
var head = document.getElementsByTagName("head")[0];
var css = document.createElement('link');
css.type = "text/css";
css.rel = "stylesheet";
css.href = "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";
head.insertBefore( css, head.firstChild );

/**
* googlefeed popcorn plug-in
* Adds a feed from the specified blog url at the target div
Expand All @@ -25,27 +52,6 @@
*
*/

var _feedFired = false,
_feedLoaded = false,
i = 1;

// insert google api and dynamic feed control script once, as well as the dynamic feed css file
if ( !_feedFired ) {
_feedFired = true;
Popcorn.getScript( "https://www.google.com/jsapi", function () {
google.load( "feeds", "1", { callback: function () { _feedLoaded = true; } } );
});
Popcorn.getScript( "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js" );
//Doing this because I cannot find something similar to getScript() for css files
var head = document.getElementsByTagName("head")[0];
var css = document.createElement('link');
css.type = "text/css";
css.rel = "stylesheet";
css.href = "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";
head.insertBefore( css, head.firstChild );
}


Popcorn.plugin( "googlefeed" , function( options ) {
// create a new div and append it to the parent div so nothing
// that already exists in the parent div gets overwritten
Expand All @@ -61,7 +67,7 @@

var initialize = function() {
//ensure that the script has been loaded
if ( !_feedLoaded ) {
if ( !scriptLoaded ) {
setTimeout(function () {
initialize();
}, 5);
Expand Down
Loading

0 comments on commit 599e860

Please sign in to comment.