diff options
| author | Teddy Wing | 2013-03-25 02:09:58 -0400 |
|---|---|---|
| committer | Teddy Wing | 2013-03-25 02:09:58 -0400 |
| commit | 46c32a0728414a82560e3a521be61207fe6a727e (patch) | |
| tree | 3ced2397190c80480f6e7802ee2e48a951066669 /options.js | |
| parent | 7aa3121d48aa3399518e9a82d981edaee3a8d7ba (diff) | |
| download | ScrumDo-Trellic-46c32a0728414a82560e3a521be61207fe6a727e.tar.bz2 | |
Add options page
A minimal, unstyled options page for the extension is now accessible
via the Chrome Extensions panel. This options page allows users to
customise the refresh interval of the ScrumDo board page.
Diffstat (limited to 'options.js')
| -rw-r--r-- | options.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/options.js b/options.js new file mode 100644 index 0000000..f3c3f4a --- /dev/null +++ b/options.js @@ -0,0 +1,25 @@ +// Saves options to localStorage. +function save_options() { + var refresh_interval_el = document.getElementById("refresh-interval"); + var refresh_interval = refresh_interval_el.value; + localStorage["refresh_interval"] = refresh_interval; + + // Update status to let user know options were saved. + var status = document.getElementById("status"); + status.innerHTML = "Options Saved."; + setTimeout(function() { + status.innerHTML = ""; + }, 750); +} + +// Restores select box state to saved value from localStorage. +function restore_options() { + var refresh_interval = localStorage["refresh_interval"]; + if (!refresh_interval) { + return; + } + var refresh_interval_el = document.getElementById("refresh-interval"); + refresh_interval_el.value = refresh_interval; +} +document.addEventListener('DOMContentLoaded', restore_options); +document.querySelector('#save').addEventListener('click', save_options); |
