2015-07-05 06:08:13 +00:00
|
|
|
/**
|
|
|
|
* Created by JiaHao on 5/7/15.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var ipc = require('ipc');
|
|
|
|
|
|
|
|
ipc.on('params', function(message) {
|
|
|
|
|
|
|
|
var appArgs = JSON.parse(message);
|
2015-07-06 01:46:27 +00:00
|
|
|
console.log(appArgs);
|
2015-07-05 06:08:13 +00:00
|
|
|
document.title = appArgs.name;
|
|
|
|
|
|
|
|
var webView = document.createElement('webview');
|
|
|
|
|
2015-07-05 12:11:34 +00:00
|
|
|
webView.setAttribute('id', 'webView');
|
2015-07-05 06:08:13 +00:00
|
|
|
webView.setAttribute('src', appArgs.targetUrl);
|
|
|
|
webView.setAttribute('autosize', 'on');
|
2015-07-06 02:31:09 +00:00
|
|
|
webView.setAttribute('minwidth', '100');
|
|
|
|
webView.setAttribute('minheight', '100');
|
2015-07-05 06:08:13 +00:00
|
|
|
|
2015-07-05 12:44:45 +00:00
|
|
|
webView.addEventListener('new-window', function(e) {
|
|
|
|
require('shell').openExternal(e.url);
|
|
|
|
});
|
|
|
|
|
2015-07-06 01:38:04 +00:00
|
|
|
// We check for desktop notifications by listening to a title change in the webview
|
|
|
|
// Not elegant, but it will have to do
|
2015-07-06 01:46:27 +00:00
|
|
|
if (appArgs.badge) {
|
2015-07-06 03:45:55 +00:00
|
|
|
webView.addEventListener('did-finish-load', function(e) {
|
|
|
|
webView.addEventListener('page-title-set', function(event) {
|
|
|
|
ipc.send('notification-message', 'TITLE_CHANGED');
|
|
|
|
});
|
2015-07-06 01:46:27 +00:00
|
|
|
});
|
|
|
|
}
|
2015-07-06 01:38:04 +00:00
|
|
|
|
2015-07-05 06:08:13 +00:00
|
|
|
var webViewDiv = document.getElementById('webViewDiv');
|
|
|
|
webViewDiv.appendChild(webView);
|
|
|
|
|
2015-07-05 12:11:34 +00:00
|
|
|
Mousetrap.bind('mod+c', function(e) {
|
|
|
|
var webView = document.getElementById('webView');
|
|
|
|
webView.copy();
|
|
|
|
});
|
|
|
|
|
|
|
|
Mousetrap.bind('mod+x', function(e) {
|
|
|
|
var webView = document.getElementById('webView');
|
|
|
|
webView.cut();
|
|
|
|
});
|
|
|
|
|
|
|
|
Mousetrap.bind('mod+v', function(e) {
|
|
|
|
var webView = document.getElementById('webView');
|
|
|
|
webView.paste();
|
|
|
|
});
|
|
|
|
|
|
|
|
Mousetrap.bind('mod+a', function(e) {
|
|
|
|
var webView = document.getElementById('webView');
|
|
|
|
webView.selectAll();
|
|
|
|
});
|
|
|
|
|
|
|
|
Mousetrap.bind('mod+z', function(e) {
|
|
|
|
var webView = document.getElementById('webView');
|
|
|
|
webView.undo();
|
|
|
|
});
|
2015-07-05 06:08:13 +00:00
|
|
|
});
|
|
|
|
|