-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.html
38 lines (31 loc) · 903 Bytes
/
mainwindow.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>List</title>
</head>
<body>
<h1>Item List</h1>
<ul></ul>
<script>
const electron = require('electron');
const {ipcRenderer} = electron;
const ul = document.querySelector('ul');
ipcRenderer.on('item:add', function(e, item){
const li = document.createElement('li');
const itemText = document.createTextNode(item);
li.appendChild(itemText);
ul.appendChild(li);
});
ipcRenderer.on('item:clear', function(){
ul.innerHTML = '';
});
//remove item
ul.addEventListener('dblclick', removeitem);
function removeitem(e){;
console.log(e.target.textContent)
ipcRenderer.send('item:remove', e.target.textContent);
e.target.remove();
}
</script>
</body>
</html>