Skip to content

Instantly share code, notes, and snippets.

@arecvlohe
Last active April 8, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arecvlohe/e93f80830cf494723a1fcd59be8a956f to your computer and use it in GitHub Desktop.
Save arecvlohe/e93f80830cf494723a1fcd59be8a956f to your computer and use it in GitHub Desktop.
A simple Giphy Search App
<input type='text' />
$(document).ready(function() {
$('input').keypress(function(event) {
if(event.which == 13) {
var value = $('input').val();
value = value.trim().replace(/\s+/g, '+');
var url = 'http://api.giphy.com/v1/gifs/search?api_key=dc6zaTOxFJmzC&q=' + value;
$.getJSON(url, function(object) {
object.data.forEach(function(gif) {
var url = gif.images.original.url;
var image = $('<img src=' + url + ' />');
image.appendTo($('body'));
});
event.preventDefault();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment