-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebview-init.js
More file actions
26 lines (24 loc) · 889 Bytes
/
webview-init.js
File metadata and controls
26 lines (24 loc) · 889 Bytes
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
/*
This script triggers the webview launcher initialisation sequence.
By default the initialisation is done on first load, this script provides support for navigation and page reload.
Lua code in HTML must support multiple executions as well as onWebviewInitalized handler.
*/
(function() {
var timeoutDelay = 1;
function handleLoad() {
if ((typeof window.external !== 'object') || (typeof window.external.invoke !== 'function')) {
if (timeoutDelay > 30000) {
throw 'window.external is not available';
}
setTimeout(handleLoad, timeoutDelay); // Let external.invoke be registered
timeoutDelay = timeoutDelay * 2;
} else if (typeof window.webview !== 'object') {
window.external.invoke(':init:');
}
}
if (document.readyState === 'complete') {
handleLoad();
} else {
window.addEventListener('load', handleLoad);
}
})();