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

  moj.Modules.UserTesting = {
    el: '.form-actions',
    pt: '.phase-tag',
    scopeCheckerUrl: 'http://clap-user-testing.dsd.io/',
    covered: [
      {
        name: 'debt',
        checkerStartFilename: 'debt_and_housing.html'
      },
      {
        name: 'discrimination',
        checkerStartFilename: 'discrimination.html'
      },
      {
        name: 'education',
        checkerStartFilename: 'education.html'
      },
      {
        name: 'family',
        checkerStartFilename: 'family.html'
      },
      {
        name: 'housing',
        checkerStartFilename: 'debt_and_housing.html'
      },
      {
        name: 'violence',
        checkerStartFilename: 'domestic_violence.html'
      },
      {
        name: 'immigration',
        checkerStartFilename: 'immigration.html'
      }
    ],

    init: function() {
      if(this.userTestingAvailable()) {
        moj.log('testing available');
        this.cacheEls();
        this.bindEvents();
      }
    },

    cacheEls: function() {
      this.$phaseTag = $(this.pt);
      this.$submit = $(this.el).find('button[type="submit"]');
      this.$form = this.$submit.closest('form');
    },

    bindEvents: function() {
      var self = this;
      this.$phaseTag.on('dblclick', function(e) {
        e.preventDefault();
        self.enable();
      });

      $(document).on('click', '.fake-submit', function(e) {
        e.preventDefault();
        self.fakeSubmit();
      });

      $('input[name="categories"]').on('keypress keydown', function(e) {
        if(e.which === 13) {
          e.preventDefault();
          self.fakeSubmit();
        }
      });
    },

    userTestingAvailable: function() {
      var loc = document.location;
      var isProblemPage = (loc.pathname.indexOf('/problem') !== -1);
      var isDevOrDemo = (loc.hostname.indexOf('localhost') !== -1 || loc.hostname.indexOf('public-demo.cla.dsd.io') !== -1);
      return isDevOrDemo && isProblemPage;
    },

    enable: function() {
      this.$submit
        .hide()
        .before('<button class="button button-larger fake-submit">Continue</button>')
      ;
      this.$phaseTag.siblings('span').html('<strong>User Testing Enabled</strong>');

      moj.log('testing enabled');
    },

    getCategoryEl: function() {
      var $c = $('[name="categories"]:checked');
      return $c;
    },

    openScopeChecker: function(page) {
      var self = this;
      this.spawnedWindow = open(this.scopeCheckerUrl + page);
      this.spawnedWindow.focus();

      this.spawnedWindow.onunload = function() {
        self.realSubmit();
      };
    },

    fakeSubmit: function() {
      var self = this;
      var c = this.getCategoryEl();
      var startPage = '';

      for(var x = 0; x < this.covered.length; x = x + 1) {
        if(self.covered[x].name === c.val()) {
          startPage = self.covered[x].checkerStartFilename;
        }
      }

      if(startPage !== '') {
        moj.log('open prototype');
        self.openScopeChecker(startPage);
      } else {
        moj.log('stay in app');
        self.realSubmit();
      }
    },

    realSubmit: function() {
      $('.fake-submit').hide();
      this.$submit.show().trigger('click');
    }

  };
}());<commit_msg>add welfare to pages covered and direct to housing if immigration selected<commit_after>(function () {
  'use strict';

  moj.Modules.UserTesting = {
    el: '.form-actions',
    pt: '.phase-tag',
    scopeCheckerUrl: 'http://clap-user-testing.dsd.io/',
    covered: [
      {
        name: 'debt',
        checkerStartFilename: 'debt_and_housing.html'
      },
      {
        name: 'discrimination',
        checkerStartFilename: 'discrimination.html'
      },
      {
        name: 'education',
        checkerStartFilename: 'education.html'
      },
      {
        name: 'family',
        checkerStartFilename: 'family.html'
      },
      {
        name: 'housing',
        checkerStartFilename: 'debt_and_housing.html'
      },
      {
        name: 'violence',
        checkerStartFilename: 'domestic_violence.html'
      },
      {
        name: 'immigration',
        checkerStartFilename: 'immigration.html'
      },
      {
        name: 'benefits',
        checkerStartFilename: 'welfare_benefits.html'
      }
    ],

    init: function() {
      if(this.userTestingAvailable()) {
        moj.log('testing available');
        this.cacheEls();
        this.bindEvents();
      }
    },

    cacheEls: function() {
      this.$phaseTag = $(this.pt);
      this.$submit = $(this.el).find('button[type="submit"]');
      this.$form = this.$submit.closest('form');
    },

    bindEvents: function() {
      var self = this;
      this.$phaseTag.on('dblclick', function(e) {
        e.preventDefault();
        self.enable();
      });

      $(document).on('click', '.fake-submit', function(e) {
        e.preventDefault();
        self.fakeSubmit();
      });

      $('input[name="categories"]').on('keypress keydown', function(e) {
        if(e.which === 13) {
          e.preventDefault();
          self.fakeSubmit();
        }
      });
    },

    userTestingAvailable: function() {
      var loc = document.location;
      var isProblemPage = (loc.pathname.indexOf('/problem') !== -1);
      var isDevOrDemo = (loc.hostname.indexOf('localhost') !== -1 || loc.hostname.indexOf('public-demo.cla.dsd.io') !== -1);
      return isDevOrDemo && isProblemPage;
    },

    enable: function() {
      this.$submit
        .hide()
        .before('<button class="button button-larger fake-submit">Continue</button>')
      ;
      this.$phaseTag.siblings('span').html('<strong>User Testing Enabled</strong>');

      moj.log('testing enabled');
    },

    getCategoryEl: function() {
      var $c = $('[name="categories"]:checked');
      return $c;
    },

    openScopeChecker: function(page, category) {
      var self = this;
      this.spawnedWindow = open(this.scopeCheckerUrl + page);
      this.spawnedWindow.focus();

      this.spawnedWindow.onunload = function() {
        self.realSubmit(category);
      };
    },

    fakeSubmit: function() {
      var self = this;
      var c = this.getCategoryEl();
      var startPage = '';

      for(var x = 0; x < this.covered.length; x = x + 1) {
        if(self.covered[x].name === c.val()) {
          startPage = self.covered[x].checkerStartFilename;
        }
      }

      if(startPage !== '') {
        moj.log('open prototype');
        self.openScopeChecker(startPage, c.val());
      } else {
        moj.log('stay in app');
        self.realSubmit();
      }
    },

    realSubmit: function(category) {
      $('.fake-submit').hide();
      if(category && category === 'immigration') { // switch to housing category for means test as immigration goes to face-to-face
        this.$form.find('[name="categories"][value="housing"]').trigger('click');
      }

      this.$submit.show().trigger('click');
    }

  };
}());
{'fraction_non_alphanumeric': 0.16738320435654916, 'fraction_numerical': 0.002006305531670966, 'mean_word_length': 2.165079365079365, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3432494', 'n_tokens_mistral': 2184, 'n_tokens_neox': 2126, 'n_words': 353}