-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
46 lines (40 loc) · 1.51 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Electron Joke</title>
<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<link rel="stylesheet" type="text/css" href="node_modules/materialize-css/dist/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<div class="container">
<h4>Joke of the turn</h4>
<div id="joke" style="min-height: 100px;"></div>
<a id="btn-joke-next" class="waves-effect waves-light btn-large"><i class="material-icons right">cloud</i>next turn</a>
</div>
<script src="node_modules/materialize-css/dist/js/materialize.min.js"></script>
<script>
const { ipcRenderer } = require('electron')
document.addEventListener("DOMContentLoaded", () => {
let joke
let populateJoke = (joke) => {
document.getElementById('joke').innerHTML = joke;
}
let getJoke = () => {
ipcRenderer.send('joke-request')
}
document.getElementById('btn-joke-next').onclick = () => {
getJoke()
}
ipcRenderer.on('joke-response', (e, res) => {
joke = res.replace(/\r\n/g, '')
populateJoke(joke)
})
// ignite
getJoke()
})
</script>
</body>
</html>