var appStoreLinks = (function () { let playStoreUrl = "https://play.google.com/store/apps/details?id=com.citic.inmotion"; let deepPlayStoreUrl = "market://details?id=com.citic.inmotion" let appStoreUrl = "https://apps.apple.com/us/app/inmotion-by-cncbi/id1294956074?ls=1"; let appGalleryUrl = "https://appgallery.huawei.com/#/app/C103527827"; let redirectUrl = "https://www.cncbinternational.com/personal/redirect/download-redirect.html"; let websiteUrl = "https://www.cncbinternational.com/personal/e-banking/inmotion/tc/index.html"; const keyValRule = /^[\w_-]+$/ const urlParams = new URLSearchParams(location.search); let referrer = urlParams.get("referrer") || ""; if (referrer) { const referrerParams = new URLSearchParams(referrer); for (const [key, value] of referrerParams.entries()) { if (!keyValRule.test(key) || !keyValRule.test(value)) { referrer = "" break } } if (referrer) { referrer = referrerParams.toString() } } function getInmotionLink() { return "inmotion://?referrer=" + encodeURIComponent(referrer); } function getPlayStoreUrl() { if (referrer) { return playStoreUrl + "&referrer=" + encodeURIComponent(referrer); } else { return playStoreUrl } } function getDeepPlayStoreUrl() { if (referrer) { return deepPlayStoreUrl + "&referrer=" + encodeURIComponent(referrer); } else { return deepPlayStoreUrl; } } function getAppStoreUrl() { // TODO: Update later... return appStoreUrl; } function getAppGallery() { // Referrer is not supoort for AppGallery return appGalleryUrl; } function getRedirect() { return redirectUrl + "?referrer=" + encodeURIComponent(referrer); } function createRedirectQrCode(id, width, height) { if (typeof QRCode === "undefined") return; return new QRCode(document.getElementById(id), { text: getRedirect(), width: width, height: height, }); } function getWebsiteUrl() { if (referrer) { if (websiteUrl.includes('?')) { return websiteUrl + "&referrer=" + encodeURIComponent(referrer); } else { return websiteUrl + "?referrer=" + encodeURIComponent(referrer); } } else { return websiteUrl; } } function gotoPlayStore(doneCb) { location.href = getInmotionLink() setTimeout(function () { if (!document.hasFocus()) return location.href = getDeepPlayStoreUrl() setTimeout(function () { if (!document.hasFocus()) return location.href = getPlayStoreUrl() if (typeof doneCb === "function") doneCb() }, 1000) }, 1000) } function gotoAppStore(doneCb) { location.href = getAppStoreUrl() if (typeof doneCb === "function") doneCb() } function gotoAppGallery(doneCb) { location.href = getInmotionLink() setTimeout(function () { if (!document.hasFocus()) return location.href = getAppGallery() if (typeof doneCb === "function") doneCb(); }, 1000) } function gotoAnyAppStore(doneCb) { var userAgent = navigator.userAgent || navigator.vendor || window.opera; // iPad if (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) { gotoAppStore(); if (typeof doneCb === "function") doneCb("ios"); } // iOS detection else if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { gotoAppStore(); if (typeof doneCb === "function") doneCb("ios"); } // Android detection else if (/android/i.test(userAgent)) { gotoPlayStore(function () { if (typeof doneCb === "function") doneCb("android"); }); } // Fallback for other devices (e.g., desktop) else { location.href = getWebsiteUrl(); if (typeof doneCb === "function") doneCb("website"); } } return { gotoPlayStore, gotoAppStore, gotoAppGallery, gotoAnyAppStore, getPlayStoreUrl, getDeepPlayStoreUrl, getAppStoreUrl, getAppGallery, getRedirect, createRedirectQrCode, getWebsiteUrl, getInmotionLink } })()