<commit_before>/* global daumtools, jshint devel: true */
(function (exports) {
    "use strict";

    exports.web2app = (function () {

        var TIMEOUT_IOS_SHORT = 1 * 1000,
            TIMEOUT_IOS_LONG = 2 * 1000,
            TIMEOUT_ANDROID = 3 * 100,
            INTERVAL = 100,
            ua = daumtools.userAgent(),
            os = ua.os,
            intentNotSupportedBrowserList = [
                'firefox',
                'opr',
                'fb_iab'
            ];

        function moveToStore (storeURL) {
            window.location.href = storeURL;
        }

        function web2app (context) {
            var willInvokeApp = (typeof context.willInvokeApp === 'function') ? context.willInvokeApp : function(){},
                onAppMissing  = (typeof context.onAppMissing === 'function')  ? context.onAppMissing  : moveToStore,
                onUnsupportedEnvironment = (typeof context.onUnsupportedEnvironment === 'function') ? context.onUnsupportedEnvironment : function(){};

            willInvokeApp();

            if (os.android) {
                if (isIntentSupportedBrowser() && context.intentURI && !context.useUrlScheme) {
                    web2appViaIntentURI(context.intentURI);
                } else if (context.storeURL) {
                    web2appViaCustomUrlSchemeForAndroid(context.urlScheme, context.storeURL, onAppMissing);
                }
            } else if (os.ios && context.storeURL) {
                web2appViaCustomUrlSchemeForIOS(context.urlScheme, context.storeURL, onAppMissing);
            } else {
                setTimeout(function () {
                    onUnsupportedEnvironment();
                }, 100);
            }
        }

        // chrome 25 and later supports intent. https://developer.chrome.com/multidevice/android/intents
        function isIntentSupportedBrowser () {
            var supportsIntent = ua.browser.chrome && +(ua.browser.version.major) >= 25;
            var blackListRegexp = new RegExp(intentNotSupportedBrowserList.join('|'), "i");
            return supportsIntent && !blackListRegexp.test(ua.ua);
        }

        function web2appViaCustomUrlSchemeForAndroid (urlScheme, storeURL, fallback) {
            deferFallback(TIMEOUT_ANDROID, storeURL, fallback);
            launchAppViaHiddenIframe(urlScheme);
        }

        function deferFallback(timeout, storeURL, fallback) {
            var clickedAt = new Date().getTime();
            return setTimeout(function () {
                var now = new Date().getTime();
                if (isPageVisible() && now - clickedAt < timeout + INTERVAL) {
                    fallback(storeURL);
                }
            }, timeout);
        }

        function web2appViaIntentURI (launchURI) {            
            if ( ua.browser.chrome ){
              move();
            }else{
              setTimeout(move, 100);
            }

            function move(){
              top.location.href = launchURI;
            }
        }

        function web2appViaCustomUrlSchemeForIOS (urlScheme, storeURL, fallback) {
            var tid;
            if (parseInt(ua.os.version.major, 10) < 8) {
                tid = deferFallback(TIMEOUT_IOS_LONG, storeURL, fallback);
                bindPagehideEvent(tid);
            } else {
                // to avoid ios store alert
                if (moveToStore === fallback) {
                    tid = deferFallback(TIMEOUT_IOS_SHORT, storeURL, fallback);
                } else {
                    tid = deferFallback(TIMEOUT_IOS_LONG, storeURL, fallback);
                }
                bindVisibilityChangeEvent(tid);
            }

            // https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12
            if ( isSupportUniversalLinks() ){
                launchAppViaChangingLocation(urlScheme);
            }else{<commit_msg>iOS9 에서 앱이 설치 되어 있음에도 무조건 스토어로 이동하는 버그 수정<commit_after>/* global daumtools, jshint devel: true */
(function (exports) {
    "use strict";

    exports.web2app = (function () {

        var TIMEOUT_IOS_SHORT = 1 * 1000,
            TIMEOUT_IOS_LONG = 2 * 1000,
            TIMEOUT_ANDROID = 3 * 100,
            INTERVAL = 100,
            ua = daumtools.userAgent(),
            os = ua.os,
            intentNotSupportedBrowserList = [
                'firefox',
                'opr',
                'fb_iab'
            ];

        function moveToStore (storeURL) {
            window.location.href = storeURL;
        }

        function web2app (context) {
            var willInvokeApp = (typeof context.willInvokeApp === 'function') ? context.willInvokeApp : function(){},
                onAppMissing  = (typeof context.onAppMissing === 'function')  ? context.onAppMissing  : moveToStore,
                onUnsupportedEnvironment = (typeof context.onUnsupportedEnvironment === 'function') ? context.onUnsupportedEnvironment : function(){};

            willInvokeApp();

            if (os.android) {
                if (isIntentSupportedBrowser() && context.intentURI && !context.useUrlScheme) {
                    web2appViaIntentURI(context.intentURI);
                } else if (context.storeURL) {
                    web2appViaCustomUrlSchemeForAndroid(context.urlScheme, context.storeURL, onAppMissing);
                }
            } else if (os.ios && context.storeURL) {
                web2appViaCustomUrlSchemeForIOS(context.urlScheme, context.storeURL, onAppMissing);
            } else {
                setTimeout(function () {
                    onUnsupportedEnvironment();
                }, 100);
            }
        }

        // chrome 25 and later supports intent. https://developer.chrome.com/multidevice/android/intents
        function isIntentSupportedBrowser () {
            var supportsIntent = ua.browser.chrome && +(ua.browser.version.major) >= 25;
            var blackListRegexp = new RegExp(intentNotSupportedBrowserList.join('|'), "i");
            return supportsIntent && !blackListRegexp.test(ua.ua);
        }

        function web2appViaCustomUrlSchemeForAndroid (urlScheme, storeURL, fallback) {
            deferFallback(TIMEOUT_ANDROID, storeURL, fallback);
            launchAppViaHiddenIframe(urlScheme);
        }

        function deferFallback(timeout, storeURL, fallback) {
            var clickedAt = new Date().getTime();
            return setTimeout(function () {
                var now = new Date().getTime();
                if (isPageVisible() && now - clickedAt < timeout + INTERVAL) {
                    fallback(storeURL);
                }
            }, timeout);
        }

        function web2appViaIntentURI (launchURI) {            
            if ( ua.browser.chrome ){
              move();
            }else{
              setTimeout(move, 100);
            }

            function move(){
              top.location.href = launchURI;
            }
        }

        function web2appViaCustomUrlSchemeForIOS (urlScheme, storeURL, fallback) {
            var tid;
            if (parseInt(ua.os.version.major, 10) < 8) {
                tid = deferFallback(TIMEOUT_IOS_LONG, storeURL, fallback);
                bindPagehideEvent(tid);
            } else {
                // to avoid ios store alert
                if (moveToStore === fallback) {
                    tid = deferFallback(TIMEOUT_IOS_SHORT, storeURL, fallback);
                } else {
                    tid = deferFallback(TIMEOUT_IOS_LONG, storeURL, fallback);
                }
                bindVisibilityChangeEvent(tid);
            }

            // https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12
            if ( isSupportUniversalLinks() ){
                clearTimeout(tid);
                launchAppViaChangingLocation(urlScheme);
            }else{
{'fraction_non_alphanumeric': 0.09993730407523511, 'fraction_numerical': 0.012163009404388714, 'mean_word_length': 1.740893470790378, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '55478', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2097, 'n_words': 390}