]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added flickr feeds
authorScottDowne <sdowne@learn.senecac.on.ca>
Fri, 25 Jun 2010 19:55:26 +0000 (15:55 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Fri, 25 Jun 2010 19:55:26 +0000 (15:55 -0400)
index.html
popcorn.js
xml/webMadeMovies.xml

index 7c2167e70747c339742ea4a92908092d617a2a6d..1f49d65846c0b8bea80b2298b8e8a5d9cd25792c 100644 (file)
@@ -2,6 +2,7 @@
   <head> 
     <title>html5 video demo</title>    
     <script src="popcorn.js"></script>
+    <script src="http://code.jquery.com/jquery.js"></script> 
     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
     <style type="text/css" media="screen"> 
       body { 
@@ -39,6 +40,7 @@
       <div id="sub"></div><br />
       <div id="tagthisvideo">In this video:<span id="inthisvideo"></span></div><br />
       <div id="map"></div>
+      <div id="flickr"></div>
     </div>
   </body> 
 </html> 
index 282b1c9f4e1c89fd7bebc5fb8265254043018b6b..7f440043a7ba5b079ff6c032cd9feaa6073bba7c 100644 (file)
     };
   };
 
+  var FlickrCommand = function(name, params, text) {
+    VideoCommand.call(this, name, params, text);
+    
+    // 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');
+    var height  = this.params.height || "50px",
+        width   = this.params.width || "50px",
+        count   = this.params.numberofimages || 4,
+        padding = this.params.padding || "5px",
+        border  = this.params.border || "0px";
+
+    // This uses jquery
+    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=" + this.params.userid + "@N00&lang=en-us&format=json&jsoncallback=?", function(data){
+      $.each(data.items, function(i, item) {
+        if (i < count) {
+          var link = document.createElement('a');
+          link.setAttribute('href', item.link);
+          var image = document.createElement('img');
+          image.setAttribute('src', item.media.m);
+          image.setAttribute('height', height);
+          image.setAttribute('width', width);
+          image.setAttribute('style', 'border:' + border + ';padding:' + padding);
+          link.appendChild(image);
+          target.appendChild(link);
+        } else {
+          return false;
+        }
+      });
+    });
+    this.target = target;
+
+    this.onIn = function() {
+      this.target.setAttribute('style', 'display:inline');
+    };
+    this.onOut = function() {
+      this.target.setAttribute('style', 'display:none');
+    };
+  };
+  
+
   var TwitterCommand = function(name, params, text) {}; // http://twitter.com/celinecelines
 
   // Wrapper for accessing commands by name
       create: function(name, params, text) {
         return new MapCommand(name, params, text);
       }
+    },
+    flickr: {
+      create: function(name, params, text) {
+        return new FlickrCommand(name, params, text);
+      }
     }
   };
 
index 9135cc29870d1564e5948d6c4abb2b88207b2275..9ef37caf73ae60234eb7dae593550d4b0b242a63 100644 (file)
@@ -20,4 +20,7 @@
     <location id="map2" in="00:30:00" out="01:00:00" lat="43.771" long="-79.5" target="map" zoom="16"/>
     <location id="map3" in="01:00:00" out="01:30:00" lat="41.771" long="-76.5" target="map" zoom="16"/>
   </map>
+  <flick>
+    <flickr in="00:01:00" out="00:05:00" target="flickr" userid="13072070" numberofimages="1000"/>
+  </flick>
 </popcorn>