<commit_before>'use strict';

import 'jquery';
import { notifier } from 'notifier';
import { request } from 'requester';
import { header } from 'header-generator';
import { template } from 'template-generator';
import { pageLoader } from 'page-controller';
import { userModel } from 'user-model';
import { validator } from 'validator';
import { kinveyUrls } from 'kinvey-urls';
import CryptoJS from 'cryptojs';

let eventLoader = (function(){

  function getUserLoginDetails() {
      let user = {
          "username": $('#login-username').val(),
          "password": <PASSWORD>JS.SHA1($('#login-password').val()).toString(),
      }

      return user;
  };

  class EventController {

    loadFrontPageEvents() {

        $('#sign-in-user').on('click', function(ev) {
            userModel.login(getUserLoginDetails());
        });

        $('#login-password').on('keydown', function(ev) {
            if (ev.which === 13) {
                userModel.login(getUserLoginDetails());
            }
        });

        $('#input-confirm-password').on('input', function(ev) {
            let $this = $(ev.target);

            if ($this.val() !== $('#input-password').val()) {
                $this.parents('.form-group').addClass('has-error');
            } else {
                $this.parents('.form-group').removeClass('has-error');
            }
        })

        $('#input-password').on('input', function(ev) {
            let $this = $(ev.target);
            let confirmPassword = $('#input-confirm-password')
            if ($this.val() === confirmPassword.val()) {
                confirmPassword.parents('.form-group').removeClass('has-error');
            } else {
                confirmPassword.parents('.form-group').addClass('has-error');
            }
        })

        $('#sign-up-user').on('click', function(ev) {
            let randomAvatarNumber = Math.floor(Math.random() * 10)
            let user = {
                "username": $('#input-username').val(),
                "password": <PASSWORD>JS.SHA1($('#input-password').val()).toString(),
                "firstName": $('#input-first-name').val(),
                "lastName": $('#input-last-name').val(),
                "email": $('#input-email-address').val(),
                "favoriteAuthors": {},
                "readBooks": [],
                "avatar": {
                    "_type": "KinveyRef",
                    "_id": kinveyUrls.KINVEY_AVATAR_IDS[randomAvatarNumber],
                    "_collection": "avatars"
                }
            };

            if (validator.validateNames(user.firstName, user.lastName) &&
                validator.validateUsername(user.username) &&
                validator.validateEmail(user.email) &&
                validator.validatePassword()) {
                userModel.register(user);
            }
        });
    };

    loadUserNavigationEvents() {
        $('#sign-out-user').on('click', function(ev) {
            userModel.logout();
        });
    };

    loadAuthorModalEvent(data) {
        $('.author-learn-more').on('click', function(ev) {
            let authorName = $(ev.target).parent().find('h2').html();
            if (!authorName) {<commit_msg>fixed bug issue with registration and login in.<commit_after>'use strict';

import 'jquery';
import { notifier } from 'notifier';
import { request } from 'requester';
import { header } from 'header-generator';
import { template } from 'template-generator';
import { pageLoader } from 'page-controller';
import { userModel } from 'user-model';
import { validator } from 'validator';
import { kinveyUrls } from 'kinvey-urls';
import CryptoJS from 'cryptojs';

let eventLoader = (function(){

  function getUserLoginDetails() {
      let user = {
          "username": $('#login-username').val(),
          "password": <PASSWORD>($('#login-password').val()).toString(),
      }

      return user;
  };

  class EventController {

    loadFrontPageEvents() {

        $('#sign-in-user').on('click', function(ev) {
            userModel.login(getUserLoginDetails());
        });

        $('#login-password').on('keydown', function(ev) {
            if (ev.which === 13) {
                userModel.login(getUserLoginDetails());
            }
        });

        $('#input-confirm-password').on('input', function(ev) {
            let $this = $(ev.target);

            if ($this.val() !== $('#input-password').val()) {
                $this.parents('.form-group').addClass('has-error');
            } else {
                $this.parents('.form-group').removeClass('has-error');
            }
        })

        $('#input-password').on('input', function(ev) {
            let $this = $(ev.target);
            let confirmPassword = $('#input-confirm-password')
            if ($this.val() === confirmPassword.val()) {
                confirmPassword.parents('.form-group').removeClass('has-error');
            } else {
                confirmPassword.parents('.form-group').addClass('has-error');
            }
        })

        $('#sign-up-user').on('click', function(ev) {
            let randomAvatarNumber = Math.floor(Math.random() * 10)
            let user = {
                "username": $('#input-username').val(),
                "password": <PASSWORD>($('#input-password').<PASSWORD>()).<PASSWORD>(),
                "firstName": $('#input-first-name').val(),
                "lastName": $('#input-last-name').val(),
                "email": $('#input-email-address').val(),
                "favoriteAuthors": {},
                "readBooks": [],
                "avatar": {
                    "_type": "KinveyRef",
                    "_id": kinveyUrls.KINVEY_AVATAR_IDS[randomAvatarNumber],
                    "_collection": "avatars"
                }
            };

            if (validator.validateNames(user.firstName, user.lastName) &&
                validator.validateUsername(user.username) &&
                validator.validateEmail(user.email) &&
                validator.validatePassword()) {
                userModel.register(user)
                  .then(response => userModel.login(response));
            }
        });
    };

    loadUserNavigationEvents() {
        $('#sign-out-user').on('click', function(ev) {
            userModel.logout();
        });
    };

    loadAuthorModalEvent(data) {
        $('.author-learn-more').on('click', function(ev) {
            let authorName = $(ev.target).parent().find('h2').html();
            if (!authorName) {
{'fraction_non_alphanumeric': 0.17743921206525085, 'fraction_numerical': 0.0018467220683287165, 'mean_word_length': 1.9839302112029384, 'pattern_counts': {'":': 26, '<': 9, '<?xml version=': 0, '>': 10, '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': '5267042', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1717, 'n_words': 281}