<commit_before>$(function () {
  'use strict';

  function testLogin() {
    $.getJSON('/account.json').then(function (data) {
      if (!data || !data.user) {
        return;
      }

      $('.js-login').hide();
      $('.js-logout').show();
      $('.js-login-dialog').modal('hide');
      $('.js-profile').html(JSON.stringify(data, null, '  '));
      $('.js-profile-container').fadeIn();

      if (data.user && data.user.photos.length) {
        $('img.js-headshot').attr('src', data.user.photos[0].value);
        $('img.js-headshot').show();
      }
    });
  }

  $('.js-open-facebook-login').click('body', function () {
    // handling this in the browser instead of on the server
    // means swapping a redirect for an http request,
    // so don't believe an fanatic's fallacy that this is slower.
    window.completeLogin = function (/*name, href*/) {
      // name can be used to disambiguate if you have multiple login strategies
      // href will contain 'code', 'token', or an error you may want to display to the user
      testLogin();
    };

    // Due to security issues surrounding iframes (click-jacking, etc),
    // we currently only support opening a new window for OAuth2.
    // Admitedly, it's a little more visual distracting that the normal double-redirect,
    // but that makes it much more difficult to bring the user back to their present experience
    // so we highly recommend this method.
    // Once the security issues are figured out, we'll support iframes (like facebook)
    window.open('/auth/facebook');
    // alternate method <iframe src="frame.htm" allowtransparency="true">
  });

  // all the comments above apply here as well, of course
  $('.js-open-ldsconnect-login').click('body', function () {
    window.completeLogin = function (/*name, href*/) {
      testLogin();
    };
    window.open('/auth/ldsconnect');
  });

  function init() {
    $('.js-logout').hide();
    $('img.js-headshot').hide();
    $('.js-profile-container').hide();

    testLogin();
  }

  init();
});
<commit_msg>add login failure alert<commit_after>$(function () {
  'use strict';

  function testLogin() {
    $.getJSON('/account.json').then(function (data) {
      if (!data || !data.user) {
        return;
      }

      $('.js-login').hide();
      $('.js-logout').show();
      $('.js-login-dialog').modal('hide');
      $('.js-profile').html(JSON.stringify(data, null, '  '));
      $('.js-profile-container').fadeIn();

      if (data.user && data.user.photos.length) {
        $('img.js-headshot').attr('src', data.user.photos[0].value);
        $('img.js-headshot').show();
      }
    });
  }

  $('.js-open-facebook-login').click('body', function () {
    // handling this in the browser instead of on the server
    // means swapping a redirect for an http request,
    // so don't believe an fanatic's fallacy that this is slower.
    window.completeLogin = function (name, href) {
      // name can be used to disambiguate if you have multiple login strategies
      // href will contain 'code', 'token', or an error you may want to display to the user
      if (!/code=/.test(href)) {
        window.alert("Looks like the login failed for " + name + "!");
        return;
      }

      testLogin();
    };

    // Due to security issues surrounding iframes (click-jacking, etc),
    // we currently only support opening a new window for OAuth2.
    // Admitedly, it's a little more visual distracting that the normal double-redirect,
    // but that makes it much more difficult to bring the user back to their present experience
    // so we highly recommend this method.
    // Once the security issues are figured out, we'll support iframes (like facebook)
    window.open('/auth/facebook');
    // alternate method <iframe src="frame.htm" allowtransparency="true">
  });

  // all the comments above apply here as well, of course
  $('.js-open-ldsconnect-login').click('body', function () {
    window.completeLogin = function (name, href) {
      if (!/code=/.test(href)) {
        window.alert("Looks like the login failed for " + name + "!");
        return;
      }

      testLogin();
    };
    window.open('/auth/ldsconnect');
  });

  function init() {
    $('.js-logout').hide();
    $('img.js-headshot').hide();
    $('.js-profile-container').hide();

    testLogin();
  }

  init();
});

{'fraction_non_alphanumeric': 0.16536518144235185, 'fraction_numerical': 0.0009186954524575103, 'mean_word_length': 2.6720067453625633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '4946895', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1257, 'n_words': 383}