npm install
npm start
Last active
August 29, 2015 14:24
-
-
Save maxkueng/5a17b848d152442b9f4d to your computer and use it in GitHub Desktop.
Electron online / offline test
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
var app = require('app'); | |
var BrowserWindow = require('browser-window'); | |
var onlineStatusWindow; | |
app.on('ready', function() { | |
onlineStatusWindow = new BrowserWindow({ width: 800, height: 600, show: true }); | |
onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<script> | |
var alertOnlineStatus = function() { | |
window.alert(navigator.onLine ? 'online' : 'offline'); | |
}; | |
window.addEventListener('online', alertOnlineStatus); | |
window.addEventListener('offline', alertOnlineStatus); | |
alertOnlineStatus(); | |
</script> | |
</body> | |
</html> |
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
{ | |
"name": "electron-onlineoffline", | |
"version": "1.0.0", | |
"main": "main.js", | |
"scripts": { | |
"start": "electron ./" | |
}, | |
"devDependencies": { | |
"electron-prebuilt": "0.28.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment