var _appDeepLinkDownlink = ''; var _targetLandingUrl = ''; (function (window, undefined) { var appDeepLinkDown = {}; window.appDeepLinkDown = window.appDeepLinkDown || appDeepLinkDown; var uagent = navigator.userAgent.toLocaleLowerCase(); if (uagent.search("android") > -1) { appDeepLinkDown.os = "android"; if (uagent.search("chrome") > -1) appDeepLinkDown.browser = "android+chrome"; } else if (uagent.search("iphone") > -1 || uagent.search("ipod") > -1 || uagent.search("ipad") > -1) { appDeepLinkDown.os = "ios"; appDeepLinkDown.iOsVer = parseFloat(('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]).replace('undefined', '3_2').replace('_', '.').replace('_', '')) || false; } var inputmode = "web"; if (uagent.indexOf("cjoneapp") > -1) inputmode ="app"; var app = { cjonecard: { base_url: "//webtoapp?", apiver: "2.8.1", store: { android: "market://details?id=kr.co.ivlog.mobile.app.cjonecard", ios: "https://itunes.apple.com/kr/app/cjone-card/id387363739?mt=8" }, packagenm: "kr.co.ivlog.mobile.app.cjonecard", scheme: "cjonecard", applink_url: (serverIpMsg == "oper") ? "https://app.cjone.com/cjonelink.html?" : "https://devapp.cjone.com/cjonelink.html?" }, onethelock: { base_url: "//webtoapp?", apiver: "1.0.0", store: { android: "market://details?id=kr.co.cjone.app.lockscreen", ios: "" }, packagenm: "kr.co.cjone.app.lockscreen", scheme: "onethelock" } }; appDeepLinkDown.link = function (name) { var link_app = app[name]; if (!link_app) return { send: function () { throw "No App exists"; }}; return { send: function (params) { var _app = this.app; params['apiver'] = _app.apiver; var full_url = _app.base_url + params; var install_block = (function (os) { return function () { window.location = _targetLandingUrl ? _targetLandingUrl : _app.store[os]; }; })(this.os); if (this.os == "ios") { if(inputmode == "web"){ var atag = document.createElement('a'); var href = _targetLandingUrl ? _targetLandingUrl : _app.applink_url+params atag.setAttribute('href', href); document.body.appendChild(atag); atag.click(); } else { //var timer = setTimeout(install_block, appDeepLinkDown.iOsVer >= 9 ? 10000 : 2000); //window.addEventListener('pagehide', clearTimer(timer)); window.location = "cjonecard:"+full_url; } } else if (this.os == "android") { if (this.browser == "android+chrome") { window.location = _targetLandingUrl ? _targetLandingUrl : "intent:" + full_url + "#Intent;scheme="+_app.scheme+";package=" + _app.packagenm + ";end;"; } else { var iframe = document.createElement('iframe'); iframe.width = '0'; iframe.height = '0'; iframe.style.disply = 'none'; iframe.src = full_url; iframe.onload = install_block; document.body.appendChild(iframe); } } else $(location).attr('href', '/cjmmobile/guide/guideAppInfo.do'); }, app: link_app, os: appDeepLinkDown.os, browser: appDeepLinkDown.browser }; function serialized(params) { var stripped = []; for (var k in params) if (params.hasOwnProperty(k)) stripped.push(k + "=" + encodeURIComponent(params[k])); return stripped.join("&"); } function clearTimer(timer) { return function () { clearTimeout(timer); window.removeEventListener('pagehide', arguments.callee); }; } }; }(window)); function cjoneAppDeepLink(){ if ( arguments.length > 0 ) _appDeepLinkDownlink = arguments[0]; setTimeout(function() { appDeepLinkDown.link("cjonecard").send(_appDeepLinkDownlink); }, 500); } function cjoneAppDeepLinkCurrPage(){ cjoneAppDeepLink('action=M130000&url=' + encodeURIComponent(location.href)); } function onethelockAppDeepLink(){ if ( arguments.length > 0 ) _appDeepLinkDownlink = arguments[0]; setTimeout(function() { appDeepLinkDown.link("onethelock").send(_appDeepLinkDownlink); }, 500); }