Skip to content
Browse files

Update examples/mozillaball/index.html to new API

Substitute old API ( navigator.apps.amInstalled() and navigator.apps.install() ) with new API ( navigator.mozApps.getSelf() and navigator.mozApps.install() ).
  • Loading branch information...
1 parent 0c6856f commit 10e321195c8055e789359856f09f5ffba9b25933 @geraldo geraldo committed Sep 26, 2012
Showing with 19 additions and 17 deletions.
  1. +19 −17 examples/mozillaball/index.html
View
36 examples/mozillaball/index.html
@@ -98,28 +98,30 @@
var gManifestName = "/manifest.webapp";
$(document).ready(function() {
- navigator.apps.amInstalled(function(result) {
- if (!result) {
- $("#install_button").show();
+ var request = navigator.mozApps.getSelf();
+ request.onsuccess = function() {
+ if (request.result) {
+ // we're installed
+ $("#install_button").text("INSTALLED!").show();
+ } else {
+ // not installed
+ $("#install_button").show();
$("#install_button").click(function() {
- navigator.apps.install({
- url: gManifestName,
- onsuccess: function() {
+ var req = navigator.mozApps.install(gManifestName);
+ req.onsuccess = function() {
$("#install_button").text("INSTALLED!").unbind('click');
- },
- onerror: function(errObj) {
+ }
+ req.onerror = function(errObj) {
alert("Couldn't install (" + errObj.code + ") " + errObj.message);
- }
- });
+ }
});
- } else {
- $("#install_button").text("INSTALLED!").show();
-
- }
- });
-
+ }
+ }
+ request.onerror = function() {
+ alert('Error checking installation status: ' + this.error.message);
+ }
});
</script>
-</html>
+</html>

0 comments on commit 10e3211

Please sign in to comment.
Something went wrong with that request. Please try again.