<commit_before>$(function () {
  $("#start-towtruck").click(TowTruck);
  randomize();
});

function cell(row, col) {
  return $("#cell-" + row + "-" + col);
}

function randomColor() {
  return "#" + Math.floor(0x1000000 + Math.random() * 0xffffff).toString(16).substr(1);
}

function randomize() {
  for (var row=1; row<6; row++) {
    for (var col=1; col<6; col++) {
      var c = cell(row, col);
      c.css({"background-color": randomColor()});
    }
  }
}

$(document).on("click", "#flips td", function () {
  var el = $(this);
  var color = randomColor();
  el.css({"background-color": color});
  if (TowTruck.running) {
    TowTruck.send({type: "flip-color", id: el.attr("id"), color: color});
  }
});

TowTruck.hub.on("flip-color", function (msg) {
  $("#" + msg.id).css({"background-color": msg.color});
});
<commit_msg>Initialize colors, and fix message registration<commit_after>$(function () {
  $("#start-towtruck").click(TowTruck);
  randomize();
});

function cell(row, col) {
  return $("#cell-" + row + "-" + col);
}

function randomColor() {
  return "#" + Math.floor(0x1000000 + Math.random() * 0xffffff).toString(16).substr(1);
}

function randomize() {
  for (var row=1; row<6; row++) {
    for (var col=1; col<6; col++) {
      var c = cell(row, col);
      c.css({"background-color": randomColor()});
    }
  }
}

$(document).on("click", "#flips td", function () {
  var el = $(this);
  var color = randomColor();
  el.css({"background-color": color});
  if (TowTruck.running) {
    TowTruck.send({type: "flip-color", id: el.attr("id"), color: color});
  }
});

var TowTruckConfig_hub_on = {
  "flip-color": function (msg) {
    $("#" + msg.id).css({"background-color": msg.color});
  },
  "towtruck.hello": function (msg) {
    var colors = [];
    $("td").each(function () {
      var el = $(this);
      colors.push({id: el.attr("id"), color: el.css("background-color")});
    });
    TowTruck.send({type: "init", colors: colors});
  },
  "init": function (msg) {
    msg.colors.forEach(function (c) {
      $("#" + c.id).css({"background-color": c.color});
    });
  }
};

{'fraction_non_alphanumeric': 0.23820867079561697, 'fraction_numerical': 0.015245354930919485, 'mean_word_length': 3.6255506607929515, 'pattern_counts': {'":': 10, '<': 7, '<?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': '2031343', 'n_tokens_mistral': 799, 'n_tokens_neox': 775, 'n_words': 149}