X-Git-Url: https://git.yukkurigames.com/?p=mlpccg.git;a=blobdiff_plain;f=mlpccg.js;h=1681afefb30d5a4a5d8523edb03de06aa64a22d5;hp=44ce3c33d5e3b256842900c9e357d9c202c329b2;hb=61267efeb7df6f77adec75120e8cbc8de8c8fec7;hpb=38629f9bf607425902be697ac5715e0def7e9b3f diff --git a/mlpccg.js b/mlpccg.js index 44ce3c3..1681afe 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 }); @@ -236,23 +236,14 @@ if (applicationCache && applicationCache.status) { } function dismiss () { - var overlay = document.getElementById("overlay"); - if (overlay) - overlay.parentNode.removeChild(overlay); - broadcast({ type: "dismiss" }); + var open = document.querySelectorAll(".dialog.open"); + for (var i = 0; i < open.length; ++i) + open[i].className = "dialog"; } -function show (id, otherId) { - var overlay = document.getElementById("overlay"); - if (!overlay) { - overlay = document.createElement('div'); - overlay.id = 'overlay'; - } else { - overlay.parentNode.removeChild(overlay); - } +function show (id) { + dismiss(); var target = document.getElementById(id); - target.parentNode.insertBefore(overlay, target); - if (otherId) - broadcast({ type: 'show', id: otherId }); + target.className += " open"; }