-
Notifications
You must be signed in to change notification settings - Fork 57
/
options.js
29 lines (24 loc) · 1.12 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
// Saves options to localStorage.
function saveOptions(event) {
event.preventDefault();
localStorage["hostname"] = document.getElementById("hostname").value;
localStorage["play-position"] = document.getElementById("play-position-current").checked ? "current" : "0";
chrome.extension.getBackgroundPage().window.location.reload();
// Show status to let user know options were saved.
var status = document.getElementById("status");
status.className = "alert alert-dismissible alert-success fade in"
setTimeout(function() {
status.className = "invisible";
}, 2000);
}
// Restores select box state to saved value from localStorage.
function restoreOptions() {
document.getElementById("hostname").value = localStorage["hostname"] || "apple-tv.local";
var play_position_inputs = {
"current": document.getElementById("play-position-current"),
"0": document.getElementById("play-position-0")
};
play_position_inputs[localStorage["play-position"] || "current"].checked = true;
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.querySelector('#save').addEventListener('click', saveOptions);