-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
35 lines (30 loc) · 927 Bytes
/
popup.js
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
class NetFlexPopup {
constructor() {
this.markup = new NetFlexMarkup;
this.storage = new NetFlexStorage;
this.messenger = new NetFlexMessage;
}
init() {
this.showLists();
this.messenger.send('reset');
this.markup.onclick('.netflex-toggle', el => {
this.markup.toggleClass(el, 'active');
this.messenger.send(el.getAttribute('data-message'));
});
}
showLists() {
let lists = this.markup.first('#netflex-lists');
lists.innerHTML = '';
this.storage.getAllKeys(user => {
let list = document.createElement('ol');
this.storage.readEach(user, item => {
let node = document.createElement('li');
node.appendChild(document.createTextNode(item));
list.appendChild(node);
});
lists.appendChild(document.createTextNode(user));
lists.appendChild(list);
});
}
}
window.onload = () => new NetFlexPopup().init();