This repository was archived by the owner on Jun 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrowser.js
executable file
·59 lines (49 loc) · 1.71 KB
/
browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
window.onresize = doLayout;
var isLoading = false;
onload = function() {
var webview = document.querySelector('webview');
doLayout();
webview.addEventListener('exit', handleExit);
webview.addEventListener('loadstop', handleLoadStop);
webview.addEventListener('loadabort', handleLoadAbort);
};
function navigateTo(url) {
resetExitedState();
document.querySelector('webview').src = url;
}
function doLayout() {
var webview = document.querySelector('webview');
var webviewWidth = document.documentElement.clientWidth;
var webviewHeight = document.documentElement.clientHeight;
webview.style.width = webviewWidth + 'px';
webview.style.height = webviewHeight + 'px';
var sadWebview = document.querySelector('#sad-webview');
sadWebview.style.width = webviewWidth + 'px';
sadWebview.style.height = webviewHeight * 2/3 + 'px';
sadWebview.style.paddingTop = webviewHeight/3 + 'px';
}
function handleExit(event) {
console.log(event.type);
document.body.classList.add('exited');
if (event.type == 'abnormal') {
document.body.classList.add('crashed');
} else if (event.type == 'killed') {
document.body.classList.add('killed');
}
}
function resetExitedState() {
document.body.classList.remove('exited');
document.body.classList.remove('crashed');
document.body.classList.remove('killed');
}
function handleLoadStop(event) {
// We don't remove the loading class immediately, instead we let the animation
// finish, so that the spinner doesn't jerkily reset back to the 0 position.
isLoading = false;
}
function handleLoadAbort(event) {
console.log('oadAbort');
console.log(' url: ' + event.url);
console.log(' isTopLevel: ' + event.isTopLevel);
console.log(' type: ' + event.type);
}