<commit_before>//= require jquery_ujs

var hipster = window.hipster = (function() {
  // CACHES ////////////////////////////////////////////////////////////
  var _isShop = null;
  var _isLoading = true;
  var _runAfterLoad = [];

  // PRIVATE ///////////////////////////////////////////////////////////
  function log(text) {
    if(window.console && window.console.log) {
      window.console.log(text);
    }
  }

  function err(text) {
    if(window.console && window.console.error) {
      window.console.error(text);
    } else {
      alert(text);
    }
  }

  function getCookie(name) {
    name = '_hipsterpizza_' + name + '=';
    var cookies = document.cookie.split(/;\s*/);
    for(var i=0; i< cookies.length; i++) {
      c = cookies[i];
      if(c.indexOf(name) === 0) {
        return unescape(c.substring(name.length, c.length));
      }
    }
    return null;
  }

  function setCookie(name, value) {
    if(!(new RegExp('^[a-z-]+$').test(name))) {
      err('Cookie Name contains invalid characters');
      return;
    }

    var date;
    if(value === null) {
      // i.e. delete the cookie
      date = 'Thu, 01 Jan 1970 00:00:01 GMT';
    } else {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + 365);
      date = exdate.toUTCString();
    }
    var data = escape(value) + "; expires=" + date;
    document.cookie = "_hipsterpizza_" + name + "=" + data;
  }

  function getCurrentAction() {
    return getCookie('action');
  }

  function isShopPage() {
    if(_isShop !== null) return _isShop;

    _isShop = $('body:contains("Warenkorb")').length === 1;
    return _isShop;
  }

  function isLoading() {
    if(!_isLoading) {
      return false;
    }

    _isLoading = $('label:contains("PLZ")').length === 0;
    return _isLoading;
  }

  function getCartItemsJson() {
    var data = [];
    $(".cartitems").each(function(ind, elm) {
      var prod = $(elm).find(".cartitems-title div").text();
      var price = $(elm).find(".cartitems-itemsum .cartitems-sprice div").text();
      price = parseFloat(price.replace(/\s/, "").replace(",", "."));
<commit_msg>correctly encode/decode cookies in JS<commit_after>//= require jquery_ujs

var hipster = window.hipster = (function() {
  // CACHES ////////////////////////////////////////////////////////////
  var _isShop = null;
  var _isLoading = true;
  var _runAfterLoad = [];

  // PRIVATE ///////////////////////////////////////////////////////////
  function log(text) {
    if(window.console && window.console.log) {
      window.console.log(text);
    }
  }

  function err(text) {
    if(window.console && window.console.error) {
      window.console.error(text);
    } else {
      alert(text);
    }
  }

  function getCookie(name) {
    name = '_hipsterpizza_' + name + '=';
    var cookies = document.cookie.split(/;\s*/);
    for(var i=0; i< cookies.length; i++) {
      c = cookies[i];
      if(c.indexOf(name) === 0) {
        return decodeURIComponent(c.substring(name.length, c.length));
      }
    }
    return null;
  }

  function setCookie(name, value) {
    if(!(new RegExp('^[a-z-]+$').test(name))) {
      err('Cookie Name contains invalid characters');
      return;
    }

    var date;
    if(value === null) {
      // i.e. delete the cookie
      date = 'Thu, 01 Jan 1970 00:00:01 GMT';
    } else {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + 365);
      date = exdate.toUTCString();
    }
    var data = encodeURIComponent(value) + "; expires=" + date;
    document.cookie = "_hipsterpizza_" + name + "=" + data;
  }

  function getCurrentAction() {
    return getCookie('action');
  }

  function isShopPage() {
    if(_isShop !== null) return _isShop;

    _isShop = $('body:contains("Warenkorb")').length === 1;
    return _isShop;
  }

  function isLoading() {
    if(!_isLoading) {
      return false;
    }

    _isLoading = $('label:contains("PLZ")').length === 0;
    return _isLoading;
  }

  function getCartItemsJson() {
    var data = [];
    $(".cartitems").each(function(ind, elm) {
      var prod = $(elm).find(".cartitems-title div").text();
      var price = $(elm).find(".cartitems-itemsum .cartitems-sprice div").text();
      price = parseFloat(price.replace(/\s/, "").replace(",", "."));

{'fraction_non_alphanumeric': 0.22162288930581614, 'fraction_numerical': 0.008911819887429643, 'mean_word_length': 2.1733630952380953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6623634', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1354, 'n_words': 280}