handle focus event, fix whitespace

This commit is contained in:
Tor Hveem 2016-04-03 13:47:38 +02:00
parent 1d52986bc6
commit 382a5dc5c0

View file

@ -1,18 +1,18 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8">
<script> <script>
onload = function() { onload = function() {
const ipc= require('electron').ipcRenderer; const ipc= require('electron').ipcRenderer;
const remote = require('electron').remote;
const nativeImage = require('electron').nativeImage;
var webview = document.getElementById("glowingbear"); var webview = document.getElementById("glowingbear");
var handleconsole = function(e) { var handleconsole = function(e) {
if(e.message.substring(0,7) == "badge: ") {
ipc.send('badge', e.message.substring(7));
}else{
console.log("webview: " + e.message); console.log("webview: " + e.message);
} }
}
var handlenewwindow = function(e) { var handlenewwindow = function(e) {
require('shell').openExternal(e.url); require('shell').openExternal(e.url);
} }
@ -22,6 +22,11 @@ onload = function() {
webview.addEventListener("console-message", handleconsole); webview.addEventListener("console-message", handleconsole);
webview.addEventListener("new-window", handlenewwindow); webview.addEventListener("new-window", handlenewwindow);
webview.addEventListener("page-title-set", handletitleset); 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> </script>
</head> </head>