diff options
Diffstat (limited to 'activePage.ts')
-rw-r--r-- | activePage.ts | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/activePage.ts b/activePage.ts index 736ddca..9b93908 100644 --- a/activePage.ts +++ b/activePage.ts @@ -8,9 +8,40 @@ export class ActivePage { public cur_section = null; private swipe_pos_x = 0; private swipe_pos_y = 0; + private app_record = null; - constructor() { + constructor(appName: string) { // Swipe event handlers + var cur_location = window.location.href; + var last_slash = cur_location.lastIndexOf('/'); + var base_url = cur_location.slice(0, last_slash + 1) + appName + '.webapp'; + this.app_record = null; + + var chk_inst_req = window.navigator.mozApps.checkInstalled(base_url); + chk_inst_req.onsuccess = function(e) { + if (!chk_inst_req.result) { + var install_but_loc = document.getElementById('installButton'); + install_but_loc.innerHTML( + '<button id="installAction">Install App</button>'); + } + document.getElementById('installAction').addEventListener('click', + (evt: TouchEvent) => { + var install_req = window.navigator.mozApps.install(base_url); + install_req.onsuccess = function() { + this.app_record = this.result; + console.log('Installed with success!'); + }; + install_req.onerror = function() { + console.log('I cannot install the app!'); + }; + }, false); + }; + chk_inst_req.onerror = function(e) { + // Most likely we are not on Firefox or something. + console.log('Cannot check whether the app has been installed.'); + }; + + document.body.addEventListener("dblclick", () => { console.log("dblclick"); |