-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (53 loc) · 1.9 KB
/
index.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
<html manifest="index.appcache">
<head>
<title>Pebble Watchface customizer</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h3 style='padding-bottom:10px'>Choose your options!</h3>
<p>
<button type='button'class="option btn btn-default" id="test">test</button>
</p>
<p>
<button type='button' class="submit btn btn-success">Submit</button>
</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$().ready(function() {
//Reload the page when we get notified appcache has changed.
window.applicationCache.addEventListener('updateready', onUpdateReady);
function onUpdateReady() {
if(window.applicationCache.status === window.applicationCache.UPDATEREADY) {
window.location.reload();
}
}
//See if the options have been stored in localStorage
var dictionary;
try {
//localStorage only offers key/string lookup
dictionary = JSON.parse(localStorage["dictionary"]);
}
catch(e) {
dictionary = {'test':0};
}
for (option in dictionary) {
if(dictionary[option])
$("#" + option).addClass("btn-primary");
};
$(".option").click(function(){
var new_val = dictionary[$(this).attr("id")] + 1;
dictionary[$(this).attr("id")] = new_val % 2;
localStorage["dictionary"] = JSON.stringify(dictionary);
$(this).toggleClass("btn-primary");
});
//Open pebble specific link to pass perameters
$('.submit').click(function() {
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(dictionary));
window.location.href = location;
});
});
</script>
</body>
</html>