aboutsummaryrefslogtreecommitdiff
path: root/xp/vco/scripts/install.js
diff options
context:
space:
mode:
Diffstat (limited to 'xp/vco/scripts/install.js')
-rw-r--r--xp/vco/scripts/install.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/xp/vco/scripts/install.js b/xp/vco/scripts/install.js
new file mode 100644
index 0000000..d44f1bb
--- /dev/null
+++ b/xp/vco/scripts/install.js
@@ -0,0 +1,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";
+}