<commit_before>$(document).ready(function() {

  setStyleSheet(getCookie("govuk-accessibility"));
  $(".customisation-settings").attr("title", "The settings link will open an overlay panel when clicked");
  $(document).keydown( function(e) {
    if (e.keyCode == 27) {
      $("#popup").slideUp('fast').remove();
      $("#mask").fadeOut('fast').remove();
    }
  });

 // Event handlers
  $('.customisation-settings').click(function(e) {
    if ($("#mask").length > 0) {
      e.preventDefault();
      return false;
    }

    $(document).trigger('customisation-opened');
    //BetaPopup.popup(, "customisation-tools");

    $("body").prepend("<div id='mask'></div>");
    $("body").prepend("<div id='popup' class='customisation-tools'></div>");

    $.get('/settings.raw', function(data){
      $('#popup').html(data).prepend("<p class='close'><a href='#' title='Click or press escape to close the settings panel'>Close</a></a>");
    });

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

     //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
    $('#mask').fadeTo("fast",0.6);

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $("#popup").css('left', winW/2-$("#popup").width()/2);

    $("#popup").delay(100).fadeIn('fast', function(){
      $(".customisation-tools h2").attr("tabindex",-1).focus();
      // if we get outside the lightbox, trap the focus and send it back
    /*  $("#popup").live('blur', function(){
        $(".customisation-tools h2").attr("tabindex",-1).focus();
      })*/
      if(getCookie("govuk-accessibility") == "wordsdifficult"){
        $('input[name=acc-options]:eq(1)').attr('checked', 'checked');
      }
      else{
        $('input[name=acc-options]:eq(0)').attr('checked', 'checked');
      }
    });



    $(".customisation-tools .close").live('click', function(e){
      e.preventDefault();
      $("#popup").unbind('blur');
      $("#popup").slideUp('fast').remove();
      $("#mask").fadeOut('fast').remove();
      $(".customisation-settings").focus();
      // $("#global-locator-box").hide();
    });


    $('.personalise-options').live("submit", function(){

      var id = $('input[name=acc-options]:checked').val();
      _gaq.push(['_trackEvent', 'Citizen-Accessibility', $(this).attr("id")]);
      if(getCookie("govuk-accessibility")){
        deleteCookie("govuk-accessibility");
      }
      setCookie("govuk-accessibility",id,1);
      setStyleSheet(id);
    return false;
    });

    e.preventDefault();

  });


  function setStyleSheet(match){
    if(match == "core"){
      deleteCookie("govuk-accessibility");
      $(".wordsdifficult").attr("rel", "alternate stylesheet");
      $(".wordsdifficult").attr('disabled', 'disabled');
      $('input[name=acc-options]:eq(0)').attr('checked', 'checked');
    }
    else if(match == "wordsdifficult"){
      $(".wordsdifficult").attr("rel", "stylesheet");
      $(".wordsdifficult").removeAttr('disabled');
      $('input[name=acc-options]:eq(1)').attr('checked', 'checked');
    }
  }

  function setCookie(name,value,days) {
    var expires;
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      expires = "; expires="+date.toGMTString();
    } else {
      expires = "";<commit_msg>Set accessibility cookie for 4 months.<commit_after>$(document).ready(function() {

  setStyleSheet(getCookie("govuk-accessibility"));
  $(".customisation-settings").attr("title", "The settings link will open an overlay panel when clicked");
  $(document).keydown( function(e) {
    if (e.keyCode == 27) {
      $("#popup").slideUp('fast').remove();
      $("#mask").fadeOut('fast').remove();
    }
  });

 // Event handlers
  $('.customisation-settings').click(function(e) {
    if ($("#mask").length > 0) {
      e.preventDefault();
      return false;
    }

    $(document).trigger('customisation-opened');
    //BetaPopup.popup(, "customisation-tools");

    $("body").prepend("<div id='mask'></div>");
    $("body").prepend("<div id='popup' class='customisation-tools'></div>");

    $.get('/settings.raw', function(data){
      $('#popup').html(data).prepend("<p class='close'><a href='#' title='Click or press escape to close the settings panel'>Close</a></a>");
    });

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

     //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
    $('#mask').fadeTo("fast",0.6);

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center
    $("#popup").css('left', winW/2-$("#popup").width()/2);

    $("#popup").delay(100).fadeIn('fast', function(){
      $(".customisation-tools h2").attr("tabindex",-1).focus();
      // if we get outside the lightbox, trap the focus and send it back
    /*  $("#popup").live('blur', function(){
        $(".customisation-tools h2").attr("tabindex",-1).focus();
      })*/
      if(getCookie("govuk-accessibility") == "wordsdifficult"){
        $('input[name=acc-options]:eq(1)').attr('checked', 'checked');
      }
      else{
        $('input[name=acc-options]:eq(0)').attr('checked', 'checked');
      }
    });



    $(".customisation-tools .close").live('click', function(e){
      e.preventDefault();
      $("#popup").unbind('blur');
      $("#popup").slideUp('fast').remove();
      $("#mask").fadeOut('fast').remove();
      $(".customisation-settings").focus();
      // $("#global-locator-box").hide();
    });


    $('.personalise-options').live("submit", function(){

      var id = $('input[name=acc-options]:checked').val();
      _gaq.push(['_trackEvent', 'Citizen-Accessibility', $(this).attr("id")]);
      if(getCookie("govuk-accessibility")){
        deleteCookie("govuk-accessibility");
      }
      setCookie("govuk-accessibility", id, 4 * 30);
      setStyleSheet(id);
    return false;
    });

    e.preventDefault();

  });


  function setStyleSheet(match){
    if(match == "core"){
      deleteCookie("govuk-accessibility");
      $(".wordsdifficult").attr("rel", "alternate stylesheet");
      $(".wordsdifficult").attr('disabled', 'disabled');
      $('input[name=acc-options]:eq(0)').attr('checked', 'checked');
    }
    else if(match == "wordsdifficult"){
      $(".wordsdifficult").attr("rel", "stylesheet");
      $(".wordsdifficult").removeAttr('disabled');
      $('input[name=acc-options]:eq(1)').attr('checked', 'checked');
    }
  }

  function setCookie(name,value,days) {
    var expires;
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      expires = "; expires="+date.toGMTString();
    } else {
      expires = "";
{'fraction_non_alphanumeric': 0.22976054732041049, 'fraction_numerical': 0.008694412770809578, 'mean_word_length': 3.455238095238095, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '668162', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2161, 'n_words': 376}