-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.js
50 lines (40 loc) · 1.59 KB
/
save.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
$(function(){
chrome.storage.local.get("max",function(value){
var i=0;
var key="a"+0;
while(i<value.max && value.max!=undefined)
{ key="a"+i;
chrome.storage.local.get(key,function(params) {
if(Object.values(params)!="")
{ $("ul").append('<li class="collection-item" id="'+Object.keys(params)+'">'+Object.values(params)+'<i class="piwrap"></i></li>');
$("#"+Object.keys(params)).bind("click",function(){
chrome.storage.local.remove($(this).attr("id"));
this.parentNode.removeChild(this); });
} });
i++; }
});
$("#btnn").bind("click",function(){
if($("#manual").val()!="")
{
chrome.storage.local.get('max',function(value){
var key="a"+0;
if(value.max==undefined){
chrome.storage.local.set({ ["a"+0]: $("#manual").val() });
chrome.storage.local.set({ 'max': 1 });
}
else{
key="a"+value.max;
chrome.storage.local.set({ ["a"+value.max]: $("#manual").val() });
chrome.storage.local.set({ 'max': value.max+1 });
}
$("ul").append('<li class="collection-item" id="'+key+'">'+$("#manual").val()+'<i class="piwrap"></i></li>');
$("#"+key).bind("click",function(){
chrome.storage.local.remove($(this).attr("id"));
this.parentNode.removeChild(this); });
$("#manual").val("");
});
}
else
alert("Eror: Manual input cannot be empty!");
});
});