-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
56 lines (44 loc) · 1.7 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
$(document).ready(function(){
$.ajax({
type : "GET",
url : "https://www.pivotaltracker.com/services/v5/me",
success : function ( data, status, xhr ) {
$("#user-name strong").text(data.username);
},
error : function ( xhr, status, error ) {
alert ("Get User Error.\n" + "Status: " + status + "\nError: " + error );
}
});
getOptions();
$("#outputActivityChecked").change( function () {
saveOptions( $("#outputActivityChecked").is(':checked'), $("input[name='format']:checked").attr('id') );
});
$("input[name='format']").change( function () {
saveOptions( $("#outputActivityChecked").is(':checked'), $("input[name='format']:checked").attr('id') );
});
});
saveOptions = function (outputActivity, format){
chrome.storage.sync.set ({
outputActivity: outputActivity,
format: format
});
//Store the options locally too
localStorage["outputActivityChecked"] = outputActivity;
localStorage["format"] = format;
// Send an update to the page
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {outputActivityChecked: outputActivity, format: format });
});
};
getOptions = function (outputActivity, format){
chrome.storage.sync.get ({
outputActivity: true,
format : "fullDocument"
}, function( options ){
$("#outputActivityChecked").attr('checked', options.outputActivity);
$("input#" + options.format ).prop('checked', true);
//Store the options locally too
localStorage["outputActivityChecked"] = options.outputActivity;
localStorage["format"] = options.format;
} );
};