blob: d44f1bb82481ed62766383d8bb1c490b17ec6779 (
plain) (
blame)
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
|
// get a reference to the install button
var button = document.getElementById('install-btn');
if(navigator.mozApps) {
var manifest_url = location.href + 'manifest.webapp';
function install(ev) {
ev.preventDefault();
// define the manifest URL
// install the app
var installLocFind = navigator.mozApps.install(manifest_url);
installLocFind.onsuccess = function(data) {
// App is installed, do something
};
installLocFind.onerror = function() {
// App wasn't installed, info is in
// installapp.error.name
alert(installLocFind.error.name);
};
};
//call install() on click if the app isn't already installed. If it is, hide the button.
var installCheck = navigator.mozApps.checkInstalled(manifest_url);
installCheck.onsuccess = function() {
if(installCheck.result) {
button.style.display = "none";
} else {
button.addEventListener('click', install, false);
};
};
} else {
button.style.display = "none";
}
|