Created
August 1, 2016 01:08
-
-
Save anonymous/d815b6814607e9d412ee800aca7e0120 to your computer and use it in GitHub Desktop.
Exported from Popcode.
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> | |
<head> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<div> | |
<input id="query" placeholder="Enter your search term"> | |
<input type="submit" id="submit" value="Search"> | |
</div> | |
<div id="output"></div> | |
<script type="text/template" id="template"> | |
{{#gifs}} | |
<div> | |
<img src="{{images.original.url}}"> | |
</div> | |
{{/gifs}} | |
</script> | |
</body> | |
</html> |
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
var API_KEY = "dc6zaTOxFJmzC"; | |
var template = $('#template').html(); | |
$("#submit").click(function() { | |
var url = "https://api.giphy.com/v1/gifs/search?q=" + encodeURIComponent($("#query").val()) + "&api_key=" + API_KEY; | |
$.get(url).then(function(response) { | |
$('#output').html(Mustache.render(template, {gifs: response.data})); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment