Skip to content

Commit

Permalink
Move app from nw.js to Electron
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Kridner committed Feb 3, 2017
1 parent 8c19eef commit eb5d6d7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
55 changes: 55 additions & 0 deletions App/main.js
@@ -0,0 +1,55 @@
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')

// 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.
let win

function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600})

// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, '../START.htm'),
protocol: 'file:',
slashes: true
}))

// Open the DevTools.
win.webContents.openDevTools()

// Emitted when the window is closed.
win.on('closed', () => {
// 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.
win = null
})
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
18 changes: 7 additions & 11 deletions App/package.json
@@ -1,16 +1,11 @@
{
"name": "beaglebone-getting-started"
, "version": "0.0.2"
, "main": "index.html"
, "version": "0.0.3"
, "main": "main.js"
, "description": "BeagleBone Getting Started App"
, "keywords": [ "beaglebone", "linux", "nw.js" ]
, "window": {
"title": "BeagleBone Getting Started App"
,"toolbar": true
, "icon": "Docs/beagle.png"
, "width": 1024
, "height": 600
, "position": "center"
, "keywords": [ "beaglebone", "linux", "electron" ]
, "scripts": {
"start": "electron ."
}
, "webkit": {
"plugin": true
Expand All @@ -19,7 +14,7 @@
{
"name": "Jason Kridner"
, "email": "jkridner@beagleboard.org"
, "web": "http://blog.hangerhead.com"
, "web": "http://jkridner.wordpress.com"
}
]
, "repositories": [
Expand All @@ -33,5 +28,6 @@
"socket.io": "0.9.11"
, "jsdom": "0.2.10"
, "mdns": "0.0.7"
, "electron": "1.4.15"
}
}

0 comments on commit eb5d6d7

Please sign in to comment.