]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#168] google news plugin
authorScottDowne <sdowne@learn.senecac.on.ca>
Fri, 7 Jan 2011 21:26:11 +0000 (16:26 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Fri, 7 Jan 2011 21:26:11 +0000 (16:26 -0500)
plugins/googleNews/popcorn.googleNews.html [new file with mode: 0644]
plugins/googleNews/popcorn.googleNews.js [new file with mode: 0644]

diff --git a/plugins/googleNews/popcorn.googleNews.html b/plugins/googleNews/popcorn.googleNews.html
new file mode 100644 (file)
index 0000000..81ed3c4
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn google Map Plug-in Demo</title>
+  
+  <script src="../../popcorn.js"></script>
+
+  <script src="http://google.com/jsapi"></script>
+  <script>google.load("elements", "1", {packages : ["newsshow"]});</script>
+
+  <script src="popcorn.googleNews.js"></script>
+  <script>
+    document.addEventListener('DOMContentLoaded', function () {
+      var p = Popcorn('#video')
+      .volume(0)
+      .play() 
+      .googleNews({
+        start: 0, // seconds
+        end: 20, // seconds
+        topic: 'Oil Spill',
+        target: 'newsdiv'
+      } )
+      .googleNews({
+        start: 25, // seconds
+        end: 30, // seconds
+        topic: 'Village Telco',
+        target: 'newsdiv'
+      } );
+    }, false);
+  </script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn google News Plug-in Demo</h1>
+  <p> Google News topic will appear at 0 seconds and disappear at 20 seconds.</p>
+  <p> Google News topic will appear at 25 seconds and disappear at 30 seconds.</p>
+  <div>
+    <video id='video' 
+      controls 
+      width= '250px'
+      poster="../../test/poster.png"> 
+
+      <source id='mp4'
+        src="../../test/trailer.mp4"
+        type='video/mp4; codecs="avc1, mp4a"'> 
+
+      <source id='ogv'
+        src="../../test/trailer.ogv"
+        type='video/ogg; codecs="theora, vorbis"'> 
+
+      <p>Your user agent does not support the HTML5 Video element.</p> 
+
+    </video> 
+  </div>
+  <div id="newsdiv"></div>
+</body>
+</html>
diff --git a/plugins/googleNews/popcorn.googleNews.js b/plugins/googleNews/popcorn.googleNews.js
new file mode 100644 (file)
index 0000000..54a0312
--- /dev/null
@@ -0,0 +1,59 @@
+// PLUGIN: Google News
+
+(function (Popcorn) {
+  
+  /**
+   */
+  Popcorn.plugin( "googleNews" , {
+
+      manifest: {
+        about:{
+          name:    "Popcorn Google News Plugin",
+          version: "0.1",
+          author:  "Scott Downe",
+          website: "http://scottdowne.wordpress.com/"
+        },
+        options:{
+          start    : {elem:'input', type:'text', label:'In'},
+          end      : {elem:'input', type:'text', label:'Out'},
+          target   : 'news-container',
+          topic     : {elem:'select', type:'text', label:'Type'}
+        }
+      },
+      _setup : function( options ) {
+
+        options.container = document.createElement( 'div' );
+
+        document.getElementById( options.target ).appendChild( options.container );
+
+        var newsShow = new google.elements.NewsShow( options.container, {
+          format : "300x250",
+          queryList : [
+            { q: options.topic || "Top Stories" }
+          ]
+        } );
+        options.container.style.display = "none";
+
+      },
+      /**
+       * @member googleNews 
+       * 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 ){
+        options.container.setAttribute( 'style', 'display:inline' );
+      },
+      /**
+       * @member googleNews 
+       * 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 ){
+        options.container.setAttribute( 'style', 'display:none' );
+      }
+
+  });
+
+})( Popcorn );