Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions lib/public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ function deepLink(options) {
'https://market.android.com/details?id=' + androidPackageName;
var ua = window.navigator.userAgent;

var hiddenProp, visibilityChange;
var timeoutId;
if (typeof document.hidden !== "undefined") {
hiddenProp = "hidden";
visibilityChange = "visibilitychange";
} else if (typeof document.msHidden !== "undefined") {
hiddenProp = "msHidden";
visibilityChange = "msvisibilitychange";
} else if (typeof document.webkitHidden !== "undefined") {
hiddenProp = "webkitHidden";
visibilityChange = "webkitvisibilitychange";
}

// split the first :// from the url string
var split = url.split(/:\/\/(.+)/);
var scheme = split[0];
Expand Down Expand Up @@ -45,11 +58,21 @@ function deepLink(options) {
window.location = urls.fallback;
}

function handleVisibilityChange() {
window.clearTimeout(timeoutId);
document.removeEventListener(visibilityChange, handleVisibilityChange, false);
}

function launchWekitApproach(url, fallback) {
if (typeof document.addEventListener !== "undefined" || hiddenProp !== undefined) {
document.addEventListener(visibilityChange, handleVisibilityChange, false);
}

document.location = url;
setTimeout(function() {

timeoutId = setTimeout(function() {
document.location = fallback;
}, 250);
}, 2500);
}

function launchIframeApproach(url, fallback) {
Expand Down