Skip to content

Commit

Permalink
Merge pull request #2 from rey/feature_restructure
Browse files Browse the repository at this point in the history
Feature restructure
  • Loading branch information
rey committed Jan 6, 2016
2 parents 89d873e + eb1d642 commit 0095416
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
app_build
_build
File renamed without changes
File renamed without changes
File renamed without changes
59 changes: 59 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var app = require('app');
var Tray = require('tray');
var Menu = require('menu');
var path = require('path');
var ping = require("net-ping")
var BrowserWindow = require('browser-window');

var iconPath = path.join(__dirname, 'icon.png');
var appIcon = null;
var win = null;

app.on('ready', function(){
win = new BrowserWindow({show: false});
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([
{ label: 'Quit',
accelerator: 'Command+Q',
selector: 'terminate:',
}
]);

appIcon.setToolTip('This is my application.');
appIcon.setContextMenu(contextMenu);

var count = 0;

setInterval(function() {

var target="8.8.8.8";
// var target="127.0.0.1";
var options = {
timeout: 500
// timeout: 2000
};

var session = ping.createSession (options);
session.pingHost (target, function (error, target, sent, rcvd) {

var delta = rcvd - sent;

// error
if (error) {
console.log ("🍎 " + target + " count: " + count + " error: " + error.toString ());
appIcon.setImage(__dirname + "/dead.png");
}

// success
else {
console.log ("🍏 " + target + " count: " + count + " delta: " + delta + " sent: " + sent.getUTCMilliseconds() + " rcvd: " + rcvd.getUTCMilliseconds());
appIcon.setImage(__dirname + "/alive.png");
}

count++;
});

}, 1000);

});

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "palin",
"version": "0.1.0",
"version": "0.2.0",
"description": "Check if you're online",
"main": "src/main.js",
"main": "main.js",
"dependencies": {
"menubar": "^3.0.0",
"net-ping": "^1.1.12"
Expand All @@ -12,7 +12,7 @@
"electron-prebuilt": "^0.36.2"
},
"scripts": {
"build": "electron-packager . Palin --platform=darwin --arch=x64 --version=0.36.2 --overwrite --out=app_build",
"build": "electron-packager . Palin --platform=darwin --arch=x64 --version=0.36.2 --overwrite --out=_build",
"start": "electron ."
},
"author": "Rey Dhuny"
Expand Down
8 changes: 0 additions & 8 deletions src/index.html

This file was deleted.

49 changes: 0 additions & 49 deletions src/main.js

This file was deleted.

0 comments on commit 0095416

Please sign in to comment.