<commit_before>pjax_config_page("new_account/virtualws", function(){
  return {
    onLoad: function() {
      if (getCookieItem('login')) {
          window.location.href = page.url.url_for('user/my_accountws');
          return;
      }
      Content.populate();
      var virtualForm = $('#virtual-form');

      handle_residence_state_ws();
      BinarySocket.send({residence_list:1});
      var form = document.getElementById('virtual-form');
      var errorPassword = document.getElementById('error-password'),
          errorRPassword = document.getElementById('error-r-password'),
          errorResidence = document.getElementById('error-residence'),
          errorAccount = document.getElementById('error-account-opening'),
          errorVerificationCode = document.getElementById('error-verification-code');

      if (isIE() === false) {
        $('#password').on('input', function() {
          $('#password-meter').attr('value', testPassword($('#password').val())[0]);
        });
      } else {
        $('#password-meter').remove();
      }

      if (form) {
        virtualForm.submit( function(evt) {
          evt.preventDefault();

          var verificationCode = document.getElementById('verification-code').value,
              residence        = document.getElementById('residence').value,
              password         = document.getElementById('password').value,
              rPassword        = document.getElementById('r-password').value;

          Validate.errorMessageResidence(residence, errorResidence);
          Validate.errorMessageToken(verificationCode, errorVerificationCode);
          Validate.hideErrorMessage(errorAccount);

          if (Validate.errorMessagePassword(password, rPassword, errorPassword, errorRPassword) && !Validate.errorMessageResidence(residence, errorResidence) && Validate.validateToken(verificationCode, errorVerificationCode)){
            BinarySocket.init({
              onmessage: function(msg){
                var response = JSON.parse(msg.data);
                if (response) {
                  var type = response.msg_type;
                  var error = response.error;

                  if (type === 'new_account_virtual' && !error){
                    // set a flag to push to gtm in my_account
                    localStorage.setItem('new_account', '1');

                    document.getElementById('email').value = response.new_account_virtual.email;
                    form.setAttribute('action', '/login');
                    form.setAttribute('method', 'POST');
                    virtualForm.unbind('submit');
                    form.submit();
                  } else if (type === 'error' || error) {
                    if (error.code === 'InvalidToken') {
                      virtualForm.empty();
                      $('.notice-message').remove();
                      var noticeText = '<p>' + Content.localize().textClickHereToRestart.replace('[_1]', page.url.url_for('')) + '</p>';
                      virtualForm.html(noticeText);
                      return;
                    } else if (error.code === 'PasswordError') {
                      errorAccount.textContent = text.localize('Password is not strong enough.');
                    } else if (error.message) {
                      errorAccount.textContent = error.message;<commit_msg>check error token<commit_after>pjax_config_page("new_account/virtualws", function(){
  return {
    onLoad: function() {
      if (getCookieItem('login')) {
          window.location.href = page.url.url_for('user/my_accountws');
          return;
      }
      Content.populate();
      var virtualForm = $('#virtual-form');

      handle_residence_state_ws();
      BinarySocket.send({residence_list:1});
      var form = document.getElementById('virtual-form');
      var errorPassword = document.getElementById('error-password'),
          errorRPassword = document.getElementById('error-r-password'),
          errorResidence = document.getElementById('error-residence'),
          errorAccount = document.getElementById('error-account-opening'),
          errorVerificationCode = document.getElementById('error-verification-code');

      if (isIE() === false) {
        $('#password').on('input', function() {
          $('#password-meter').attr('value', testPassword($('#password').val())[0]);
        });
      } else {
        $('#password-meter').remove();
      }

      if (form) {
        virtualForm.submit( function(evt) {
          evt.preventDefault();

          var verificationCode = document.getElementById('verification-code').value,
              residence        = document.getElementById('residence').value,
              password         = document.getElementById('password').value,
              rPassword        = document.getElementById('r-password').value;

          Validate.errorMessageResidence(residence, errorResidence);
          Validate.errorMessageToken(verificationCode, errorVerificationCode);
          Validate.hideErrorMessage(errorAccount);

          if (Validate.errorMessagePassword(password, rPassword, errorPassword, errorRPassword) && !Validate.errorMessageResidence(residence, errorResidence) && !Validate.errorMessageToken(verificationCode, errorVerificationCode)){
            BinarySocket.init({
              onmessage: function(msg){
                var response = JSON.parse(msg.data);
                if (response) {
                  var type = response.msg_type;
                  var error = response.error;

                  if (type === 'new_account_virtual' && !error){
                    // set a flag to push to gtm in my_account
                    localStorage.setItem('new_account', '1');

                    document.getElementById('email').value = response.new_account_virtual.email;
                    form.setAttribute('action', '/login');
                    form.setAttribute('method', 'POST');
                    virtualForm.unbind('submit');
                    form.submit();
                  } else if (type === 'error' || error) {
                    if (error.code === 'InvalidToken') {
                      virtualForm.empty();
                      $('.notice-message').remove();
                      var noticeText = '<p>' + Content.localize().textClickHereToRestart.replace('[_1]', page.url.url_for('')) + '</p>';
                      virtualForm.html(noticeText);
                      return;
                    } else if (error.code === 'PasswordError') {
                      errorAccount.textContent = text.localize('Password is not strong enough.');
                    } else if (error.message) {
                      errorAccount.textContent = error.message;
{'fraction_non_alphanumeric': 0.13108168427317363, 'fraction_numerical': 0.0011902990626394881, 'mean_word_length': 2.1455311183902666, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7838', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1587, 'n_words': 275}