/
settings.html
157 lines (152 loc) · 5.71 KB
/
settings.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<!-- @@@:TODO Hand create the Object to JSONify before sending to ensure booleans are sent as booleans -->
<!-- Alternatively try only sending the changed fields -->
<html lang="en-US">
<head>
<title>CST Big Time Settings</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
</head>
<body>
<!-- Header -->
<h1>CST Big Time Settings</h1>
<!-- Settings Table -->
<table>
<tr>
<th colspan="2">Option Toggles:</th>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="zero_prefix" style="width:100px; margin-left:20px;"> <label for="zero_prefix">Zero Prefix Hour Value?</label></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="vibe_hour" style="width:100px; margin-left:20px;"> <label for="vibe_hour">Vibrate on the Hour?</label></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="show_power" style="width:100px; margin-left:20px;"> <label for="show_power">Show Power Level Indicator?</label></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="show_btooth" style="width:100px; margin-left:20px;"> <label for="show_btooth">Show Bluetooth Indicator?</label></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" id="vibe_btooth" style="width:100px; margin-left:20px;"> <label for="vibe_btooth">Vibrate on Bluetooth Connect/Disconnect?</label></td>
</tr>
<tr>
<td><label for="month_first">Date Format</label></td>
<td>
<select id="month_first">
<option value="true">MM/DD</option>
<option value="false">DD/MM</option>
</select>
</td>
</tr>
<tr>
<th colspan="2">Weekday Abbreviations:</th>
</tr>
<tr>
<td><label for="sun_text">Sunday</label></td>
<td><input type="text" id="sun_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="mon_text">Monday</label>
</td><td><input type="text" id="mon_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="tue_text">Tuesday</label></td>
<td><input type="text" id="tue_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="wed_text">Wednesday</label></td>
<td><input type="text" id="wed_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="thu_text">Thursday</label></td>
<td><input type="text" id="thu_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="fri_text">Friday</label></td>
<td><input type="text" id="fri_text" maxlength="3" /></td>
</tr>
<tr>
<td><label for="sat_text">Saturday</label></td>
<td><input type="text" id="sat_text" maxlength="3" /></td>
</tr>
</table>
<p style="text-align:center;"><button type="button" class="submit btn btn-success" style="width:100px;margin-top:20px;">Submit</button>
<!-- Footer -->
<br />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
window.applicationCache.addEventListener("updateready",onUpdateReady);
function onUpdateReady () {
if(window.applicationCache.status === window.applicationCache.UPDATEREADY) {
window.location.reload();
}
} //onUpdateReady
var dictionary;
try {
dictionary = JSON.parse(localStorage["dictionary"]);
if(!dictionary.hasOwnProperty("month_first")) {
dictionary["month_first"] = true;
dictionary["sun_text"] = "Su";
dictionary["mon_text"] = "Mo";
dictionary["tue_text"] = "Tu";
dictionary["wed_text"] = "We";
dictionary["thu_text"] = "Th";
dictionary["fri_text"] = "Fr";
dictionary["sat_text"] = "Sa";
}
if(!dictionary.hasOwnProperty("vibe_hour")) {
dictionary["vibe_hour"] = true;
dictionary["vibe_btooth"] = false;
}
} catch(x) {
dictionary = {
zero_prefix: false,
show_power: true,
show_btooth: true,
month_first: true,
sun_text: "Su",
mon_text: "Mo",
tue_text: "Tu",
wed_text: "We",
thu_text: "Th",
fri_text: "Fr",
sat_text: "Sa",
vibe_hour: true,
vibe_btooth: false
};
}
for(option in dictionary) {
if(dictionary[option]) {
/* Option */
switch(option) {
case "zero_prefix":
case "show_power":
case "show_btooth":
case "vibe_hour":
case "vibe_btooth":
$('#' + option).prop("checked",dictionary[option]);
break;
default:
$('#' + option).val(dictionary[option]);
break;
}
}
}
$(":checkbox").on("change",function() {
dictionary[$(this).attr("id")] = this.checked;
localStorage["dictionary"] = JSON.stringify(dictionary);
});
$(":text,select").on("change",function() {
dictionary[$(this).attr("id")] = $(this).val();
localStorage["dictionary"] = JSON.stringify(dictionary);
});
$(".submit").click(function() {
console.log(JSON.stringify(dictionary));
window.location.href = "pebblejs://close#" + encodeURIComponent(JSON.stringify(dictionary));
});
});
</script>
</body>
</html>