mcopy/app/main.js

55 lines
1.1 KiB
JavaScript
Raw Normal View History

var electron = require('electron'),
2016-04-11 14:49:57 +00:00
fs = require('fs'),
Menu = require('menu'),
ipcMain = require('electron').ipcMain,
app = electron.app,
BrowserWindow = electron.BrowserWindow,
uuid = require('node-uuid'),
mcopy = {};
2016-04-11 06:01:26 +00:00
mcopy.cfg = JSON.parse(fs.readFileSync('./cfg.json', 'utf8'));
mcopy.arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg);
var mainWindow;
2016-04-11 06:01:26 +00:00
2016-04-11 14:49:57 +00:00
var init = function () {
createWindow();
mcopy.arduino.init(function (success) {
mcopy.arduino.connect(function () {
//
});
});
2016-04-11 14:49:57 +00:00
};
2016-04-11 06:01:26 +00:00
2016-04-11 14:49:57 +00:00
var createMenu = function () {
2016-04-11 06:01:26 +00:00
2016-04-11 14:49:57 +00:00
};
2016-04-11 06:01:26 +00:00
2016-04-11 14:49:57 +00:00
var createWindow = function () {
mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadURL('file://' + __dirname + '/index.html');
mainWindow.webContents.openDevTools();
mainWindow.on('closed', function() {
mainWindow = null;
});
2016-04-11 06:01:26 +00:00
}
2016-04-11 14:49:57 +00:00
app.on('ready', init);
2016-04-11 06:01:26 +00:00
app.on('window-all-closed', function () {
2016-04-11 14:49:57 +00:00
if (process.platform !== 'darwin') {
app.quit();
}
2016-04-11 06:01:26 +00:00
});
app.on('activate', function () {
2016-04-11 14:49:57 +00:00
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on('light', function(event, arg) {
//
event.returnValue = true;
});