2015-07-05 06:08:13 +00:00
|
|
|
/**
|
2016-01-22 11:57:39 +00:00
|
|
|
Preload file that will be executed in the renderer process
|
2015-07-05 06:08:13 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-23 01:27:09 +00:00
|
|
|
var electron = require('electron');
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
var webFrame = electron.webFrame;
|
2015-07-05 06:08:13 +00:00
|
|
|
|
2016-01-23 05:32:20 +00:00
|
|
|
setNotificationCallback(function (title, opt) {
|
|
|
|
ipc.send('notification', title, opt);
|
2016-01-22 18:44:42 +00:00
|
|
|
});
|
|
|
|
|
2016-01-23 05:32:20 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
|
// do things
|
2016-01-21 17:32:21 +00:00
|
|
|
});
|
2016-01-19 12:26:19 +00:00
|
|
|
|
|
|
|
ipc.on('params', function (event, message) {
|
2015-07-05 06:08:13 +00:00
|
|
|
var appArgs = JSON.parse(message);
|
2016-01-22 11:57:39 +00:00
|
|
|
console.log('nativefier.json', appArgs);
|
2016-01-19 12:26:19 +00:00
|
|
|
});
|
2016-01-22 18:44:42 +00:00
|
|
|
|
2016-01-23 01:27:09 +00:00
|
|
|
ipc.on('change-zoom', function (event, message) {
|
|
|
|
webFrame.setZoomFactor(message);
|
|
|
|
});
|
|
|
|
|
2016-01-23 05:43:33 +00:00
|
|
|
|
2016-01-23 05:32:20 +00:00
|
|
|
/**
|
|
|
|
* Patches window.Notification to set a callback on a new Notification
|
|
|
|
* @param callback
|
|
|
|
*/
|
|
|
|
function setNotificationCallback(callback) {
|
|
|
|
|
|
|
|
var oldNotify = window.Notification;
|
|
|
|
var newNotify = function (title, opt) {
|
|
|
|
callback(title, opt);
|
|
|
|
return new oldNotify(title, opt);
|
|
|
|
};
|
|
|
|
newNotify.requestPermission = oldNotify.requestPermission.bind(oldNotify);
|
|
|
|
Object.defineProperty(newNotify, 'permission', {
|
|
|
|
get: function () {
|
|
|
|
return oldNotify.permission;
|
|
|
|
}
|
|
|
|
});
|
2016-01-22 18:44:42 +00:00
|
|
|
|
2016-01-23 05:32:20 +00:00
|
|
|
window.Notification = newNotify;
|
2016-01-22 18:44:42 +00:00
|
|
|
}
|