Skip to content

Instantly share code, notes, and snippets.

Created August 1, 2016 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/d815b6814607e9d412ee800aca7e0120 to your computer and use it in GitHub Desktop.
Save anonymous/d815b6814607e9d412ee800aca7e0120 to your computer and use it in GitHub Desktop.
Exported from Popcode.
<!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>
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