forked from DigitalHistory/history-please
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (52 loc) · 2.03 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Historymatic</title>
<style>
</style>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<div class="wrapper">
<div id="container" hidden></div>
<div class="button-container centered">
<button id="button">History, please</button>
</div>
</div>
<script>
// using `ipcRenderer` lets us do some fancy
// event handling.
const {ipcRenderer} = require("electron");
// this is nice -- smooth things out a bit
// by creating variables for the elements we care about.
const buttonContainer = document.querySelector(".button-container");
const buttonEl = document.getElementById("button");
const containerEl = document.getElementById("container");
// on button click, retrieve and show the next
// page in our shuffled list
buttonEl.addEventListener("click", () => {
// update this to send new "get next" signal
//ipcRenderer.send("get-history");
ipcRenderer.send("get-next");
});
// this really is a bit convoluted -- instead of
// all thisevent signalling we could just wirte a simple function or two
ipcRenderer.on("recipe", (event, arg) => {
// this is silly -- let's remove this.
// buttonContainer.classList.remove("centered");
container.hidden = false;
container.innerHTML = arg;
});
// add a couple of key bindings; now we can go back
// and forth with `n` and `p`
window.addEventListener("keyup", function(event) {
if (event.key == "n" || event.key == "Enter")
{ipcRenderer.send('get-next');
} else if (event.key == "p") {
ipcRenderer.send('get-previous');
}
});
</script>
</body>
</html>