-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
72 lines (52 loc) · 1.68 KB
/
Copy pathpopup.js
File metadata and controls
72 lines (52 loc) · 1.68 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
function refresh_local_storage(){
chrome.storage.local.get('tics', function (result) {
var tags = ''
if(result.tics != undefined){
jQuery.each(result.tics,function(index, value){
tags += "<a class='remove-tag-click' href='#' data-keyword='"+value+"' title='Remove "+value+"'>"+value+"</a>"
if(index != result.tics.length -1){
tags += " "
}
})
jQuery("#tic-tag-cloud").html(tags)
jQuery(".remove-tag-click").click(function(){
remove_keyword(jQuery(this).data('keyword'))
jQuery(this).remove()
});
}
});
}
$(document).ready(function() {
refresh_local_storage()
});
jQuery("#add_keyword_button").click(function(){
if(jQuery("#add_keyword_text").val().length >0 ){
add_keyword(jQuery("#add_keyword_text").val() );
jQuery("#add_keyword_text").val("")
jQuery("#error").html("")
}else{
jQuery("#error").html("Please enter a keyword")
}
})
function remove_keyword(keyword){
chrome.tabs.query({active:true,currentWindow:true},function(tabs){
//tabs is an array even if there is only one result
var message = {};
message.type = "removeKeyword";
message.keyword = keyword;
chrome.tabs.sendMessage(tabs[0].id, message, function(response){
refresh_local_storage()
});
})
}
function add_keyword(keyword){
chrome.tabs.query({active:true,currentWindow:true},function(tabs){
//tabs is an array even if there is only one result
var message = {};
message.type = "addKeyword";
message.keyword = keyword;
chrome.tabs.sendMessage(tabs[0].id,message, function(response){
refresh_local_storage()
});
})
}