Team:TU Delft/fb display

From 2010.igem.org

(Difference between revisions)
Line 22: Line 22:
<script type="text/javascript">
<script type="text/javascript">
-
function fb_photos</html>{{{album|135033906513449}}}<html>(response) {
+
// needs to be global for jsonp invoke
 +
var fb_photos</html>{{{album|135033906513449}}}<html>;
 +
 
 +
$(function() {
 +
 
 +
var albumID = "</html>{{{album|135033906513449}}}<html>";
 +
var baseurl = "https://graph.facebook.com/";
 +
 
 +
 
 +
function addScript(url) {
 +
  var html = '<script src="'+ url + '" type="text/javascript"></scr'+'ipt>';
 +
  $("#fb_scriptload" + albumID).html(html);
 +
}
 +
 
 +
function fetchPhotos() {
 +
  addScript(baseurl + "/" + albumID + "/photos?callback=fb_photos"+albumID);
 +
}
 +
 
 +
fb_photos</html>{{{album|135033906513449}}}<html> = function (response) {
   var n = </html>{{{count|6}}}<html>;
   var n = </html>{{{count|6}}}<html>;
   var imghtml = "";
   var imghtml = "";
-
  var albumID = </html>{{{album|135033906513449}}}<html>;
 
   var done={}, j=0, und;
   var done={}, j=0, und;
Line 50: Line 67:
   }
   }
   catch (err) {
   catch (err) {
-
  $("#photobox" + albumID).html("Error: " + err.description);
+
//    $("#photobox" + albumID).html("Error: " + err.description);
 +
    $("#photobox" + albumID).delay(400).queue(fetchPhotos);
   }
   }
}
}
-
$(function() {
+
$("#photobox" + albumID).click(fetchPhotos).delay(300).queue(fetchPhotos);
-
 
+
-
var albumID = "</html>{{{album|135033906513449}}}<html>";
+
-
 
+
-
var baseurl = "https://graph.facebook.com/";
+
-
 
+
-
function addScript(url) {
+
-
  var html = '<script src="'+ url + '" type="text/javascript"></scr'+'ipt>';
+
-
  $("#fb_scriptload" + albumID).html(html);
+
-
}
+
-
 
+
-
function fetchPhotos() {
+
-
  addScript(baseurl + "/" + albumID + "/photos?callback=fb_photos"+albumID);
+
-
}
+
-
 
+
-
$("#photobox" + albumID).click(fetchPhotos).delay(600).queue(fetchPhotos);
+
});
});
</script>
</script>
</html>
</html>

Revision as of 22:20, 27 July 2010


This is a template page that displays random pictures from a facebook album.

{{:Team:TU_Delft/fb_display|album=ID|count=Number of images|css=CSS class}}
Parameters: 
album: Facebook album ID
count: Number of pictures to display
css: CSS class for each image


loading facebook photo's...