This repository has been archived by the owner on Nov 28, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arjun Guha
committed
Mar 24, 2009
1 parent
1c66f4c
commit c016902
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|