-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
68 lines (64 loc) · 2.17 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//Sends sort message to tab when sortBtn is clicked
document.getElementById("sortBtn").addEventListener("click", function(){
var params = {active: true, currentWindow: true}
chrome.tabs.query(params, gotTabs);
function gotTabs(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {id: "sort"});
}
});
//Detects change to autoSort and stores it
var autoSort = document.getElementById("autoSort");
autoSort.addEventListener("click", function(){
chrome.storage.sync.set({ autoSort: autoSort.checked });
});
chrome.storage.sync.get("autoSort", function(data) {
if(data.autoSort != null){
autoSort.checked = data.autoSort;
}
else {
autoSort.checked = true;
chrome.storage.sync.set({ autoSort: autoSort.checked });
}
});
//Detects change to sortReviews and stores it
var sortReviews = document.getElementById("sortReviews");
sortReviews.addEventListener("click", function(){
chrome.storage.sync.set({ sortReviews: sortReviews.checked });
});
chrome.storage.sync.get("sortReviews", function(data) {
if(data.sortReviews != null){
sortReviews.checked = data.sortReviews;
}
else {
sortReviews.checked = true;
chrome.storage.sync.set({ sortReviews: sortReviews.checked });
}
});
//Detects change to minRating and stores it
var minRating = document.getElementById("minRating");
minRating.addEventListener("change", function(){
chrome.storage.sync.set({ minRating: minRating.value });
});
chrome.storage.sync.get("minRating", function(data) {
if(data.minRating != null){
minRating.value = data.minRating;
}
else {
minRating.value = 0;
chrome.storage.sync.set({ minRating: minRating.value });
}
});
//Detects change to minReviews and stores it
var minReviews = document.getElementById("minReviews");
minReviews.addEventListener("change", function(){
chrome.storage.sync.set({ minReviews: minReviews.value });
});
chrome.storage.sync.get("minReviews", function(data) {
if(data.minReviews != null){
minReviews.value = data.minReviews;
}
else {
minReviews.value = 0;
chrome.storage.sync.set({ minReviews: minReviews.value });
}
});