From: Joe Wreschnig Date: Tue, 5 Aug 2014 20:48:09 +0000 (+0200) Subject: Android improvements X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=adfa2f63286a9abd44621e5d0374570a12ae0adf;p=mlpccg.git Android improvements Add width=device-width to viewport specification, which should remove tap delay (and automatically disable fastclick) in current Android Chrome. Disable origin checks, which seem to fail randomly on Android. Remove now-unused show message, which was the only even slightly-dangerous message. --- diff --git a/double.html b/double.html index 8391471..915612f 100644 --- a/double.html +++ b/double.html @@ -13,7 +13,7 @@ --> - + diff --git a/mlpccg.html b/mlpccg.html index ae52f02..5433a88 100644 --- a/mlpccg.html +++ b/mlpccg.html @@ -13,7 +13,7 @@ --> - + diff --git a/mlpccg.js b/mlpccg.js index 44ce3c3..0e8643e 100644 --- a/mlpccg.js +++ b/mlpccg.js @@ -66,16 +66,14 @@ function iclamp (x, lo, hi) { } function broadcast (data, source) { - var origin = (!location.origin || location.origin === "null") - ? "*" : location.origin; source = source || window; if (window.parent && window.parent !== source && window.parent !== window) { - window.parent.postMessage(data, origin); + window.parent.postMessage(data, "*"); } for (var i = 0; i < window.frames.length; ++i) { var w = window.frames[i].window; if (w !== source) { - w.postMessage(data, origin); + w.postMessage(data, "*"); } } } @@ -164,10 +162,12 @@ function open (event) { event.preventDefault(); } -window.addEventListener('DOMContentLoaded', function () { - var links = document.querySelectorAll("a[href]:not([target=_blank])"); - for (var i = 0; i < links.length; ++i) { - links[i].addEventListener('click', open); +window.addEventListener('DOMContentLoaded', function () { + if (navigator.standalone) { + var links = document.querySelectorAll("a[href]:not([target=_blank])"); + for (var i = 0; i < links.length; ++i) { + links[i].addEventListener('click', open); + } } FastClick.attach(document.body, { tapDelay: 50 }); @@ -242,7 +242,7 @@ function dismiss () { broadcast({ type: "dismiss" }); } -function show (id, otherId) { +function show (id) { var overlay = document.getElementById("overlay"); if (!overlay) { overlay = document.createElement('div'); @@ -252,7 +252,5 @@ function show (id, otherId) { } var target = document.getElementById(id); target.parentNode.insertBefore(overlay, target); - if (otherId) - broadcast({ type: 'show', id: otherId }); } diff --git a/single.html b/single.html index 89f5429..2852ad5 100644 --- a/single.html +++ b/single.html @@ -13,7 +13,7 @@ --> - + @@ -302,10 +302,6 @@ overlay.parentNode.removeChild(overlay); }; - messages.show = function (data) { - show(data.id); - }; - function maybeBack (event) { if (Math.max(score, opponentScore) !== 0 && Math.max(score, opponentScore) !== 15) {