-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathoptions.js
33 lines (29 loc) · 909 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
31
32
function restoreOptions() {
var trackId = localStorage['trackId'];
if (!trackId)
return;
$('#tracking-id-text').val(trackId);
}
function hideStatus() {
setTimeout(function() {
$('#status').slideUp('slow');
}, 2000);
}
function saveOptions() {
var trackId = $('#tracking-id-text').val();
console.log(trackId);
if (trackId && trackId.length > 0) {
localStorage['trackId'] = trackId;
var successBlock = "<span class='success'>Options Saved</span>";
$('#status').html(successBlock);
$('#status').slideDown('slow', hideStatus());
} else {
var errorBlock = "<span class='error'>UHO, something went wrong</span>";
$('#status').html(errorBlock);
$('#status').slideDown('slow', hideStatus());
}
}
$(document).ready(function(){
$('#saveButton').click(saveOptions);
restoreOptions();
});