Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from mozilla-services/multi-platform
Browse files Browse the repository at this point in the history
Multi-platform support
  • Loading branch information
magopian committed Jan 27, 2017
2 parents 27898ef + 3f38804 commit 5d355c6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ Grab it from the Chrome Store: https://chrome.google.com/webstore/detail/hoverpa
1. Go to ``chrome://extensions``
2. Tick the Developer Mode
3. Load the hoverpad repository folder.

## Desktop app

Using [Electron](http://electron.atom.io/), you can run the hoverpad as an
application on your desktop.

First install electron:

npm install -g electron

Then run the application:

electron electron.js
39 changes: 39 additions & 0 deletions electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict'
const electron = require('electron')

const app = electron.app // this is our app
const BrowserWindow = electron.BrowserWindow // This is a Module that creates windows

let mainWindow // saves a global reference to mainWindow so it doesn't get garbage collected

app.on('ready', createWindow) // called when electron has initialized

// This will create our app window, no surprise there
function createWindow () {
mainWindow = new BrowserWindow({
width: 1024,
height: 768
})

// display the index.html file
mainWindow.loadURL(`file://${ __dirname }/index.html`)

// open dev tools by default so we can see any console errors
//mainWindow.webContents.openDevTools()

mainWindow.on('closed', function () {
mainWindow = null
})
}

/* Mac Specific things */

// when you close all the windows on a non-mac OS it quits the app
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') { app.quit() }
})

// if there is no mainWindow it creates one (like when you click the dock icon)
app.on('activate', () => {
if (mainWindow === null) { createWindow() }
})
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"debug": "elm-live Main.elm --output=hoverpad.js --open -- --debug",
"live": "elm-live Main.elm --output=hoverpad.js --open",
"fx-web-ext": "web-ext build",
"electron": "electron electron.js",
"publish-to-gh-pages": "mkdir -p dist && cp -r index.html *.js *.css icons dist && gh-pages --dist ./dist"
},
"repository": {
Expand All @@ -23,6 +24,7 @@
"elm": "^0.18.0",
"elm-live": "^2.6.1",
"web-ext": "^1.7.0",
"gh-pages": "^0.11.0"
"gh-pages": "^0.11.0",
"electron": "1.4.15"
}
}
9 changes: 8 additions & 1 deletion ports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const KEY_PREFIX = "hoverpad";
var credentials;
var app = Elm.Main.fullscreen();
var app;
if (typeof(Elm) === "undefined") {
// This happens if we're in the context of Electron.
const Elm = require('./hoverpad.js');
app = Elm.Main.fullscreen();
} else {
app = Elm.Main.fullscreen();
}

function placeCaretAtEnd(el) {
return function() {
Expand Down

0 comments on commit 5d355c6

Please sign in to comment.