-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup.js
50 lines (43 loc) · 1.4 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
let ctaStatus = document.getElementById('ctaStatus');
const ctaClearList = document.getElementById('ctaClearList');
const formularioUsuarios = document.getElementById('formularioUsuarios');
const listUsuariosRender = document.getElementById('containerList');
formularioUsuarios.onsubmit = function(element) {
const name = formularioUsuarios[0].value;
const color = formularioUsuarios[1].value;
chrome.storage.local.get(null,function (list){
console.log(list);
if(list.users){
list.users.push({username:`${name}`, color:`${color}`})
}else {
list.users = [];
list.users.push({username:`${name}`, color:`${color}`});
}
chrome.storage.local.set(list,function (){
console.log(`Storage Succesful ${list}`);
});
});
element.preventDefault()
};
ctaStatus.onclick = function(element) {
chrome.storage.local.get(null,function (obj){
console.log(obj);
});
element.preventDefault()
};
ctaClearList.onclick = function(element) {
chrome.storage.local.clear(function(elements){
console.log(`Se eliminaron ${element}`)
})
element.preventDefault()
};
chrome.storage.local.get(null,function (list){
let listItem;
for (user of list.users){
console.log(user)
listItem = document.createElement('li');
listItem.style.backgroundColor =user.color;
listItem.innerHTML = `${user.username}`;
listUsuariosRender.appendChild(listItem);
}
})