-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
overlay.html
86 lines (72 loc) · 2.69 KB
/
overlay.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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="res/style.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.structure.min.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.theme.min.css" />
<script>if (typeof module === 'object') {
window.module = module;
module = undefined;
}</script>
<!-- normal script imports etc -->
<script src="res/jquery-3.3.1.min.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module)
module = window.module;</script>
<script>
const logger = require('./modules/Log').getLogger(__filename);
var renderer = require('electron').ipcRenderer;
var timestamp = null;
function hideOverlay(msgTimestamp) {
if(msgTimestamp !== timestamp) {
logger.info(`Different timestamps ${msgTimestamp} -> ${timestamp}, not hiding window overlay`);
} else {
logger.info("Hiding overlay");
renderer.send("hideOverlay");
}
}
$(document).ready(function () {
renderer.on("message", (event, msg) => {
timestamp = msg.timestamp;
var msgDiv = $("#messages");
msgDiv.html(`<span class='message'>${msg.text}</span>`);
logger.info("Fading in overlay");
msgDiv.fadeIn(500);
var messageWidth = document.getElementById("messages").scrollWidth + (msgDiv.has("img").length ? 40 : 0);
setTimeout(() => { window.resizeTo(messageWidth, 40); }, 10);
logger.info(`Resizing to ${messageWidth}`);
setTimeout(() => { msgDiv.fadeOut(500, () => {hideOverlay(msg.timestamp);} ); }, 4000);
});
});
</script>
<style>
div.cover {
position:absolute;
overflow:hidden;
x:0;
y:0;
height:100%;
width:100%;
-webkit-user-select: none;
-webkit-app-region:drag;
}
div.overlayMessage {
padding-left:10px;
padding-right:10px;
display:none;
line-height:40px;
width:auto;
white-space:nowrap;
overflow:hidden;
vertical-align:middle;
}
</style>
</head>
<body style="overflow:hidden !important;" onmouseover="logger.info('moused over');hideOverlay(timestamp);">
<div class="cover"> </div>
<div id="messages" class="overlayMessage messageSection"></div>
</body>
</html>