<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">
        if (!window['facebookInitialized']) $(window).load(function() {
            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) {
                var facebookConnect, fbtimer;
                facebookConnect = function () {
                    // If FB is was not loaded still, auto try again
                    if (!window['FB']) {
                        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);
            }
            window.facebookInitialized = true;<commit_msg>Changed loading of Facebook scripts by the new loader #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">
        /* Load if not initialized and only after all other elements were loaded in the page */
        if (!window['facebookInitialized']) $(window).load(function() {
            LC.load({
                scripts: ['//connect.facebook.net/@(Facebook.Language)/all.js'],
                complete: function () {
                    FB.init({ appId: '@Facebook.AppId', status: true, cookie: true, xfbml: true });
                },
                completeVerification: function () {
                    return !!window['FB'];
                }
            });
            if (!facebookConnect) {
                var facebookConnect, fbtimer;
                facebookConnect = function () {
                    // If FB is was not loaded still, auto try again
                    if (!window['FB']) {
                        fbtimer = setTimeout($.proxy(facebookConnect, this), 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);
            }
            window.facebookInitialized = true;
{'fraction_non_alphanumeric': 0.1199580146948568, 'fraction_numerical': 0.001349527665317139, 'mean_word_length': 1.2367538564721663, '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': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4615950', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1477, 'n_words': 351}