Try to install application.
[cascardo/pomo.git] / install.js
1 function status_update(stat_str) {
2         var stat_el = document.getElementById("status");
3         stat_el.innerHTML = stat_str;
4 }
5
6 function install() {
7         status_update("Installing");
8         var app = navigator.mozApps.install("http://pomo.cascardo.info/pomo.webapp");
9         app.onsuccess = function() {
10                 status_update("Application installed now");
11         }
12         app.onerror = function() {
13                 status_update("Error installing app: " + app.error.name);
14         }
15 }
16
17 function check_install() {
18         var app = navigator.mozApps.getSelf();
19         app.onsuccess = function() {
20                 if (app.result) {
21                         status_update("Installed");
22                 } else {
23                         status_update("Not Installed");
24                         install();
25                 }
26         };
27         app.onerror = function() {
28                 var stat = document.getElementById("status");
29                 status_update("Installing app not supported");
30                 status_update("Skipping installation");
31         };
32 }
33 check_install();