<commit_before>﻿@{
    string size = PageData["Size"] ?? "medium";
    var icon = "";
    switch (size) {
        default:
        case "medium":
            icon = "connect-facebook.png";
            break;
        case "large":
            icon = "connect-facebook-large.png";
            break;
    }
    var redirectUrl = PageData["Redirect"] ?? Request["Redirect"];
}
@helper GetFacebookInitializationScripts(string redirectUrl) {
    var urlsection = PageData["Section"] ?? "Callback"; // Possible values: Callback, Verify, Callback/Provider
    var result = PageData["Result"] ?? "redirect"; // Possible values: redirect, json
    var facebookPermissions = "email,user_about_me";
    
    <div id="fb-root" style="display: none"></div>
    <script type="text/javascript">
        var facebookInitialized, facebookConnect, fbtimer;

        if (!facebookInitialized) {
            Modernizr.load({ load: document.location.protocol +
                '//connect.facebook.net/@(Facebook.Language)/all.js',
                callback: function () {
                    FB.init({ appId: '@Facebook.AppId', status: true, cookie: true, xfbml: true });
                }
            });

            if (!facebookConnect) {
                function initFacebookConnect() {
                    facebookConnect = function () {
                        // If FB is was not loaded still, auto try again
                        if (typeof(FB) === 'undefined') {
                            fbtimer = setTimeout(facebookConnect, 500);
                        } else {
                            if (fbtimer) clearTimeout(fbtimer);
                            var redirect_url = $(this).data('redirect');
                            var profile_url = $(this).data('profile');
                            FB.login(function (response) {
                                if (response.authResponse) {
                                    //console.log('FacebookConnect: Welcome!');
                                    $.blockUI(loadingBlock);
                                    var url = LcUrl.LangPath + "Account/Facebook/@urlsection/?Redirect=" + redirect_url + '&profile=' + profile_url;
                                    console.log(url);
                                    @if (result == "redirect") {
                                    <text>
                                    window.location = url;
                                    </text>
                                    } else if (result == "json") {
                                    <text>
                                    popup(url, 'small', null, "Verifing");
                                    </text>
                                    }
                                    /*FB.api('/me', function (response) {
                                    console.log('FacebookConnect: Good to see you, ' + response.name + '.');
                                    });*/
                                } else {
                                    //console.log('FacebookConnect: User cancelled login or did not fully authorize.');
                                }
                            }, { scope: '@facebookPermissions' });
                        }
                        return false;
                    };
                    $(document).on('click', 'a.facebook-connect', facebookConnect);
                }
                if (typeof jQuery === 'undefined')
                    Modernizr.load(
                    { 
                        load: LcUrl.AppPath + "Scripts/jquery/jquery-1.7.2.min.js",
                        complete: initFacebookConnect
                    });
                else 
                    initFacebookConnect();
            }
<commit_msg>Changed how FacebookConnect button scripts are loaded and checked for 'loaded' to avoid race-condition errors on Chrome #189<commit_after>﻿@{
    string size = PageData["Size"] ?? "medium";
    var icon = "";
    switch (size) {
        default:
        case "medium":
            icon = "connect-facebook.png";
            break;
        case "large":
            icon = "connect-facebook-large.png";
            break;
    }
    var redirectUrl = PageData["Redirect"] ?? Request["Redirect"];
}
@helper GetFacebookInitializationScripts(string redirectUrl) {
    var urlsection = PageData["Section"] ?? "Callback"; // Possible values: Callback, Verify, Callback/Provider
    var result = PageData["Result"] ?? "redirect"; // Possible values: redirect, json
    var facebookPermissions = "email,user_about_me";
    
    <div id="fb-root" style="display: none"></div>
    <script type="text/javascript">
        var facebookInitialized, facebookConnect, fbtimer;

        if (!facebookInitialized) {
            Modernizr.load({ load: document.location.protocol +
                '//connect.facebook.net/@(Facebook.Language)/all.js',
                complete: function () {
                    FB.init({ appId: '@Facebook.AppId', status: true, cookie: true, xfbml: true });
                }
            });

            if (!facebookConnect) {
                function initFacebookConnect() {
                    facebookConnect = function () {
                        // If FB is was not loaded still, auto try again
                        if (typeof(FB) === 'undefined') {
                            fbtimer = setTimeout(facebookConnect, 500);
                        } else {
                            if (fbtimer) clearTimeout(fbtimer);
                            var redirect_url = $(this).data('redirect');
                            var profile_url = $(this).data('profile');
                            FB.login(function (response) {
                                if (response.authResponse) {
                                    //console.log('FacebookConnect: Welcome!');
                                    $.blockUI(loadingBlock);
                                    var url = LcUrl.LangPath + "Account/Facebook/@urlsection/?Redirect=" + redirect_url + '&profile=' + profile_url;
                                    @if (result == "redirect") {
                                    <text>
                                    window.location = url;
                                    </text>
                                    } else if (result == "json") {
                                    <text>
                                    popup(url, 'small', null, "Verifing");
                                    </text>
                                    }
                                    /*FB.api('/me', function (response) {
                                    console.log('FacebookConnect: Good to see you, ' + response.name + '.');
                                    });*/
                                } else {
                                    //console.log('FacebookConnect: User cancelled login or did not fully authorize.');
                                }
                            }, { scope: '@facebookPermissions' });
                        }
                        return false;
                    };
                    jQuery(document).on('click', 'a.facebook-connect', facebookConnect);
                }
                if (!window['jQuery'])
                    Modernizr.load(
                    {
                        load: LcUrl.AppPath + "Scripts/jquery/jquery-1.7.2.min.js",
                        complete: initFacebookConnect
                    });
                else 
                    initFacebookConnect();
            }

{'fraction_non_alphanumeric': 0.11046280334173186, 'fraction_numerical': 0.0019891261105954116, 'mean_word_length': 1.0886181113265023, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3620304', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1613, 'n_words': 366}