Created
March 15, 2014 02:03
-
-
Save cflove/9560809 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Flickr</title> | |
| <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> | |
| <style type="text/css"> | |
| body {font-family: Verdana;} | |
| .photo {display: inline-block; padding: 10px; width: 400px; height: 300px;} | |
| #count {font-weight: bold;} | |
| </style> | |
| </head> | |
| <body> | |
| <div id="searchbar"> | |
| <input type="text" id="searchBox"> | |
| <button id="searchButton">Search</button> | |
| </div> | |
| <div id="count"></div> | |
| <div id='images'></div> | |
| <script type="text/javascript"> | |
| $(document).ready(function(){ | |
| $.ajax({ | |
| dataType: "json", | |
| url: "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?&format=json&tags=Tree" | |
| }).success(function(data) { | |
| console.log(data) | |
| $.each(data.items, function(i,e) { | |
| console.log(e) | |
| $('#images').append( '<div class="photo">'+e.description+'</div>') | |
| }) | |
| }); | |
| // ===================================================================== | |
| searchimg = function(key) { | |
| $.ajax({ | |
| dataType: "json", | |
| url: "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?&format=json&tags=" + key | |
| }).success(function(data) { | |
| // console.log(data) | |
| // $('#count').html( data.items.length + ' Pictures Found') | |
| // $('#images').html('') | |
| $.each(data.items, function(i,e) { | |
| $('#images').append( '<div class="photo">'+e.description+'</div>') | |
| }) | |
| }); | |
| } | |
| $('#searchButton').click(function(){ | |
| alert( $('#searchBox').val() ) | |
| // if ($('#searchBox').val() == '' ) { | |
| // alert("Please Enter Search Key") | |
| // } else { | |
| // searchimg($('#searchBox').val()) | |
| // } | |
| }) | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment