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

  var root = this,
      $ = root.jQuery;
  if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }

  var userSatisfaction = {
    cookieNameTakenSurvey: "govuk_takenUserSatisfactionSurvey",
    setCookieTakenSurvey: function () {
      GOVUK.cookie(userSatisfaction.cookieNameTakenSurvey, true, { days: 30*4 });
      $("#user-satisfaction-survey").removeClass('visible');
    },
    appendCurrentPathToSurveyUrl: function() {
      var takeSurvey = document.getElementById('take-survey');
      var href = takeSurvey.getAttribute('href');
      if (href.indexOf('?c=') === -1) {
        var surveyUrlWithPath = href + "?c=" + root.location.pathname;
        takeSurvey.setAttribute('href', surveyUrlWithPath);
      }
    },
    setEventHandlers: function () {
      var $noThanks = $('#survey-no-thanks');
      var $takeSurvey = $('#take-survey');

      $noThanks.click(function (e) {
        userSatisfaction.setCookieTakenSurvey();
        e.stopPropagation();
        return false;
      });
      $takeSurvey.click(userSatisfaction.setCookieTakenSurvey);
    },
    showSurveyBar: function () {
      if (GOVUK.cookie(userSatisfaction.cookieNameTakenSurvey) === "true" ||
          userSatisfaction.otherNotificationVisible()) {
        return;
      }

      userSatisfaction.setEventHandlers();
      userSatisfaction.appendCurrentPathToSurveyUrl();

      $("#user-satisfaction-survey").addClass('visible');
    },
    otherNotificationVisible: function() {
      return $('#banner-notification:visible, #global-cookie-message:visible, #global-browser-prompt:visible').length > 0;
    },
    randomlyShowSurveyBar: function () {
      if ($('#user-satisfaction-survey').length <= 0) {
        return;
      }
      if (Math.floor(Math.random() * 50) === 0) {
        userSatisfaction.showSurveyBar();
      }
    }
  };

  root.GOVUK.userSatisfaction = userSatisfaction;<commit_msg>Add method to set user satisfaction survey URL<commit_after>(function() {
  "use strict";

  var root = this,
      $ = root.jQuery;
  if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }

  var userSatisfaction = {
    cookieNameTakenSurvey: "govuk_takenUserSatisfactionSurvey",
    setCookieTakenSurvey: function () {
      GOVUK.cookie(userSatisfaction.cookieNameTakenSurvey, true, { days: 30*4 });
      $("#user-satisfaction-survey").removeClass('visible');
    },
    appendCurrentPathToSurveyUrl: function() {
      var takeSurvey = document.getElementById('take-survey');
      var href = takeSurvey.getAttribute('href');
      if (href.indexOf('?c=') === -1) {
        var surveyUrlWithPath = href + "?c=" + root.location.pathname;
        takeSurvey.setAttribute('href', surveyUrlWithPath);
      }
    },
    setEventHandlers: function () {
      var $noThanks = $('#survey-no-thanks');
      var $takeSurvey = $('#take-survey');

      $noThanks.click(function (e) {
        userSatisfaction.setCookieTakenSurvey();
        e.stopPropagation();
        return false;
      });
      $takeSurvey.click(userSatisfaction.setCookieTakenSurvey);
    },
    showSurveyBar: function () {
      if (GOVUK.cookie(userSatisfaction.cookieNameTakenSurvey) === "true" ||
          userSatisfaction.otherNotificationVisible()) {
        return;
      }

      userSatisfaction.setEventHandlers();
      userSatisfaction.appendCurrentPathToSurveyUrl();

      $("#user-satisfaction-survey").addClass('visible');
    },
    otherNotificationVisible: function() {
      return $('#banner-notification:visible, #global-cookie-message:visible, #global-browser-prompt:visible').length > 0;
    },
    randomlyShowSurveyBar: function () {
      if ($('#user-satisfaction-survey').length <= 0) {
        return;
      }
      if (Math.floor(Math.random() * 50) === 0) {
        userSatisfaction.showSurveyBar();
      }
    },
    setSurveyUrl: function(href) {
      var takeSurvey = document.getElementById('take-survey');
      takeSurvey.setAttribute('href', href);
      userSatisfaction.appendCurrentPathToSurveyUrl();
    }
  };

  root.GOVUK.userSatisfaction = userSatisfaction;
{'fraction_non_alphanumeric': 0.1471158507028599, 'fraction_numerical': 0.004362578768783325, 'mean_word_length': 3.250257466529351, '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': '2761351', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1238, 'n_words': 184}