Skip to content

Commit

Permalink
Initial Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Dec 6, 2014
0 parents commit ec892d8
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

build/
63 changes: 63 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var gui = require('nw.gui');
var win = gui.Window.get();

var nativeMenuBar = new gui.Menu({ type: "menubar" });
nativeMenuBar.createMacBuiltin("Hot Gif");
win.menu = nativeMenuBar;

var clipboard = gui.Clipboard.get();

//win.showDevTools();


var api_key="dc6zaTOxFJmzC";
var translate_endpoint="http://api.giphy.com";
var api_version="v1";

//Hotkey Stuff
var option = {
key : "Ctrl+Alt+G",
active : function() {
win.show();
win.focus();
$("#s").focus();
},
failed : function(msg) {
console.log(msg);
}
};

var shortcut = new gui.Shortcut(option);


gui.App.registerGlobalHotKey(shortcut);


$(document).on("ready", function()
{
$("#search").on("click", function()
{
search();
});
$("#s").keyup(function (e)
{
if (e.keyCode == 13)
{
search();
}
});
});

function search()
{
keyword=$("#s").val();
$("#s").val("");
win.hide();
url=translate_endpoint+"/"+api_version+"/gifs/translate?s=" + keyword + "&api_key=" + api_key;

$.ajax({type: "GET",url: url }).done(function(res)
{
clipboard.set(res.data.images.original.url, 'text');
});

}
39 changes: 39 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Hot Gif</title>

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

<script src="app.js"></script>

<style type="text/css">
body
{
font-size:48px;
background-color: #FF69B4;
color: #FFF;
margin: 0px;
padding: 0px;
overflow:hidden;

}
input
{
border: 0;
color: #FFF;
background-color: #FF69B4;
font-size:48px;
width: 500px;
text-align:center;
outline: none;
}

</style>

</head>
<body>
<input type="text" id="s">
</body>
</html>
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Hot Gif",
"main": "index.html",
"version": "0.0.1",
"name": "Hot Gif",
"window": {
"title": "Hot Gif",
"toolbar": false,
"frame": false,
"width": 500,
"height": 60
}
}

0 comments on commit ec892d8

Please sign in to comment.