-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.js
56 lines (50 loc) · 1.49 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Saves options to localStorage.
function save_options() {
localStorage["local_server_id"] = $("#localserverid").val();
localStorage["remote_server_id"] = $("#remoteserverid").val();
localStorage["path_id"] = $("#pathid").val();
localStorage["width_id"] = $("#widthid").val();
localStorage["height_id"] = $("#heightid").val();
// Checks the Local URL radio on the context menu
chrome.contextMenus.update("radioRemote", {
checked: false
});
chrome.contextMenus.update("radioLocal", {
checked: true
});
localStorage["active_server_id"] = localStorage["local_server_id"];
// Update status to let user know options were saved.
$("#status").html("Options Saved.");
setTimeout(function() {
$("#status").html("");
}, 2000);
}
// Restores select box state to saved value from localStorage.
function restore_options() {
var local_server_id = localStorage["local_server_id"];
var remote_server_id = localStorage["remote_server_id"];
var path_id = localStorage["path_id"];
var width_id = localStorage["width_id"];
var height_id = localStorage["height_id"];
if(local_server_id){
$("#localserverid").val(local_server_id);
}
if (remote_server_id) {
$("#remoteserverid").val(remote_server_id);
}
if(path_id){
$("#pathid").val(path_id);
}
if(width_id){
$("#widthid").val(width_id);
}
if(height_id){
$("#heightid").val(height_id);
}
}
$(document).ready(function(){
restore_options();
$("#saveButton").click(function(){
save_options();
});
});