Permalink
Browse files

Merge pull request #171 from geraldo/patch-1

Update examples/mozillaball/index.html to new API
  • Loading branch information...
2 parents 0c6856f + 10e3211 commit f0d965479e18e3d62ee8a2cbb85cf5f5ca310453 @ianb ianb committed Sep 26, 2012
Showing with 19 additions and 17 deletions.
  1. +19 −17 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 f0d9654

Please sign in to comment.