-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
34 lines (26 loc) · 1.34 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
function save_options() {
var tomatotime = document.getElementById('tomatotime').value;
var tomatobreak = document.getElementById('tomatobreak').value;
var tomatobreaklong = document.getElementById('tomatobreaklong').value;
var tomatoblock = document.getElementById('tomatoblock').value;
localStorage.setItem("lapSize", tomatotime);
localStorage.setItem("shortBreak", tomatobreak);
localStorage.setItem("longBreak", tomatobreaklong);
localStorage.setItem("blockedUrls", tomatoblock);
var status = document.getElementById('status');
status.textContent = 'Settings saved!';
var port = chrome.extension.connect({name: "tomatoOptionsCommunication"});
port.postMessage("tomato-data-update");
var finished = setTimeout(function() {
status.textContent = '';
}, 2750);
}
function restore_options() {
document.getElementById('tomatotime').value = localStorage.getItem("lapSize") || 25;
document.getElementById('tomatobreak').value = localStorage.getItem("shortBreak") || 5;
document.getElementById('tomatobreaklong').value = localStorage.getItem("longBreak") || 15;
document.getElementById('tomatoblock').value = localStorage.getItem("blockedUrls") || "facebook.com,twitter.com";
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('tomatosave').addEventListener('click',
save_options);