X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fpomo.git;a=blobdiff_plain;f=install.js;fp=install.js;h=0cdde11074ee81801d6c60ca6e45fc0e21392136;hp=0000000000000000000000000000000000000000;hb=aeccb1324dad2e0ee3429a699d9d68f44ef950fc;hpb=fd49456477a527d3e251b0f69ae463142fa65b5e diff --git a/install.js b/install.js new file mode 100644 index 0000000..0cdde11 --- /dev/null +++ b/install.js @@ -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();