-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
30 lines (29 loc) · 1.01 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Psh Password Manager</title>
<link rel="stylesheet" href="/index.css" />
<script>
function emit(eventName) {
const event = new Event(eventName);
document.dispatchEvent(event);
}
if (window.__TAURI__ !== undefined) {
const { appWindow } = window.__TAURI__.window;
appWindow.onFocusChanged(({ payload: focused }) => {
let eventName = undefined;
if (focused === true) {
eventName = 'resume';
} else {
eventName = 'pause';
}
emit(eventName);
});
} else {
document.addEventListener('focus', () => { emit('resume') });
document.addEventListener('blur', () => { emit('pause') });
}
</script>
</head>
</html>