handle focus event, fix whitespace
This commit is contained in:
parent
1d52986bc6
commit
382a5dc5c0
1 changed files with 22 additions and 17 deletions
|
@ -1,18 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
onload = function() {
|
||||
const ipc= require('electron').ipcRenderer;
|
||||
const remote = require('electron').remote;
|
||||
const nativeImage = require('electron').nativeImage;
|
||||
|
||||
var webview = document.getElementById("glowingbear");
|
||||
|
||||
var handleconsole = function(e) {
|
||||
if(e.message.substring(0,7) == "badge: ") {
|
||||
ipc.send('badge', e.message.substring(7));
|
||||
}else{
|
||||
console.log("webview: " + e.message);
|
||||
}
|
||||
}
|
||||
var handlenewwindow = function(e) {
|
||||
require('shell').openExternal(e.url);
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ onload = function() {
|
|||
webview.addEventListener("console-message", handleconsole);
|
||||
webview.addEventListener("new-window", handlenewwindow);
|
||||
webview.addEventListener("page-title-set", handletitleset);
|
||||
|
||||
ipc.on('browser-window-focus', function() {
|
||||
setTimeout(function() { webview.focus(); }, 0);
|
||||
setTimeout(function() { webview.executeJavaScript("document.getElementById(\"sendMessage\").focus();") }, 0);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
Loading…
Reference in a new issue