forked from jnoelg/Pebble-MySimpleWatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurable.html
91 lines (75 loc) · 3.08 KB
/
configurable.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
<!DOCTYPE html>
<html>
<head>
<title>MySimpleWatch Configurable</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="b">
<div data-role="header">
<h1 class="ui-title" role="heading">Settings</h1>
</div>
<div data-role="main" class="ui-content">
<div class="ui-field-contain">
<label for="hh-in-bold">Display hours in bold</label>
<select name="hh-in-bold" id="hh-in-bold" data-role="slider">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</div>
<div class="ui-field-contain">
<label for="mm-in-bold">Display minutes in bold</label>
<select name="mm-in-bold" id="mm-in-bold" data-role="slider">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</div>
<div class="ui-grid-a">
<div class="ui-block-a"><input id="b-cancel" type="reset" data-theme="b" data-icon="delete" value="Cancel"></div>
<div class="ui-block-b"><input id="b-apply" type="submit" data-theme="a" data-icon="check" value="Apply"></div>
</div>
</div>
</div>
<script>
function getOptions() {
var options = {}
//Add all textual values
$('textarea, select, [type="hidden"], [type="password"], [type="text"]').each(function(){options[$(this).attr('id')] = $(this).val();})
//Add all checkbox type values
$('[type="radio"], [type="checkbox"]').each(function(){options[$(this).attr('id')] = $(this).is(':checked');})
return options;
}
function setOptions(optionsJSON) {
// validate that optionsJSON is not null
if (optionsJSON) {
// deserialize optionsJSON
var options = jQuery.parseJSON(decodeURIComponent(optionsJSON));
for(key in options) {
$("#"+[key]).val(options[key]);
$("#"+[key]).val(options[key]).slider("refresh");
}
}
}
$().ready(function() {
$("#b-cancel").click(function() {
console.log("Cancel");
var location = "pebblejs://close";
console.log(location);
document.location = location;
});
$("#b-apply").click(function() {
console.log("Apply");
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(getOptions()));
console.log(location);
document.location = location;
});
//Set form values to whatever is passed in.
setOptions(window.location.search.substring(1));
});
</script>
</body>
</html>