-
Notifications
You must be signed in to change notification settings - Fork 0
/
audlast.html
119 lines (108 loc) · 4.46 KB
/
audlast.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title>Audible Last Pebble Configuration</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body onload="loadLocalStorage()">
<h1>Audible Last Pebble Configuration</h1>
<div>
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="radio" name="country" id="country-couk" value=".co.uk"/>
<label for="country-couk">.co.uk</label>
<input type="radio" name="country" id="country-de" value=".de" checked/>
<label for="country-de"> .de </label>
<input type="radio" name="country" id="country-com" value=".com"/>
<label for="country-com">.com</label>
<input type="radio" name="country" id="country-fr" value=".fr"/>
<label for="country-fr"> .fr </label>
</fieldset>
</div>
<p>Search for:
<input type="text" id="searchvalue" size="45" maxlength="64">
</p>
<div>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Pages:</legend>
<input type="radio" name="pages" id="pages1" value="1" checked/>
<label for="pages1"> 1 </label>
<input type="radio" name="pages" id="pages2" value="2"/>
<label for="pages2"> 2 </label>
<input type="radio" name="pages" id="pages3" value="3"/>
<label for="pages3"> 3 </label>
<input type="radio" name="pages" id="pages4" value="4"/>
<label for="pages4"> 4 </label>
<input type="radio" name="pages" id="pages5" value="5"/>
<label for="pages5"> 5 </label>
</fieldset>
</div>
<div class="ui-body ui-body-b">
<fieldset class="ui-grid-a">
<div class="ui-block-a"><button type="submit" data-theme="d" id="cncl_button">Cancel</button></div>
<div class="ui-block-b"><button type="submit" data-theme="a" id="save_button">Submit</button></div>
</fieldset>
</div>
<script>
function loadLocalStorage() {
var countryValue = localStorage.getItem("AudLast#countryValue");
if (countryValue !== null) {
$("input[value=\""+countryValue+"\"]").click();
$("input[name='country']").checkboxradio("refresh");
}
var searchvalue = document.getElementById("searchvalue");
searchvalue.value = localStorage.getItem("AudLast#searchValue");
var pagesValue = localStorage.getItem("AudLast#pagesValue");
if (pagesValue !== null) {
$("input[value=\""+pagesValue+"\"]").click();
$("input[name='pages']").checkboxradio("refresh");
}
}
function getQueryParam(variable, defaultValue) {
var query = location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] === variable) {
return decodeURIComponent(pair[1]);
}
}
return defaultValue || false;
}
function saveOptions() {
var countryValue = $("input[name='country']:checked").val();
var searchvalue = document.getElementById("searchvalue");
var searchpagesValue = $("input[name='pages']:checked").val();
var options = {
"country": countryValue,
"search": searchvalue.value,
"pages": searchpagesValue
}
localStorage.setItem("AudLast#options_all", options);
localStorage.setItem("AudLast#countryValue", countryValue);
localStorage.setItem("AudLast#searchValue", searchvalue.value);
localStorage.setItem("AudLast#pagesValue", searchpagesValue);
return options;
};
var submitButton = document.getElementById("save_button");
submitButton.addEventListener("click",
function() {
console.log("Submit");
var return_to = getQueryParam('return_to', 'pebblejs://close#');
var options = saveOptions();
var location = return_to + encodeURIComponent(JSON.stringify(options));
document.location = location;
},
false);
var cancelButton = document.getElementById("cncl_button");
cancelButton.addEventListener("click",
function() {
console.log("Cancel");
var location = getQueryParam('return_to', 'pebblejs://close#');
document.location = location;
},
false);
</script>
</body>
</html>