Skip to content

Commit

Permalink
Initial version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetx committed Nov 30, 2015
0 parents commit 5d52d1d
Show file tree
Hide file tree
Showing 33 changed files with 306 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/clipppy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
html, body {
margin: 0;
padding: 0;
overflow: hidden;
}

body {
background-color: rgba(0, 0, 0, 0);
}

::-webkit-scrollbar-thumb {
display: none;
}

div.clippy {
-webkit-app-region: drag;
}
124 changes: 124 additions & 0 deletions app/clipppy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="clipppy.css" />
<link rel="stylesheet" type="text/css" href="clippy-js/clippy.css" media="all">
</head>

<body>
<script src="clippy-js/clippy.min.js"></script>
<script src="jquery-2.1.4.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
<script>

var agents = ["Clippy", "F1", "Genius", "Links", "Rocky"],
agent,
agent_name = localStorage.agent ? localStorage.agent : "Clippy",
remote = require('electron').remote,
mainWindow = remote.BrowserWindow,
Menu = remote.require('menu'),
MenuItem = remote.require('menu-item'),
Tray = remote.require('tray'),
NativeImage = remote.require('native-image');

function loadAgent(agent) {
// hide existing agent, if any
if (window.agent) {
window.agent.hide(0);
}
// check that it's valid
if (agents.indexOf(agent) === -1) {
agent = "Clippy";
}
// remember
localStorage.agent = agent_name = agent;
// load agent
clippy.load(agent, function (obj) {
// store reference
window.agent = obj;
// play intro
obj.play("Greeting");
});
}
function saveWindowPosition(x, y) {
localStorage.pos_x = x;
localStorage.pos_y = y;
};
function restoreWindowPosition() {
// restore window position
var pos_x = typeof localStorage.pos_x !== "undefined" ? parseInt(localStorage.pos_x) : -1,
pos_y = typeof localStorage.pos_y !== "undefined" ? parseInt(localStorage.pos_y) : -1;

if (pos_x < 0 || pos_x + (0.5 * window.innerWidth) > screen.width
|| pos_y < 0 || pos_y + (0.5 * window.innerHeight) > screen.height
) {
pos_x = screen.width - window.innerWidth - 50;
pos_y = screen.height - window.innerHeight - 50;
}
moveTo(pos_x, pos_y);
}
restoreWindowPosition();

(function tray_and_contextmenu() {
// Create a tray icon
var item_quit = new MenuItem({
label: "Quit Clipppy",
click: function () {
window.close();
}
});

var menu_agents = new Menu(),
items_agents = [],
item_agent;
for (var i in agents) {
item_agent = new MenuItem({
type: "checkbox",
checked: agents[i] === agent_name,
label: agents[i],
click: function (menuItem) {
for (var j in items_agents) {
items_agents[j].checked = false;
}
menuItem.checked = true;
loadAgent(menuItem.label);
}
});
items_agents.push(item_agent);
menu_agents.append(item_agent);
}

var item_agents = new MenuItem({
label: "Agent",
submenu: menu_agents
});

var tray = new Tray(NativeImage.createFromDataURL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wseFCEBCB07PgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAD3ElEQVQ4y5VUW0xbdRz+/uec9vS0nJZeaKFrgQJFLspCiAyGgjB1i06XmRkXNUbj7cUlPjizqXtYMEoEshlN1O1B5swCGq+DoHtZvDCjzhrmzLjUdJSWddD7aXs4PfQcHxQjAVz8Hn+/fF++L78LwX/gm+8uv/z75bmDfn9IvK3Ne/iBB3uGcANQmzUmf71QlxLw3FzLadfgQKLuhx+nXx0cHLTh/8Lr/Yuzc9fuscbG1vHVus8XOnvs2Id7bsQnGxWPHn3z7n37HvtgdLS3XRBK5np7DykvHTqifjJ6zv3t+ElyxT+/WxQSDcsQimhahSzTYKFCBqMy/xaKx2OYmZmxl5dXft3V1YET7w1f6u5p4tvbvTu8TdvVHcLM/PcTFyCs5KFSFCiKgCIUqEIeGRBwGnJgQ4cnT5xJ/nRxwtR9x165ob7GG40Hrr7xej/27n8KtbVJqDIHlVmGVNBAWs5DIwEZrYq72hr5dUM5+MJxPP3Mw8VCwak8eWDIHgx8OTk7HYTTWQG6kIfNtQVOjwXu0jq4HBaUOV3QGfWosBl9Jda2zDrB/oHnIWZFrsxoKrzV1/FpdY3b1NNVBntdDXbdVwY5R0OnNYDoc+BZLYx6GeVuF0rttuFN1yYjJWneyGnOT2S7G26pAsPzcHIlOH1mFnazERqWQhFDoLcWw2Exg9evoKqy1XdFLYDZSNBmXhRTCXEBFOcEOJiMBDIj4apfQjQaQfB6GgZWA1mZh7vCBYfNACh6Xz1NNl1st9XFOqXUNUi5NIqNgJgzg7eZkUkn0dlcg61NbqDAIhtPQa+1+AlNEusiq6oKAFgSwiMLgTk0NuuwsBSGIkXAahnI6SSIjkJOpRAJx6HkMyi26sGx9NurGmsiE0IwGxg+DCnXWuqk8Mij9TjeH0JZpQseRxjBPzKIRvLIxtJYDGVRZDIgJURBYefImltedZYUvnqC57jXwv4s7r/3ZvxyUY8j/R5s71hASgyDtxDwnBbhRRECESAIKXBgxwghkTUOp3xDW/2hj94Nzlxv02iz0Llt0KyoOPfOFNy2PPxTCXjcViylq5CSAjByy7ippgLllVawjpK+NSlD82dfUbRyl7SYvVNhKWQzeehYBYxWwdjn1xATPWhu0SGTMYLXTUOvyYEiLDx1DpTaq8d5w7Z71ghe+nkETbc+BADIpT92ZHNcZ0qJVbOS4fa0IranYlnzUiwHu4MDvaIFSxMwJg72Ivw28OL+lr5TCZkQy+bfJhr4AjbPnr+nfp6ZDjL6eGSymzYUbTPq0AlJ06rVyO9X1z7+rDr/GXKWVhgMW/7h/wkdrn7il+BqKgAAAABJRU5ErkJggg=="));
tray.setToolTip("Clipppy");

var menu_tray = new Menu();
menu_tray.append(item_agents);
menu_tray.append(item_quit);
tray.setContextMenu(menu_tray);

$(document.body).on("contextmenu", function (ev) {
ev.preventDefault();
menu_tray.popup(ev.x, ev.y);
return false;
});
})();

$(document).ready(function () {
loadAgent(agent_name);
});

$(window).on("beforeunload", function (e) {
e.preventDefault();
var close_anim = agent.animations().indexOf("GoodBye") > -1 ? "GoodBye" : "Goodbye";
agent.play(close_anim, undefined, function () {
$(window).off("beforeunload");
window.close();
});
return false;
});
</script>
</body>
</html>
58 changes: 58 additions & 0 deletions app/clipppy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* global __dirname */
var electron = require("electron"),
app = electron.app, // Module to control application life.
BrowserWindow = electron.BrowserWindow; // Module to create native browser window.

// Report crashes to our server.
electron.crashReporter.start();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;

// Quit when all windows are closed.
app.on("window-all-closed", function() {
app.quit();
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on("ready", function () {
// Create the browser window.
mainWindow = new BrowserWindow({
icon: "img/icon-128.icns",
width: 124,
height: 93,
resizable: true,
alwaysOnTop: true,
skipTaskbar: true,
show: false,
frame: false,
transparent: true,
acceptFirstMouse: true
});

// and load the index.html of the app.
mainWindow.loadURL("file://" + __dirname + "/clipppy.html");

// show window after loaded
mainWindow.showInactive();

// Open the DevTools.
// mainWindow.webContents.openDevTools();

// Emitted when the window is moved.
mainWindow.on("move", function () {
mainWindow.webContents.executeJavaScript(
"saveWindowPosition(" + mainWindow.getPosition().join(", ") + ")"
);
});

// Emitted when the window is closed.
mainWindow.on("closed", function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
10 changes: 10 additions & 0 deletions app/clippy-js/MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright (c) 2012 Fireplace, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

THE ABOVE LICENSE IS FOR THE CODE (JAVASCRIPT AND CSS) IN CLIPPY.JS ONLY.
All Microsoft agents, including agent names, the Clippy brand and all resources are the property of Microsoft and their respective owners.
1 change: 1 addition & 0 deletions app/clippy-js/agents/Clippy/agent.js

Large diffs are not rendered by default.

Binary file added app/clippy-js/agents/Clippy/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/clippy-js/agents/Clippy/sounds-mp3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Clippy/sounds-ogg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/F1/agent.js

Large diffs are not rendered by default.

Binary file added app/clippy-js/agents/F1/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/clippy-js/agents/F1/sounds-mp3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/F1/sounds-ogg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Genius/agent.js

Large diffs are not rendered by default.

Binary file added app/clippy-js/agents/Genius/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/clippy-js/agents/Genius/sounds-mp3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Genius/sounds-ogg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Links/agent.js

Large diffs are not rendered by default.

Binary file added app/clippy-js/agents/Links/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/clippy-js/agents/Links/sounds-mp3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Links/sounds-ogg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Rocky/agent.js

Large diffs are not rendered by default.

Binary file added app/clippy-js/agents/Rocky/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/clippy-js/agents/Rocky/sounds-mp3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/clippy-js/agents/Rocky/sounds-ogg.js

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions app/clippy-js/clippy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.clippy, .clippy-balloon {
position: fixed;
z-index: 1000;
}

.clippy-balloon {

background: #FFC;
cursor: pointer;
color: black;
padding: 8px;
border: 1px solid black;
border-radius: 5px;

}

.clippy-content {
max-width: 200px;
min-width: 120px;
font-family: "Microsoft Sans", sans-serif;
font-size: 10pt;
}

.clippy-tip {
width: 10px;
height: 16px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAMAAAAlvKiEAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAlQTFRF///MAAAA////52QwgAAAAAN0Uk5T//8A18oNQQAAAGxJREFUeNqs0kEOwCAIRFHn3//QTUU6xMyyxii+jQosrTPkyPEM6IN3FtzIRk1U4dFeKWQiH6pRRowMVKEmvronEynkwj0uZJgR22+YLopPSo9P34wJSamLSU7lSIWLJU7NkNomNlhqxUeAAQC+TQLZyEuJBwAAAABJRU5ErkJggg==) no-repeat;
position: absolute;
}

.clippy-top-left .clippy-tip {
top: 100%;
margin-top: 0px;
left: 100%;
margin-left: -50px;
}

.clippy-top-right .clippy-tip {
top: 100%;
margin-top: 0px;
left: 0;
margin-left: 50px;
background-position: -10px 0;

}

.clippy-bottom-right .clippy-tip {
top: 0;
margin-top: -16px;
left: 0;
margin-left: 50px;
background-position: -10px -16px;
}

.clippy-bottom-left .clippy-tip {
top: 0;
margin-top: -16px;
left: 100%;
margin-left: -50px;
background-position: 0px -16px;
}

Loading

0 comments on commit 5d52d1d

Please sign in to comment.