diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-08-22 23:15:49 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-08-22 23:15:49 +0200 |
commit | 337106cfc37d5d3662b66893fd086f6341f9eec0 (patch) | |
tree | 86e0ee19fa2cb185cc3285c536d947deb704e262 | |
parent | a9ad02b3ff96f020fe7a90e2fc7b1aef15726a63 (diff) | |
download | zalmy-337106cfc37d5d3662b66893fd086f6341f9eec0.tar.gz |
Get rid of all remaining parts of TypeScript
-rw-r--r-- | activePage.es | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/activePage.es b/activePage.es index 20ddcd1..74980e2 100644 --- a/activePage.es +++ b/activePage.es @@ -2,7 +2,7 @@ var cur_section = Symbol(); export class ActivePage { - constructor(appName: string) { + constructor(appName) { // The idea behind this property that it could basically anything, but // whoever inherits this class must override next(), prev(), and display() methods, // if necessary; just in the end, its value probably corresponds to the IDs of the @@ -18,29 +18,31 @@ export class ActivePage { 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.'); - }; + if (!!window.navigator.mozApps) { + 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) => { + 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", @@ -50,7 +52,7 @@ export class ActivePage { }, false); document.body.addEventListener("mousedown", - (evt: MouseEvent) => { + (evt) => { this.swipe_pos_x = evt.screenX; this.swipe_pos_y = evt.screenY; console.log("mousedown; pos = " + this.swipe_pos_x + @@ -58,7 +60,7 @@ export class ActivePage { }, false); document.body.addEventListener("mouseup", - (evt: MouseEvent) => { + (evt) => { console.log("mouseup; end_pos = " + evt.screenX + " / " + evt.screenY); this.handle_move(this.swipe_pos_x - evt.screenX, @@ -66,7 +68,7 @@ export class ActivePage { }, false); document.body.addEventListener("touchstart", - (evt: TouchEvent) => { + (evt) => { this.swipe_pos_x = evt.changedTouches[0].screenX; this.swipe_pos_y = evt.changedTouches[0].screenY; console.log("touchstart; pos = " + this.swipe_pos_x + @@ -74,7 +76,7 @@ export class ActivePage { }, false); document.body.addEventListener("touchend", - (evt: TouchEvent) => { + (evt) => { var end_pos = evt.changedTouches[evt.changedTouches.length - 1]; console.log("touchend; end_pos = " + end_pos.screenX + " / " + end_pos.screenY); @@ -112,7 +114,7 @@ export class ActivePage { * negligible), then the vertical swipe (in either direction) means * jump to today. */ - handle_move(distX: number, distY: number) { + handle_move(distX, distY) { var negligible = 100; console.log('distX = ' + distX); console.log('distY = ' + distY); |