<commit_before>$(document).ready(function() {
  var radios = $('.table-view.radio');
  var saveBtn = $('#save');

  radios.each(function (index) {
    var radio = $(this);
    var buttons = radio.find('li.table-view-cell > a');

    buttons.click(function() {
      buttons.removeClass('active');
      $(this).addClass('active');
    });
  });

  saveBtn.click(function() {
    var object = {};

    radios.each(function (index) {
      var radio = $(this);
      var key   = radio.data('name');
      var value = radio.find('.active').first().data('value');

      if (value) {
        object[key] = value;
      }
    });

    window.location.href = "pebblejs://close#" + encodeURIComponent(JSON.stringify(object));
  });
});
<commit_msg>Add ability to specify defaults through hash<commit_after>$.fn.filterByData = function(prop, val) {
  return this.filter(
    function() { return $(this).data(prop)==val; }
  );
};

$(document).ready(function() {
  var radios = $('.table-view.radio');
  var saveBtn = $('#save');

  var options = {};
  var hash = window.location.hash.substring(1);
  if (hash) {
    try {
      var parsed = JSON.parse(hash);
      options = parsed;
    } catch (e) {
      console.error('Error parsing options: ', hash);
    }
  }

  radios.each(function (index) {
    var radio = $(this);
    var buttons = radio.find('li.table-view-cell > a');

    if (options[radio.data('name')]) {
      var button = buttons.filterByData('value', options[radio.data('name')]);
      button.addClass('active');
    }

    buttons.click(function() {
      buttons.removeClass('active');
      $(this).addClass('active');
    });
  });

  saveBtn.click(function() {
    var object = {};

    radios.each(function (index) {
      var radio = $(this);
      var key   = radio.data('name');
      var value = radio.find('.active').first().data('value');

      if (value) {
        object[key] = value;
      }
    });

    window.location.href = "pebblejs://close#" + encodeURIComponent(JSON.stringify(object));
  });
});

{'fraction_non_alphanumeric': 0.19547021171836534, 'fraction_numerical': 0.0004923682914820286, 'mean_word_length': 2.8631178707224336, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6732784', 'n_tokens_mistral': 652, 'n_tokens_neox': 638, 'n_words': 120}