event.preventDefault();
}
});
+ wrt.on('ambient-tick', function() {
+ if (_this.webApplication)
+ _this.webApplication.ambientTick();
+ });
+ wrt.on('ambient-changed', function(event, ambient_mode) {
+ console.log('ambient-changed , ambient_mode:' + ambient_mode);
+ if (_this.webApplication)
+ _this.webApplication.ambientChanged(ambient_mode);
+ });
wrt.on('addon-installed', function(event, path) {
console.log('addon-installed at ' + path);
let dbInfo = AddonManager.checkAddon(path);
});
}
}
+ ambientTick() {
+ const kAmbientTickEventScript =
+ '(function(){' +
+ 'var __event = document.createEvent(\"CustomEvent\");' +
+ '__event.initCustomEvent(\"timetick\", true, true);' +
+ 'document.dispatchEvent(__event);' +
+ 'for (var i=0; i < window.frames.length; i++)' +
+ '{ window.frames[i].document.dispatchEvent(__event); }' +
+ '})()';
+ wrt.executeJS(this.mainWindow.webContents, kAmbientTickEventScript);
+ }
+ ambientChanged(ambient_mode) {
+ const kAmbientChangedEventScript =
+ '(function(){' +
+ 'var __event = document.createEvent(\"CustomEvent\");' +
+ 'var __detail = {};' +
+ '__event.initCustomEvent(\"ambientmodechanged\",true,true,__detail);' +
+ '__event.detail.ambientMode = ' +
+ (ambient_mode ? 'true' : 'false') + ';' +
+ 'document.dispatchEvent(__event);' +
+ 'for (var i=0; i < window.frames.length; i++)' +
+ '{ window.frames[i].document.dispatchEvent(__event); }' +
+ '})()';
+ wrt.executeJS(this.mainWindow.webContents, kAmbientChangedEventScript);
+ }
}
module.exports = WebApplication;