]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Adding plugin for google feed (to access blogs)
authordseif <david.c.seifried@gmail.com>
Fri, 4 Mar 2011 03:52:22 +0000 (19:52 -0800)
committerdseif <david.c.seifried@gmail.com>
Fri, 4 Mar 2011 03:52:22 +0000 (19:52 -0800)
plugins/googlefeed/popcorn.googlefeed.html [new file with mode: 0644]
plugins/googlefeed/popcorn.googlefeed.js [new file with mode: 0644]

diff --git a/plugins/googlefeed/popcorn.googlefeed.html b/plugins/googlefeed/popcorn.googlefeed.html
new file mode 100644 (file)
index 0000000..7ec3fcd
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn Google Feed Plug-in Demo</title>
+  
+  <script src="../../popcorn.js"></script>
+  <script src="popcorn.googlefeed.js"></script>
+  <script>
+    document.addEventListener('DOMContentLoaded', function () {
+      var p = Popcorn('#video')
+      .volume(0)
+      .play()
+      .googlefeed({
+        start: 0, // seconds
+        end: 15, // seconds
+        target: "map",
+               url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
+        title: "Planet Feed"
+         } )
+         .googlefeed({
+        start: 5, // seconds
+        end: 20, // seconds
+        target: "map1",
+               url: "http://blog.pikimal.com/geek/feed/",
+               title: "pikiGeek"
+      } );
+    }, false);
+  </script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Google Feed Plug-in Demo</h1>
+  <p>A Blog feed of Seneca's Planet Feed will be displayed from 0 seconds to 15 seconds</p>
+  <p> A Blog feed of pikiGeek's feed will be displayed from 5 seconds to 20 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 style="width:1000px">
+    <div id="map" style="position:relative;float:left;width:400px;height:600px"><p>Locations in this video:</p></div>
+    <div id="map1" style="position:relative;float:left;width:400px;height:600px"><p>Locations in this video:</p></div>
+  </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/googlefeed/popcorn.googlefeed.js b/plugins/googlefeed/popcorn.googlefeed.js
new file mode 100644 (file)
index 0000000..86acd90
--- /dev/null
@@ -0,0 +1,127 @@
+// PLUGIN: Google Feed
+var googleCallback;
+(function (Popcorn) {
+
+  /**
+   * googlemap popcorn plug-in
+   * Adds a map to the target div centered on the location specified by the user
+   * Options parameter will need a start, end, target, type, zoom, lat and lng, and location
+   * -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 DOM element that you want the map to appear in. This element must be in the DOM
+   * -Type [optional] either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN, STREETVIEW
+   * -Zoom [optional] defaults to 0
+   * -Heading [optional] STREETVIEW orientation of camera in degrees relative to true north (0 north, 90 true east, ect)
+   * -Pitch [optional] STREETVIEW vertical orientation of the camera (between 1 and 3 is recommended)
+   * -Lat and Lng: the coordinates of the map must be present if location is not specified.
+   * -Location: the adress you want the map to display, bust be present if lat and log are not specified.
+   * Note: using location requires extra loading time, also not specifying both lat/lng and location will
+   * cause and error.
+   * @param {Object} options
+   *
+   * Example:
+    var p = Popcorn("#video")
+      .googlemap({
+       start: 5, // seconds
+       end: 15, // seconds
+       type: "ROADMAP",
+       target: "map",
+       lat: 43.665429,
+       lng: -79.403323
+    } )
+  *
+  */
+
+  var newdiv, i = 1, _mapFired = false, _mapLoaded = false;
+
+  // callback function fires when the script is run
+  googleCallback = function() {
+                       google.load("feeds", "1", {"callback" : reallyLoaded});
+  };
+  
+  var reallyLoaded = function() {
+                               _mapLoaded = true;
+                       };
+  
+  // insert google api script once
+  if (!_mapFired) {
+    _mapFired = true;
+    var loadScriptTime = (new Date).getTime();
+    var head = document.getElementsByTagName("head")[0];
+    var script = document.createElement("script");
+       var script2 = document.createElement("script");
+       var css = document.createElement('link');
+       
+    script.src = "https://www.google.com/jsapi?callback=googleCallback";
+    script.type = "text/javascript";
+       script2.src = "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js";
+    script2.type = "text/javascript";
+       css.type = "text/css";
+       css.rel = "stylesheet";
+       css.href =  "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";
+       
+       head.insertBefore( script2, head.firstChild );  
+    head.insertBefore( script, head.firstChild );
+       head.insertBefore( css, head.firstChild );
+  }
+
+
+  Popcorn.plugin( "googlefeed" , function( options ) {
+    // create a new div this way anything in the target div
+    // this is later passed on to the maps api
+    var newdiv = document.createElement("div");
+       newdiv.style.display = "none";
+    if (document.getElementById(options.target)) {
+      document.getElementById(options.target).appendChild(newdiv);
+    }
+
+    var initialize = function() {
+       if ( !_mapLoaded ) {
+        setTimeout(function () {
+          initialize();
+        }, 5);
+      } else {
+      var container = new GFdynamicFeedControl(options.url, newdiv, {
+               vertical: true,
+               title: options.title
+               });
+         }
+       };
+       initialize();
+    return {
+      /**
+       * @member webpage
+       * 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){
+            newdiv.setAttribute( 'style', 'display:inline' );
+      },
+      /**
+       * @member webpage
+       * 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){
+          newdiv.setAttribute( 'style', 'display:none' );
+      }
+    };
+  },
+  {
+    about: {
+      name: "Popcorn Google Feed Plugin",
+      version: "0.1",
+      author: "David Seifried",
+      website: "dseifried.wordpress.com"
+    },
+    options: {
+      start    : {elem:"input", type:"text", label:"In"},
+      end      : {elem:"input", type:"text", label:"Out"},
+      target   : "map-container",
+      url      : {elem:"input", type:"text", label:"url"},
+         title    : {elem:"input", type:"text", label:"title"}
+    }
+  });
+})( Popcorn );