-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
30 lines (24 loc) · 856 Bytes
/
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
function saveOptions() {
var fontName = document.getElementById("font_name").value;
if (!fontName) {
message('Error: No font name specified');
return;
}
chrome.storage.sync.set({'font_name': fontName}, function() {
// Notify that we saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() { status.innerHTML = ""; }, 750);
});
}
var defFontName = "PT Mono";//"Consolas";
function loadOptions() {
chrome.storage.sync.get('font_name', function(val) {
var fontName = val['font_name'];
if (typeof fontName === "undefined")
fontName = defFontName;
document.getElementById("font_name").value = fontName;
});
}
document.addEventListener('DOMContentLoaded', loadOptions);
document.querySelector('#save').addEventListener('click', saveOptions);