<commit_before>(function() {
  $(function() {
    var chords = {};
    var canvas = $("#canvas-chord");
    var width = canvas.width(), height = canvas.height(), r = height / 2 - 50;

    var calculateCoordinates = function(nodeId) {
      var bytes = _(Math.floor(_.size(nodeId) / 2)).times(function(i) {
        return parseInt(nodeId.substr(i * 2, 2), 16);
      });
      var ratio = _.chain(bytes)
        .map(function(b) { return b / 0xff;})
        .reduceRight(function(a, b) { return (a >> 8) + b; }, 0)
        .value();
      var radian = ratio * 2 * Math.PI;
      return {
        x: width / 2 - r * Math.cos(radian),
        y: height / 2 - r * Math.sin(radian)
      };
    };

    var peerIdToShow = null;
    var updateChordGraph = function() {
      var ctx = canvas[0].getContext('2d');
      ctx.clearRect(0, 0, width, height);
      ctx.beginPath();
      ctx.arc(width / 2, height / 2, r, 0, 2 * Math.PI);
      ctx.strokeStyle = 'gray';
      ctx.stroke();

      _.each(chords, function(chord) {
        ctx.beginPath();
        var coord = calculateCoordinates(chord.getNodeId());
        ctx.arc(coord.x, coord.y, 5, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.fillStyle = 'red';
        ctx.fill();

        if (!_.isNull(peerIdToShow) && chord.getPeerId() !== peerIdToShow) {
          return;
        }

        var strokeQuadraticCurve = function(toNode, rOffset, color) {
          var _coord = calculateCoordinates(toNode.nodeId);
          var radian = Math.atan2((_coord.y + coord.y) / 2 - height / 2,
                                  (_coord.x + coord.x) / 2 - width / 2);
          ctx.beginPath();
          ctx.moveTo(coord.x, coord.y);
          ctx.quadraticCurveTo(width / 2 + (r + rOffset) * Math.cos(radian),
                               height / 2 + (r + rOffset) * Math.sin(radian),
                               _coord.x, _coord.y);
          ctx.strokeStyle = color;
          ctx.stroke();
        };

        var statuses = chord.getStatuses();

        if ($("#checkbox-show-successors").prop('checked')) {
          _.each(statuses.successors, function(successor) {
            strokeQuadraticCurve(successor, 50, 'blue');
          });
        }

        if ($("#checkbox-show-predecessor").prop('checked')) {<commit_msg>Improved chord graph to use arrow for representing successors and predecessor associations.<commit_after>(function() {
  $(function() {
    var chords = {};
    var canvas = $("#canvas-chord");
    var width = canvas.width(), height = canvas.height(), r = height / 2 - 50;
    var center = {x: width / 2, y: height / 2};

    var calculateCoordinates = function(nodeId) {
      var bytes = _(Math.floor(_.size(nodeId) / 2)).times(function(i) {
        return parseInt(nodeId.substr(i * 2, 2), 16);
      });
      var ratio = _.chain(bytes)
        .map(function(b) { return b / 0xff;})
        .reduceRight(function(a, b) { return (a >> 8) + b; }, 0)
        .value();
      var radian = ratio * 2 * Math.PI;
      return {
        x: center.x - r * Math.cos(radian),
        y: center.y - r * Math.sin(radian)
      };
    };

    var peerIdToShow = null;
    var updateChordGraph = function() {
      var ctx = canvas[0].getContext('2d');
      ctx.clearRect(0, 0, width, height);
      ctx.beginPath();
      ctx.arc(center.x, center.y, r, 0, 2 * Math.PI);
      ctx.strokeStyle = 'gray';
      ctx.stroke();

      _.each(chords, function(chord) {
        ctx.beginPath();
        var coord = calculateCoordinates(chord.getNodeId());
        ctx.arc(coord.x, coord.y, 5, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.fillStyle = 'red';
        ctx.fill();

        if (!_.isNull(peerIdToShow) && chord.getPeerId() !== peerIdToShow) {
          return;
        }

        var strokeQuadraticCurve = function(toNode, rOffset, color) {
          var _coord = calculateCoordinates(toNode.nodeId);
          var radian = Math.atan2((_coord.y + coord.y) / 2 - center.y,
                                  (_coord.x + coord.x) / 2 - center.x);
          ctx.beginPath();
          ctx.moveTo(coord.x, coord.y);
          var cpx = center.x + (r + rOffset) * Math.cos(radian);
          var cpy = center.y + (r + rOffset) * Math.sin(radian);
          ctx.quadraticCurveTo(cpx, cpy, _coord.x, _coord.y);
          ctx.strokeStyle = color;
          ctx.stroke();

          ctx.beginPath();
          ctx.moveTo(_coord.x, _coord.y);
          var radian = Math.atan2(cpy - _coord.y,
                                  cpx - _coord.x);
          ctx.lineTo(_coord.x + 10 * Math.cos(radian - Math.PI / 6),
                     _coord.y + 10 * Math.sin(radian - Math.PI / 6));
          ctx.lineTo(_coord.x + 10 * Math.cos(radian + Math.PI / 6),
                     _coord.y + 10 * Math.sin(radian + Math.PI / 6));
          ctx.closePath();
          ctx.fillStyle = color;
          ctx.fill();
        };

        var statuses = chord.getStatuses();

        if ($("#checkbox-show-successors").prop('checked')) {
          _.each(statuses.successors, function(successor) {
            strokeQuadraticCurve(successor, 50, 'blue');
          });
        }

        if ($("#checkbox-show-predecessor").prop('checked')) {
{'fraction_non_alphanumeric': 0.15913895829329233, 'fraction_numerical': 0.014414760714972132, 'mean_word_length': 1.8719646799116998, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4641316', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1657, 'n_words': 360}