-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainWindow.html
60 lines (49 loc) · 1.54 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<title>To do List</title>
</head>
<body>
<!-- Navbar goes here -->
<nav>
<div class="nav-wrapper teal titlee">
<a class="brand-logo center">To do List</a>
</div>
</nav>
<div class="container" id="list">
</div>
<script>
const electron = require('electron');
const {
ipcRenderer
} = electron;
const ul = document.querySelector('#list');
// Add item
ipcRenderer.on('item:add', function (e, item) {
if (item.length != 0 && item.trim().length != 0) {
ul.className = 'collection';
const li = document.createElement('a');
li.className = 'collection-item ';
const itemText = document.createTextNode(item);
li.appendChild(itemText);
ul.appendChild(li);
}
});
//Clear items
ipcRenderer.on('item:clear', function () {
ul.innerHTML = '';
ul.className = '';
});
//Remove item
ul.addEventListener('dblclick', removeItem);
function removeItem(e) {
e.target.remove();
if (ul.children.length == 0) {
ul.className = '';
}
}
</script>
</body>
</html>