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
Luke Wilde
committed
Mar 19, 2012
1 parent
d38880b
commit e6850e4
Showing
1 changed file
with
9 additions
and
50 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 |
---|---|---|
@@ -1,50 +1,9 @@ | ||
<style> | ||
body { | ||
min-width:357px; | ||
overflow-x:hidden; | ||
} | ||
|
||
img { | ||
margin:5px; | ||
border:2px solid black; | ||
vertical-align:middle; | ||
width:75px; | ||
height:75px; | ||
} | ||
</style> | ||
|
||
<script> | ||
var req = new XMLHttpRequest(); | ||
req.open( | ||
"GET", | ||
"http://api.flickr.com/services/rest/?" + | ||
"method=flickr.photos.search&" + | ||
"api_key=90485e931f687a9b9c2a66bf58a3861a&" + | ||
"text=hello%20world&" + | ||
"safe_search=1&" + // 1 is "safe" | ||
"content_type=1&" + // 1 is "photos only" | ||
"sort=relevance&" + // another good one is "interestingness-desc" | ||
"per_page=20", | ||
true); | ||
req.onload = showPhotos; | ||
req.send(null); | ||
|
||
function showPhotos() { | ||
var photos = req.responseXML.getElementsByTagName("photo"); | ||
|
||
for (var i = 0, photo; photo = photos[i]; i++) { | ||
var img = document.createElement("image"); | ||
img.src = constructImageURL(photo); | ||
document.body.appendChild(img); | ||
} | ||
} | ||
|
||
// See: http://www.flickr.com/services/api/misc.urls.html | ||
function constructImageURL(photo) { | ||
return "http://farm" + photo.getAttribute("farm") + | ||
".static.flickr.com/" + photo.getAttribute("server") + | ||
"/" + photo.getAttribute("id") + | ||
"_" + photo.getAttribute("secret") + | ||
"_s.jpg"; | ||
} | ||
</script> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>NewsDing</title> | ||
</head> | ||
<body> | ||
<h1>Awwwh News</h1> | ||
</body> | ||
</html> |