<commit_before>function pusherStart() {
  // Pusher global vars
  var pusher = new Pusher($("meta[name='pusher-key']").attr("content"));
  var listUrl = $(".list").data("url");
  var channel = pusher.subscribe($(".list").data("pusher-channel"));

  // Pusher logger
  Pusher.log = function(message) {
    if (window.console && window.console.log) {
      window.console.log(message);
    }
  };

  // Pusher event bind
  if($(".list").length){
    channel.bind('new_message', function(data) { loadList(); });
    loadList();
  }

  // Ajax load list function
  function loadList(){
    $(".list").load(listUrl, function(){
      if($(".list .list-item").length == 0){
        $(".panel.empty-state").show();
      } else {
        $(".panel.empty-state").hide();
      }
    });
  }
}

$(document).on("ready page:change", function(){
  pusherStart();
})<commit_msg>Pusher.js: Fix TypeError when switching tabs + minor cleanup (Task #356)<commit_after>function pusherStart() {
  // Pusher global vars
  var list = $(".list");
  var pusher = new Pusher($("meta[name='pusher-key']").attr("content"));
  var listUrl = list.data("url");
  var listChannel = list.data("pusher-channel");

  if (typeof listChannel == "undefined") {
    return;
  }

  var channel = pusher.subscribe(listChannel);

  // Pusher event bind
  if(list.length){
    channel.bind('new_message', function(data) {
        loadList();
    });
    loadList();
  }

  // Ajax load list function
  function loadList(){
    $(".list").load(listUrl, function(){
      if($(".list .list-item").length == 0){
        $(".panel.empty-state").show();
      } else {
        $(".panel.empty-state").hide();
      }
    });
  }
}

$(document).on("ready page:change", function(){
  pusherStart();
});
{'fraction_non_alphanumeric': 0.20923603192702395, 'fraction_numerical': 0.0028506271379703536, 'mean_word_length': 3.119718309859155, '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': '3200017', 'n_tokens_mistral': 571, 'n_tokens_neox': 570, 'n_words': 110}