Permalink
Browse files

flickr works with new interface

  • Loading branch information...
1 parent 1c66f4c commit c0169029e974f7b1a7ca4eaf2411a5b8d9b78bc2 Arjun Guha committed Mar 24, 2009
Showing with 61 additions and 0 deletions.
  1. +61 −0 website/static/demos/flickr.html
@@ -0,0 +1,61 @@
+<html>
+<head>
+<link rel="stylesheet" href="/demo.css"/>
+<script type="text/javascript" src="/fx/flapjax.js"></script>
+<script type="text/javascript" src="/fx/fxws.js"></script>
+
+<title>Flapjax Demo: Flickr Search</title>
+<script type="text/javascript">
+
+// flickrSearchRequest :: String -> Request
+function flickrSearchRequest(text) {
+ return {
+ url: "http://api.flickr.com/services/rest/",
+ fields: { "method": "flickr.photos.search",
+ "format": "json",
+ "nojsoncallback": "1",
+ "api_key": "543eddef782d468ca90d07ccc5fbdfe8",
+ "text": text },
+ request: "get",
+ response: "json" };};
+
+function photoThumbnailUrl(photo) {
+ return "http://farm" + photo.farm + ".static.flickr.com/" + photo.server +
+ "/" + photo.id + "_" + photo.secret + "_t.jpg"; }
+
+// flickrSearchResponse :: Respose -> Listof(Url)
+function flickrResponseToUrls(response) {
+ return map(photoThumbnailUrl,response.photos.photo); }
+
+// makeImg :: Url -> Element
+function makeImg(url) {
+ return IMG_({ src: url }); }
+
+function loader() {
+ initFlapjaxForeignWSO('/fx');
+
+ var requestE = extractValueE("search").mapE(flickrSearchRequest);
+ var responseE = getForeignWebServiceObjectE(requestE);
+
+ var thumbsE = responseE.mapE(function(response) {
+ return DIV_(map(makeImg,flickrResponseToUrls(response)))});
+
+ insertDomE(thumbsE, "thumbnails");
+
+}
+
+</script>
+</head>
+
+<body onload="loader();">
+
+<div style="text-align: center">
+
+search: <input type="text" id="search"/><br/><br/>
+
+<div id="thumbnails">Search for something</div>
+
+</div>
+</body>
+</html>
+

0 comments on commit c016902

Please sign in to comment.