This repository has been archived by the owner on Jan 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure.html
executable file
·92 lines (81 loc) · 2.91 KB
/
configure.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
<!DOCTYPE html>
<html>
<head>
<title>Configure Barely</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.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>
<div data-role="page" id="main">
<div data-role="header" class="jqm-header">
<h1>Configure Barely</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="KEY_INVERTED">Invert (White on Black)</label>
<select name="KEY_INVERTED" id="KEY_INVERTED" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</div>
<div data-role="fieldcontain">
<label for="KEY_BLUETOOTH">Show my Bluetooth Connectivity</label>
<select name="KEY_BLUETOOTH" id="KEY_BLUETOOTH" data-role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
</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="b-cancel">Cancel</button></div>
<div class="ui-block-b"><button type="submit" data-theme="a" id="b-submit">Submit</button></div>
</fieldset>
</div>
</div>
</div>
</div>
<script>
function saveOptions() {
var options = {
'KEY_INVERTED': $("#KEY_INVERTED").val(),
'KEY_BLUETOOTH': $("#KEY_BLUETOOTH").val()
}
return options;
}
function getUrlOptions() {
var params = {};
var bits = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/g, function (match, key, value) {
params[key] = value;
});
return params;
}
function setUrlOptions() {
var params = getUrlOptions();
for (key in params) {
var field = $("#"+key);
if (field !== null) {
var value = decodeURIComponent(params[key]);
field.val(value).slider("refresh");
}
}
}
$().ready(function() {
setUrlOptions();
$("#b-cancel").click(function() {
console.log("Cancel");
document.location = "pebblejs://close";
});
$("#b-submit").click(function() {
console.log("Submit");
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(saveOptions()));
console.log("Warping to: " + location);
console.log(location);
document.location = location;
});
});
</script>
</body>
</html>