Try to install application.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Thu, 31 Jan 2013 01:07:57 +0000 (23:07 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Thu, 31 Jan 2013 01:07:57 +0000 (23:07 -0200)
Tries to install the application from its manifest, using a blank icon
and updating a status div.

images/pomo-128.png [new file with mode: 0644]
index.html
install.js [new file with mode: 0644]
pomo.webapp [new file with mode: 0644]

diff --git a/images/pomo-128.png b/images/pomo-128.png
new file mode 100644 (file)
index 0000000..a5f1cf6
Binary files /dev/null and b/images/pomo-128.png differ
index 0071d85..dba067d 100644 (file)
@@ -1,7 +1,10 @@
 <html>
 <head>
 <title>Pomo</title>
 <html>
 <head>
 <title>Pomo</title>
+<script src="/install.js"></script>
 </head>
 <body>
 </head>
 <body>
+<div id="status">
+</div>
 </body>
 </html>
 </body>
 </html>
diff --git a/install.js b/install.js
new file mode 100644 (file)
index 0000000..0cdde11
--- /dev/null
@@ -0,0 +1,33 @@
+function status_update(stat_str) {
+       var stat_el = document.getElementById("status");
+       stat_el.innerHTML = stat_str;
+}
+
+function install() {
+       status_update("Installing");
+       var app = navigator.mozApps.install("http://pomo.cascardo.info/pomo.webapp");
+       app.onsuccess = function() {
+               status_update("Application installed now");
+       }
+       app.onerror = function() {
+               status_update("Error installing app: " + app.error.name);
+       }
+}
+
+function check_install() {
+       var app = navigator.mozApps.getSelf();
+       app.onsuccess = function() {
+               if (app.result) {
+                       status_update("Installed");
+               } else {
+                       status_update("Not Installed");
+                       install();
+               }
+       };
+       app.onerror = function() {
+               var stat = document.getElementById("status");
+               status_update("Installing app not supported");
+               status_update("Skipping installation");
+       };
+}
+check_install();
diff --git a/pomo.webapp b/pomo.webapp
new file mode 100644 (file)
index 0000000..197a4ae
--- /dev/null
@@ -0,0 +1,14 @@
+{
+       "name": "Pomo",
+       "description": "Pomodoro",
+       "launch_path": "/",
+       "icons": {
+               "128": "/images/pomo-128.png"
+       },
+       "developer": {
+               "name": "Thadeu Lima de Souza Cascardo",
+               "url": "http://cascardo.info/"
+       },
+       "default_locale": "en",
+       "appcache_path": "/index.manifest"
+}