-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aouerfelli
committed
Jan 2, 2017
1 parent
2a961ce
commit 47b536a
Showing
21 changed files
with
1,123 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,6 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
dist | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
npm-debug.log | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# station-timer | ||
A simple timer application that repeatedly counts down and loops for a given number of stations | ||
# Station Timer | ||
|
||
A minimal timer application built with [Electron](http://electron.atom.io) that | ||
counts down and loops for a given number of stations. This was originally | ||
created for a classroom environment, where the instructor would have a number of | ||
stations set up and would allocate a certain amount of time to stay at each | ||
station, and would then give some additional time to clean up and go to the next | ||
station. | ||
|
||
## Releases (NOT AVAILABE YET) | ||
There are builds available for Windows and macOS, since those are the only | ||
platforms I am able to use and test on at the moment. If you would like to | ||
build for your own platform, you can follow the steps [below](#Build). | ||
|
||
## Build | ||
To build for your specific platform: | ||
```sh | ||
git clone https://github.com/aouerfelli/station-timer.git | ||
cd station-timer | ||
npm install && npm run dist | ||
``` | ||
Your build should be located in the `dist` directory if the build was | ||
successful. | ||
|
||
To customize the build, see the different options available in | ||
[electron-builder](https://github.com/electron-userland/electron-builder/wiki/Options). | ||
|
||
## Run | ||
If you would like to run the code directly instead of building it: | ||
```sh | ||
git clone https://github.com/aouerfelli/station-timer.git | ||
cd station-timer | ||
npm install && npm start | ||
``` | ||
|
||
## License | ||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
const {app, BrowserWindow, ipcMain} = require('electron'); | ||
|
||
let mainWindow, setupWindow, pauseWindow; | ||
|
||
function createMainWindow() { | ||
mainWindow = new BrowserWindow({ | ||
fullscreen: true, | ||
frame: false | ||
}); | ||
mainWindow.loadURL(`file://${__dirname}/views/index.html`); | ||
mainWindow.setMenu(null); | ||
|
||
mainWindow.once('ready-to-show', mainWindow.show); | ||
|
||
mainWindow.on('closed', () => mainWindow = null); | ||
} | ||
|
||
function createSetupModalWindow() { | ||
setupWindow = new BrowserWindow({ | ||
parent: mainWindow, | ||
modal: true, | ||
minWidth: 400, | ||
minHeight: 300, | ||
frame: false | ||
}); | ||
setupWindow.loadURL(`file://${__dirname}/views/setup.html`); | ||
setupWindow.setMenu(null); | ||
|
||
setupWindow.once('ready-to-show', setupWindow.show); | ||
|
||
setupWindow.on('close', exitApp); | ||
|
||
setupWindow.on('closed', () => setupWindow = null); | ||
} | ||
|
||
function createPauseModalWindow() { | ||
mainWindow.webContents.executeJavaScript( | ||
'document.body.classList.add(\'dim\')' | ||
); | ||
|
||
pauseWindow = new BrowserWindow({ | ||
parent: mainWindow, | ||
modal: true, | ||
width: 400, | ||
height: 250, | ||
resizable: false, | ||
closable: false, | ||
frame: false | ||
}); | ||
pauseWindow.loadURL(`file://${__dirname}/views/pause.html`); | ||
pauseWindow.setMenu(null); | ||
|
||
pauseWindow.once('ready-to-show', pauseWindow.show); | ||
|
||
pauseWindow.on('close', exitApp); | ||
|
||
pauseWindow.on('closed', () => { | ||
mainWindow.webContents.executeJavaScript( | ||
'document.body.classList.remove(\'dim\')' | ||
); | ||
pauseWindow = null; | ||
}); | ||
} | ||
|
||
function createStartWindows() { | ||
createMainWindow(); | ||
createSetupModalWindow(); | ||
} | ||
|
||
function exitApp() { | ||
// Do not exit the program on macOS (standard OS-specific behaviour). | ||
// Instead, close all open windows. | ||
if (process.platform === 'darwin') { | ||
// Lose app and window focus before closing windows | ||
app.hide(); | ||
BrowserWindow.getAllWindows().forEach(win => win.close()); | ||
} else { | ||
app.quit(); | ||
} | ||
} | ||
|
||
app.on('ready', createStartWindows); | ||
|
||
app.on('window-all-closed', exitApp); | ||
|
||
app.on('activate', createStartWindows); | ||
|
||
ipcMain.on('setup-timer', (evt, settings) => | ||
mainWindow.webContents.send('start-timer', settings) | ||
); | ||
|
||
ipcMain.on('pause', createPauseModalWindow); | ||
|
||
/** | ||
* Called after the pause window has been opened and it is safe to wait for a | ||
* synchronous reply before continuing the counter. | ||
* There is undoubtedly a better way of handling pause, but this works for now. | ||
* | ||
* @return the false boolean value for the paused flag in mainWindow | ||
*/ | ||
ipcMain.on('pause-wait', evt => { | ||
// If it has already been closed before this channel, then return immediately | ||
if (pauseWindow == null) { | ||
evt.returnValue = false; | ||
} else { | ||
pauseWindow.on('closed', () => evt.returnValue = false); | ||
} | ||
}); | ||
|
||
ipcMain.on('exit', exitApp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "station-timer", | ||
"productName": "Station Timer", | ||
"version": "1.0.0", | ||
"description": "A simple timer application that repeatedly counts down for a given amount of times", | ||
"author": "Ahmad Ouerfelli <[email protected]>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/aouerfelli/station-timer" | ||
}, | ||
"bugs": "https://github.com/aouerfelli/station-timer/issues", | ||
"main": "./main.js" | ||
} |
Oops, something went wrong.