forked from webrecorder/webrecorder-player
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
42 lines (34 loc) · 945 Bytes
/
preload.js
File metadata and controls
42 lines (34 loc) · 945 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { ipcRenderer } = require('electron');
document.addEventListener('DOMContentLoaded', (evt) => {
// if wbinfo is not present assume 404
if (typeof window.wbinfo !== 'undefined') {
const state = {
wb_type: 'load',
url: window.wbinfo.url,
ts: window.wbinfo.timestamp
};
ipcRenderer.sendToHost('load', state);
} else {
ipcRenderer.sendToHost('not-found', {wb_type: 'not-found'});
}
});
document.addEventListener('hashchange', (evt) => {
const state = {
wb_type: 'hashchange',
hash: window.location.hash
};
ipcRenderer.sendToHost('hashchange', state);
});
document.addEventListener('drop', (evt) => {
evt.preventDefault();
const filename = evt.dataTransfer.files[0].path;
const state = {
wb_type: 'open',
filename
};
ipcRenderer.sendToHost('open', state);
});
document.addEventListener('dragover', (evt) => {
evt.preventDefault();
evt.stopPropagation();
});