forked from ccampbell/xtab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
46 lines (40 loc) · 992 Bytes
/
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
/* global $, Aftershave */
function _handleChange() {
var input = $('#input-max');
if (this.value === 'other') {
input.show();
input.trigger('focus');
return;
}
localStorage.max = this.value;
input.hide();
}
function _saveMax() {
var input = $('#input-max');
localStorage.max = input.val();
}
function _saveAlgo() {
localStorage.algo = this.value;
}
function _run() {
var options = {
10: 10,
15: 15,
20: 20,
25: 25,
30: 30,
35: 35,
40: 40,
45: 45,
50: 50
};
var algo = localStorage.algo || 'used';
var max = parseInt(localStorage.max || 20);
$('body').html(Aftershave.render('popup', {options: options, algo: algo, max: max}));
}
$.ready(function() {
$(document).on('change', 'select', _handleChange);
$(document).on('change', '#input-max', _saveMax);
$(document).on('change', 'input[type=radio]', _saveAlgo);
_run();
});