<commit_before>var supercoolfieldsDelay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  };
})();


function supercoolfieldsEmbedRefresh($input) {
  var $spinner = $input.parent().find('.spinner'),
      $error = $input.parent().find('.error');
  $spinner.removeClass('hidden');
  $error.addClass('hidden');

  var url = $input.val(),
      $target = $input.parent().find('.supercoolfields-embed-preview'),
      request = $.ajax({
        url: '/actions/supercoolFields/embed/get',
        type: 'POST',
        data: { url : url },
        dataType: 'json'
      });

  request.done(function(msg) {
    if ( msg.success ) {
      $target.html(msg.html);
      $spinner.addClass('hidden');
    } else {
      $spinner.addClass('hidden');
      $error.removeClass('hidden');
    }
  });

  request.fail(function(jqXHR, textStatus) {
    $spinner.addClass('hidden');
    $error.removeClass('hidden');
  });

}


$(function(){

  $('.supercoolfields-embed input').on('keyup', function(e){
    var $t = $(this);
    supercoolfieldsDelay(function(){
      supercoolfieldsEmbedRefresh($t);
    }, 1000 );
  });

  $(window).on('load', function(){
<commit_msg>embed: deferred binding of keyup so we catch new matrix blocks etc<commit_after>var supercoolfieldsDelay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  };
})();


function supercoolfieldsEmbedRefresh($input) {
  var $spinner = $input.parent().find('.spinner'),
      $error = $input.parent().find('.error');
  $spinner.removeClass('hidden');
  $error.addClass('hidden');

  var url = $input.val(),
      $target = $input.parent().find('.supercoolfields-embed-preview'),
      request = $.ajax({
        url: '/actions/supercoolFields/embed/get',
        type: 'POST',
        data: { url : url },
        dataType: 'json'
      });

  request.done(function(msg) {
    if ( msg.success ) {
      $target.html(msg.html);
      $spinner.addClass('hidden');
    } else {
      $spinner.addClass('hidden');
      $error.removeClass('hidden');
    }
  });

  request.fail(function(jqXHR, textStatus) {
    $spinner.addClass('hidden');
    $error.removeClass('hidden');
  });

}


$(function(){

  $(document).on('keyup', '.supercoolfields-embed input', function(e){
    var $t = $(this);
    supercoolfieldsDelay(function(){
      supercoolfieldsEmbedRefresh($t);
    }, 1000 );
  });

  $(window).on('load', function(){

{'fraction_non_alphanumeric': 0.19013806706114397, 'fraction_numerical': 0.0039447731755424065, 'mean_word_length': 3.2765598650927488, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6594225', 'n_tokens_mistral': 825, 'n_tokens_neox': 787, 'n_words': 138}