forked from bmalnad/btcjamhelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
87 lines (79 loc) · 3.11 KB
/
options.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Saves options to chrome.storage
function saveOptions() {
var exchange = $('#exchange').val();
var watchinterval = $('#watchinterval').val();
// var removewarnings = $('#removewarnings').is(':checked') ? true : false;
var fixrateuserscreen = $('#fixrateuserscreen').is(':checked') ? true : false;
var fixpaymentscreen = $('#fixpaymentscreen').is(':checked') ? true : false;
var notifynewlisting = $('#notifynewlisting').is(':checked') ? true : false;
var fixfollowersscreen = $('#fixfollowersscreen').is(':checked') ? true : false;
//stopaskingformoney
var stopaskingformoney = $('#stopaskingformoney').is(':checked') ? true : false;
chrome.storage.local.set({
exchange: exchange,
watchinterval: watchinterval,
fixrateuserscreen: fixrateuserscreen,
fixpaymentscreen: fixpaymentscreen,
notifynewlisting: notifynewlisting,
fixfollowersscreen: fixfollowersscreen,
stopaskingformoney: stopaskingformoney
}, function() {
// Update status to let user know options were saved.
$('#status').text('Options saved.');
$('#status').css('display','block');
chrome.runtime.sendMessage({
from: 'options',
subject: 'updateWatchInterval'
});
setTimeout(function() {
$('#status').text('');
$('#status').css('display','none');
}, 2000);
});
}
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function loadOptions() {
chrome.storage.local.get({
exchange: 'coindesk',
watchinterval: '15',
removewarnings: true,
fixrateuserscreen: true,
fixpaymentscreen: true,
notifynewlisting: true,
fixfollowersscreen: true,
stopaskingformoney: false
}, function(options) {
$('#exchange').val(options.exchange);
$('#watchinterval').val(options.watchinterval);
$('#fixrateuserscreen').prop('checked',options.fixrateuserscreen);
$('#fixpaymentscreen').prop('checked',options.fixpaymentscreen);
$('#notifynewlisting').prop('checked',options.notifynewlisting);
$('#fixfollowersscreen').prop('checked',options.fixfollowersscreen);
$('#stopaskingformoney').prop('checked',options.stopaskingformoney);
});
}
document.addEventListener('DOMContentLoaded', loadOptions);
document.getElementById('save').addEventListener('click', saveOptions);
// /* Once the DOM is ready... */
// window.addEventListener('DOMContentLoaded', function() {
// /* ...query for the active tab... */
// chrome.tabs.query({
// active: true,
// currentWindow: true
// }, function(tabs) {
// /* ...and send a request for the DOM info... */
// chrome.tabs.sendMessage(
// tabs[0].id,
// {from: 'popup', subject: 'DOMInfo'},
// /* ...also specifying a callback to be called
// * from the receiving end (content script) */
// console.log('message sent from popup!'));
// });
// });
$(document).ready(function(){
$('body').on('click', 'a.donate', function(){
chrome.tabs.create({url: $(this).attr('href')});
return false;
});
});