<commit_before>define(['jquery', 'eventEmitter/EventEmitter', 'base/login'],
  function ($, EventEmitter, auth) {
    'use strict';

    var emitter = new EventEmitter();

    var $applyBtn = $('#apply-now');
    var $closeBtn = $('.js-close-panel');
    var $issueBadgeBtn = $('#js-badge-issuing');
    var $applicationForm = $('#submit-badge-application');
    var $application = $('#application');
    var $claimCodeInput = $applicationForm.find('[name="claimcode"]');
    var $evidenceInput = $applicationForm.find('[name="evidence"]');
    var $cityInput = $applicationForm.find('[name="city"]');
    var $applicationInputs = $evidenceInput.add($cityInput);
    var $error = $('.submit-badge-error');
    var $success = $('#submit-badge-success');
    var $successIssued = $('#issue-badge-success');
    var $successClaimed = $('#claim-badge-success');
    var $loginOnly = $('.login-only');
    var $logoutOnly = $('.logout-only');
    var $applicationOn = $('.application-on');
    var $applicationOff = $('.application-off');
    var $issueBadgeOn = $('.js-issue-badge-on');
    var $issue = $('#issue');
    var $issueForm = $('#issue-form');
    var $claimCodeQuestion = $('#claim-code-explainer');

    var badgeSlug = $application.attr('data-badge-slug');
    var applicationSlug = $application.attr('data-application-slug');

    // An application was submitted successfully
    emitter.on('submit-application', function () {
      $success.removeClass('hidden');
      $error.addClass('hidden');
      $application.addClass('hidden');
    });

    // An claim code was claimed successfully
    emitter.on('claim-successful', function () {
      $successClaimed.removeClass('hidden');
      $error.addClass('hidden');
      $application.addClass('hidden');
    });

    // An application was submitted successfully
    emitter.on('badge-issued', function () {
      $successIssued.removeClass('hidden');
      $error.addClass('hidden');
      $issue.addClass('hidden');
    });

    // An application error occurred
    emitter.on('error', function (err) {
      if (err.responseJSON) {
        $error.find('.error-message').html('(' + err.responseJSON.error + ')');
      }
      $success.addClass('hidden');
      $successIssued.addClass('hidden');
      $error.removeClass('hidden');
    });

    emitter.on('reset-application', function (err) {
      $success.addClass('hidden');
      $error.addClass('hidden');
      $application.removeClass('hidden');
    });

    emitter.on('application-on', function () {
      $applicationOn.removeClass('hidden');
      $applicationOff.addClass('hidden');
    });

    emitter.on('js-issue-badge-on', function () {
      $issueBadgeOn.removeClass('hidden');
      $applicationOff.addClass('hidden');
    });

    emitter.on('application-off', function () {
      $applicationOn.addClass('hidden');
      $issueBadgeOn.addClass('hidden');
      $applicationOff.removeClass('hidden');
    });

    $logoutOnly.on('click', function () {
      auth.login();
    });

    auth.on('login', function () {
      $loginOnly.removeClass('hidden');
      $logoutOnly.addClass('hidden');
    });

    auth.on('logout', function () {
      $loginOnly.addClass('hidden');
      $logoutOnly.removeClass('hidden');
    });

    $claimCodeInput.on('change', function (e) {
      if ($claimCodeInput.val().length) {
        $applicationInputs.removeAttr('required');
        $applicationInputs.attr('disabled', 'disabled');
      } else {
        $applicationInputs.attr('required', 'required');
        $applicationInputs.removeAttr('disabled');
      }<commit_msg>verify login for badge detail page<commit_after>define(['jquery', 'eventEmitter/EventEmitter', 'base/login'],
  function ($, EventEmitter, auth) {
    'use strict';

    var emitter = new EventEmitter();

    var $applyBtn = $('#apply-now');
    var $closeBtn = $('.js-close-panel');
    var $issueBadgeBtn = $('#js-badge-issuing');
    var $applicationForm = $('#submit-badge-application');
    var $application = $('#application');
    var $claimCodeInput = $applicationForm.find('[name="claimcode"]');
    var $evidenceInput = $applicationForm.find('[name="evidence"]');
    var $cityInput = $applicationForm.find('[name="city"]');
    var $applicationInputs = $evidenceInput.add($cityInput);
    var $error = $('.submit-badge-error');
    var $success = $('#submit-badge-success');
    var $successIssued = $('#issue-badge-success');
    var $successClaimed = $('#claim-badge-success');
    var $loginOnly = $('.login-only');
    var $logoutOnly = $('.logout-only');
    var $applicationOn = $('.application-on');
    var $applicationOff = $('.application-off');
    var $issueBadgeOn = $('.js-issue-badge-on');
    var $issue = $('#issue');
    var $issueForm = $('#issue-form');
    var $claimCodeQuestion = $('#claim-code-explainer');

    var badgeSlug = $application.attr('data-badge-slug');
    var applicationSlug = $application.attr('data-application-slug');

    // An application was submitted successfully
    emitter.on('submit-application', function () {
      $success.removeClass('hidden');
      $error.addClass('hidden');
      $application.addClass('hidden');
    });

    // An claim code was claimed successfully
    emitter.on('claim-successful', function () {
      $successClaimed.removeClass('hidden');
      $error.addClass('hidden');
      $application.addClass('hidden');
    });

    // An application was submitted successfully
    emitter.on('badge-issued', function () {
      $successIssued.removeClass('hidden');
      $error.addClass('hidden');
      $issue.addClass('hidden');
    });

    // An application error occurred
    emitter.on('error', function (err) {
      if (err.responseJSON) {
        $error.find('.error-message').html('(' + err.responseJSON.error + ')');
      }
      $success.addClass('hidden');
      $successIssued.addClass('hidden');
      $error.removeClass('hidden');
    });

    emitter.on('reset-application', function (err) {
      $success.addClass('hidden');
      $error.addClass('hidden');
      $application.removeClass('hidden');
    });

    emitter.on('application-on', function () {
      $applicationOn.removeClass('hidden');
      $applicationOff.addClass('hidden');
    });

    emitter.on('js-issue-badge-on', function () {
      $issueBadgeOn.removeClass('hidden');
      $applicationOff.addClass('hidden');
    });

    emitter.on('application-off', function () {
      $applicationOn.addClass('hidden');
      $issueBadgeOn.addClass('hidden');
      $applicationOff.removeClass('hidden');
    });

    $logoutOnly.on('click', function () {
      auth.login();
    });

    auth.on('login', function () {
      $loginOnly.removeClass('hidden');
      $logoutOnly.addClass('hidden');
    });

    auth.on('logout', function () {
      $loginOnly.addClass('hidden');
      $logoutOnly.removeClass('hidden');
    });

    auth.wmLogin.verify();
    $claimCodeInput.on('change', function (e) {
      if ($claimCodeInput.val().length) {
        $applicationInputs.removeAttr('required');
        $applicationInputs.attr('disabled', 'disabled');
      } else {
        $applicationInputs.attr('required', 'required');
        $applicationInputs.removeAttr('disabled');
      }
{'fraction_non_alphanumeric': 0.1891184573002755, 'fraction_numerical': 0.0, 'mean_word_length': 3.4573357888275016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3080177', 'n_tokens_mistral': 2078, 'n_tokens_neox': 2047, 'n_words': 342}