/
index.html
100 lines (89 loc) · 2.44 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
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
<html>
<head>
<title>app1</title>
<script src="https://myapps.mozillalabs.com/jsapi/include.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
.status {
border: 2px solid #000;
background-color: #ddd;
display: inline;
padding: 4px;
}
div {
margin-bottom: 1em;
}
pre {
border: 1px solid #999;
overflow: wrap;
width: 100%;
}
</style>
<script>
$(function () {
function setInstalled() {
var pending = navigator.mozApps.getSelf();
pending.onsuccess = function () {
if (this.result) {
$('#unknown').hide();
$('#uninstalled').hide();
$('#installed').show();
var result = {};
for (var i in this.result) {
result[i] = this.result[i];
try {
JSON.stringify(result[i]);
} catch (e) {
alert('Bad attribute: ' + i + ' typeof: ' + (typeof i));
}
}
try {
$('#record').text(JSON.stringify(result, null, true));
} catch (e) {
$('#record').text('Error serializing record: ' + e);
}
} else {
$('#unknown').hide();
$('#installed').hide();
$('#uninstalled').show();
$('#record').text('');
}
};
pending.onerror = function () {
alert('Error in getSelf: ' + (this.error.name || this.error));
};
}
setInstalled();
$('#install').click(function () {
var pending = navigator.mozApps.install(location.protocol + '//'
+ location.host + '/manifest.webapp');
pending.onsuccess = function () {
setInstalled();
};
pending.onerror = function () {
if (this.error == 'DENIED' || this.error.name == 'DENIED') {
return;
}
alert('Error in install: ' + (this.error.name || this.error));
};
});
});
</script>
</head>
<body>
<div>
Welcome to <code>app1</code>
</div>
<div>The manifest is located at <a
href="http://app1.ianbicking.org/manifest.webapp">http://app1.ianbicking.org/manifest.webapp</a>
</div>
<div>Installation status is:
<div id="unknown" class="status">Unknown</div>
<div id="installed" class="status" style="display: none">Installed</div>
<div id="uninstalled" class="status" style="display: none">Uninstalled</div>
</div>
<div>To install or reinstall:
<button type="button" id="install">Install</button>
</div>
<pre id="record"></pre>
</body>