From e1af5e214c389aea2b55daf82bdec92472db3f19 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 9 Feb 2019 00:00:53 +0800 Subject: Moving shitty stuff sitting around in the www folder here. --- xp/vco/scripts/install.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 xp/vco/scripts/install.js (limited to 'xp/vco/scripts/install.js') 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"; +} -- cgit v1.2.3