-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenderer.html
More file actions
53 lines (45 loc) · 1.46 KB
/
renderer.html
File metadata and controls
53 lines (45 loc) · 1.46 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag -->
<meta
http-equiv="Content-Security-Policy"
content="script-src 'self' 'unsafe-inline';"
/>
<script type="text/javascript">
function setVal(id, value) {
document.getElementById(id).innerHTML = value;
}
function toMain() {
window.api.toMain(document.getElementById("msg").value);
}
function toBg() {
window.api.forBackground(document.getElementById("msg").value);
}
function assignTask() {
window.api.assignTask(document.getElementById("task").value);
}
window.api.toRenderer((data) => {
setVal("received", data);
});
window.api.status((threads, tasks) => {
setVal("threads", threads);
setVal("tasks", tasks);
});
</script>
</head>
<body>
<h2>Background Threads</h2>
Msg: <input id="msg" type="textfield" value="a message" /><br />
<button onclick="toMain()">Send to main thread</button><br />
<button onclick="toBg()">Send to bg thread</button>
<label id="received"></label>
<br /><br />
Task: <input id="task" type="textfield" value="a task" /><br />
<button onclick="assignTask()">Do background work</button>
<br /><br />
<label id="threads">0</label> background threads available<br />
<label id="tasks">0</label> tasks queued
</body>
</html>