<commit_before>FRTool.initFR(FRData);
var DEFAULT_FONT = "14pt cursive";
var DEFAULT_BACKGROUND = "transparent";
var DEFAULT_NAME_FONT = "24pt cursive";
var defaultAge = FRTool.Age["Modern"].Name;

function getRandomNumber(range) {
  return range[Math.floor(Math.random() * range.length)];
}

function getImgUrl(dragonID, isLeft) {
  if (dragonID == "") {
    if (isLeft) {
      dragonID = getRandomNumber([1, 6, 7, 8, 9, 11]);
    } else {
      dragonID = getRandomNumber([2, 3, 4, 5, 10]);
    }
  }
  var dragonID = parseInt(dragonID);
  var miniDragonId = Math.ceil(dragonID / 100);
  if (dragonID % 100 == 0) {
    miniDragonId += 1;
  }
  return 'http://flightrising.com/rendern/350/' + miniDragonId + '/' + dragonID + '_350.png'
}

function ageChangeInit() {
  defaultAge = $('#age').val();
  if (defaultAge == undefined || defaultAge == "") {
    defaultAge = FRTool.Age["Modern"].Name;
  }
  initGeneSelect('o_Primary_gene', 'Primary', defaultAge);
  initGeneSelect('a_Primary_gene', 'Primary', defaultAge);
  initGeneSelect('o_Secondary_gene', 'Secondary', defaultAge);
  initGeneSelect('a_Secondary_gene', 'Secondary', defaultAge);
  initGeneSelect('o_Tertiary_gene', 'Tertiary', defaultAge);
  initGeneSelect('a_Tertiary_gene', 'Tertiary', defaultAge);
  initBreedSelect('o_breed', defaultAge);
  initBreedSelect('a_breed', defaultAge);
  localize(language_code);
}

function initGeneSelect(id, type, age) {
  $('#' + id).html("");
  for (var i = 0; i < FRTool.Oddss.length; i++) {
    var genes = FRTool.getGene(FRTool.Oddss[i], type, age);
    var group = $("<optgroup></optgroup>")
      .attr("data-localize", FRTool.Oddss[i].Name)
      .attr("label", FRTool.Oddss[i].Name);
    for (var j = 0; j < genes.length; j++) {
      group.append($("<option></option>")
        .attr("data-localize", genes[j].Name)
        .attr("value", genes[j].Name)
        .text(genes[j].Name));
    };
    $('#' + id).append(group);
  };
}

function initColorSelect(id) {
  for (var i = 0; i < FRTool.Colors.length; i++) {
    $('#' + id).append(
      $("<option></option>")
      .attr("data-localize", FRTool.Colors[i].Name)
      .attr("class", FRTool.Colors[i].Name)
      .attr("value", FRTool.Colors[i].Name)
      .text(FRTool.Colors[i].Name)
    );
  }
}

function initBreedSelect(id, age) {
  $('#' + id).html("");
  for (var i = 0; i < FRTool.Oddss.length; i++) {
    var breeds = FRTool.getBreed(FRTool.Oddss[i], age);
    var group = $("<optgroup></optgroup>")
      .attr("data-localize", FRTool.Oddss[i].Name)
      .attr("label", FRTool.Oddss[i].Name);
    for (var j = 0; j < breeds.length; j++) {
      group.append($("<option></option>")
        .attr("data-localize", breeds[j].Name)
        .attr("value", breeds[j].Name)
        .text(breeds[j].Name));
    };
    if (breeds.length > 0) {
      $('#' + id).append(group);
    }
  };
}

function initAgeSelect(id) {
  var name = FRTool.Age["Modern"].Name;
  $('#' + id).append(
    $("<option></option>")
    .attr("data-localize", name)
    .attr("class", name)
    .attr("value", name)
    .text(name)
  );
  name = FRTool.Age["Ancient"].Name;
  var group = $("<optgroup></optgroup>")
    .attr("data-localize", name)
    .attr("label", name);
  var breeds = FRTool.AncientBreeds;
  for (var j = 0; j < breeds.length; j++) {
    group.append($("<option></option>")
      .attr("data-localize", breeds[j].Name)
      .attr("value", breeds[j].Name)
      .text(breeds[j].Name));
  };
  if (breeds.length > 0) {
    $('#' + id).append(group);
  }
}

function UpdateColorClass(colorSelect) {
  colorSelect.removeClass();
  colorSelect.addClass("form-control");
  colorSelect.addClass(colorSelect.val());
}

function drawName(canvasContext, text, x, y, font, textAlign, color, shadowcolor) {
  canvasContext.font = font || DEFAULT_NAME_FONT;
  canvasContext.textAlign = textAlign
  canvasContext.shadowOffsetX = 2;
  canvasContext.shadowOffsetY = 2;
  canvasContext.shadowBlur = 2;
  canvasContext.shadowColor = shadowcolor;
  canvasContext.fillStyle = color;
  canvasContext.fillText(text, x, y);
}

function drawImage(canvasContext, src, x, y, width, height, flip, callback) {
  if (src) {
    var img = new Image();
    img.src = src;

    img.onload = function() {
      if (flip) {
        img.crossOrigin = "Anonymous";
        canvasContext.scale(-1, 1);
        canvasContext.drawImage(img, -x - width, y, width, height);
        canvasContext.scale(-1, 1);
      } else {
        canvasContext.drawImage(img, x, y, width, height);
      }
      callback();
    }
  }
}

function drawColorRange(canvasContext, range, lineColor, y) {
  var single = 10;
  var width;
  do {
    single -= 1;
    width = range.length * (single + 1);
  } while (width > 200);
  var startX = 320 - width / 2;
  for (var i = 0; i < range.length; i++) {
    canvasContext.lineWidth = "2";
    canvasContext.strokeStyle = lineColor;
    canvasContext.lineCap = "square";
    canvasContext.beginPath();
    canvasContext.rect(startX, y, single, 20);
    canvasContext.stroke();

    canvasContext.fillStyle = range[i].Color;
    canvasContext.fillRect(startX, y, single, 20);
    startX += single + 1;
  }
}

function drawGene(canvasContext, font, gene1, gene2, color, leftcolor, rightcolor, y) {
  var width = 80;
  var imgWidth = 640;
  canvasContext.font = font || DEFAULT_FONT;
  if (gene1 == gene2) {
    canvasContext.textAlign = "center";
    canvasContext.fillStyle = color;
    canvasContext.fillText(gene1.Name.replace("-Gene",""), imgWidth / 2, y);
    canvasContext.fillRect((imgWidth - width) / 2, y + 4, width, 3);
  } else {
    var rate = FRTool.getGeneRate(gene1, gene2);
    canvasContext.textAlign = "end";
    canvasContext.fillStyle = leftcolor;
    canvasContext.fillText(gene1.Name, imgWidth / 2 - 6, y);
    canvasContext.fillRect(imgWidth / 2 - width - 1, y + 4, width * 2 * rate[0], 3);
    canvasContext.textAlign = "start";
    canvasContext.fillStyle = rightcolor;
    canvasContext.fillText(gene2.Name.replace("-Gene",""), imgWidth / 2 + 6, y);
    canvasContext.fillRect(imgWidth / 2 - width + 1 + width * 2 * rate[0], y + 4, width * 2 * rate[1], 3);
  }
}

function drawBreed(canvasContext, font, breed1, breed2, color, leftcolor, rightcolor, y) {
  var width = 80;
  var imgWidth = 640;
  canvasContext.font = font || DEFAULT_FONT;
  if (breed1 == breed2) {
    canvasContext.textAlign = "center";
    canvasContext.fillStyle = color;
    canvasContext.fillText(breed1.Name, imgWidth / 2, y);
    canvasContext.fillRect((imgWidth - width) / 2, y + 4, width, 3);
  } else {
    var rate = FRTool.getBreedRate(breed1, breed2);
    canvasContext.textAlign = "end";
    canvasContext.fillStyle = leftcolor;
    canvasContext.fillText(breed1.Name, imgWidth / 2 - 6, y);
    canvasContext.fillRect(imgWidth / 2 - width - 1, y + 4, width * 2 * rate[0], 3);
    canvasContext.textAlign = "start";
    canvasContext.fillStyle = rightcolor;
    canvasContext.fillText(breed2.Name, imgWidth / 2 + 6, y);
    canvasContext.fillRect(imgWidth / 2 - width + 1 + width * 2 * rate[0], y + 4, width * 2 * rate[1], 3);
  }
}
<commit_msg>Update card.js<commit_after>FRTool.initFR(FRData);
var DEFAULT_FONT = "14pt cursive";
var DEFAULT_BACKGROUND = "transparent";
var DEFAULT_NAME_FONT = "24pt cursive";
var defaultAge = FRTool.Age["Modern"].Name;

function getRandomNumber(range) {
  return range[Math.floor(Math.random() * range.length)];
}

function getImgUrl(dragonID, isLeft) {
  if (dragonID == "") {
    if (isLeft) {
      dragonID = getRandomNumber([1, 6, 7, 8, 9, 11]);
    } else {
      dragonID = getRandomNumber([2, 3, 4, 5, 10]);
    }
  }
  var dragonID = parseInt(dragonID);
  var miniDragonId = Math.ceil(dragonID / 100);
  if (dragonID % 100 == 0) {
    miniDragonId += 1;
  }
  return 'http://flightrising.com/rendern/350/' + miniDragonId + '/' + dragonID + '_350.png'
}

function ageChangeInit() {
  defaultAge = $('#age').val();
  if (defaultAge == undefined || defaultAge == "") {
    defaultAge = FRTool.Age["Modern"].Name;
  }
  initGeneSelect('o_Primary_gene', 'Primary', defaultAge);
  initGeneSelect('a_Primary_gene', 'Primary', defaultAge);
  initGeneSelect('o_Secondary_gene', 'Secondary', defaultAge);
  initGeneSelect('a_Secondary_gene', 'Secondary', defaultAge);
  initGeneSelect('o_Tertiary_gene', 'Tertiary', defaultAge);
  initGeneSelect('a_Tertiary_gene', 'Tertiary', defaultAge);
  initBreedSelect('o_breed', defaultAge);
  initBreedSelect('a_breed', defaultAge);
  localize(language_code);
}

function initGeneSelect(id, type, age) {
  $('#' + id).html("");
  for (var i = 0; i < FRTool.Oddss.length; i++) {
    var genes = FRTool.getGene(FRTool.Oddss[i], type, age);
    var group = $("<optgroup></optgroup>")
      .attr("data-localize", FRTool.Oddss[i].Name)
      .attr("label", FRTool.Oddss[i].Name);
    for (var j = 0; j < genes.length; j++) {
      group.append($("<option></option>")
        .attr("data-localize", genes[j].Name)
        .attr("value", genes[j].Name)
        .text(genes[j].Name));
    };
    $('#' + id).append(group);
  };
}

function initColorSelect(id) {
  for (var i = 0; i < FRTool.Colors.length; i++) {
    $('#' + id).append(
      $("<option></option>")
      .attr("data-localize", FRTool.Colors[i].Name)
      .attr("class", FRTool.Colors[i].Name)
      .attr("value", FRTool.Colors[i].Name)
      .text(FRTool.Colors[i].Name)
    );
  }
}

function initBreedSelect(id, age) {
  $('#' + id).html("");
  for (var i = 0; i < FRTool.Oddss.length; i++) {
    var breeds = FRTool.getBreed(FRTool.Oddss[i], age);
    var group = $("<optgroup></optgroup>")
      .attr("data-localize", FRTool.Oddss[i].Name)
      .attr("label", FRTool.Oddss[i].Name);
    for (var j = 0; j < breeds.length; j++) {
      group.append($("<option></option>")
        .attr("data-localize", breeds[j].Name)
        .attr("value", breeds[j].Name)
        .text(breeds[j].Name));
    };
    if (breeds.length > 0) {
      $('#' + id).append(group);
    }
  };
}

function initAgeSelect(id) {
  var name = FRTool.Age["Modern"].Name;
  $('#' + id).append(
    $("<option></option>")
    .attr("data-localize", name)
    .attr("class", name)
    .attr("value", name)
    .text(name)
  );
  name = FRTool.Age["Ancient"].Name;
  var group = $("<optgroup></optgroup>")
    .attr("data-localize", name)
    .attr("label", name);
  var breeds = FRTool.AncientBreeds;
  for (var j = 0; j < breeds.length; j++) {
    group.append($("<option></option>")
      .attr("data-localize", breeds[j].Name)
      .attr("value", breeds[j].Name)
      .text(breeds[j].Name));
  };
  if (breeds.length > 0) {
    $('#' + id).append(group);
  }
}

function UpdateColorClass(colorSelect) {
  colorSelect.removeClass();
  colorSelect.addClass("form-control");
  colorSelect.addClass(colorSelect.val());
}

function drawName(canvasContext, text, x, y, font, textAlign, color, shadowcolor) {
  canvasContext.font = font || DEFAULT_NAME_FONT;
  canvasContext.textAlign = textAlign
  canvasContext.shadowOffsetX = 2;
  canvasContext.shadowOffsetY = 2;
  canvasContext.shadowBlur = 2;
  canvasContext.shadowColor = shadowcolor;
  canvasContext.fillStyle = color;
  canvasContext.fillText(text, x, y);
}

function drawImage(canvasContext, src, x, y, width, height, flip, callback) {
  if (src) {
    var img = new Image();
    img.src = src;

    img.onload = function() {
      if (flip) {
        img.crossOrigin = "Anonymous";
        canvasContext.scale(-1, 1);
        canvasContext.drawImage(img, -x - width, y, width, height);
        canvasContext.scale(-1, 1);
      } else {
        canvasContext.drawImage(img, x, y, width, height);
      }
      callback();
    }
  }
}

function drawColorRange(canvasContext, range, lineColor, y) {
  var single = 10;
  var width;
  do {
    single -= 1;
    width = range.length * (single + 1);
  } while (width > 200);
  var startX = 320 - width / 2;
  for (var i = 0; i < range.length; i++) {
    canvasContext.lineWidth = "2";
    canvasContext.strokeStyle = lineColor;
    canvasContext.lineCap = "square";
    canvasContext.beginPath();
    canvasContext.rect(startX, y, single, 20);
    canvasContext.stroke();

    canvasContext.fillStyle = range[i].Color;
    canvasContext.fillRect(startX, y, single, 20);
    startX += single + 1;
  }
}

function drawGene(canvasContext, font, gene1, gene2, color, leftcolor, rightcolor, y) {
  var width = 80;
  var imgWidth = 640;
  canvasContext.font = font || DEFAULT_FONT;
  if (gene1 == gene2) {
    canvasContext.textAlign = "center";
    canvasContext.fillStyle = color;
    canvasContext.fillText(gene1.Name.replace("-Gene",""), imgWidth / 2, y);
    canvasContext.fillRect((imgWidth - width) / 2, y + 4, width, 3);
  } else {
    var rate = FRTool.getGeneRate(gene1, gene2);
    canvasContext.textAlign = "end";
    canvasContext.fillStyle = leftcolor;
    canvasContext.fillText(gene1.Name.replace("-Gene",""), imgWidth / 2 - 6, y);
    canvasContext.fillRect(imgWidth / 2 - width - 1, y + 4, width * 2 * rate[0], 3);
    canvasContext.textAlign = "start";
    canvasContext.fillStyle = rightcolor;
    canvasContext.fillText(gene2.Name.replace("-Gene",""), imgWidth / 2 + 6, y);
    canvasContext.fillRect(imgWidth / 2 - width + 1 + width * 2 * rate[0], y + 4, width * 2 * rate[1], 3);
  }
}

function drawBreed(canvasContext, font, breed1, breed2, color, leftcolor, rightcolor, y) {
  var width = 80;
  var imgWidth = 640;
  canvasContext.font = font || DEFAULT_FONT;
  if (breed1 == breed2) {
    canvasContext.textAlign = "center";
    canvasContext.fillStyle = color;
    canvasContext.fillText(breed1.Name, imgWidth / 2, y);
    canvasContext.fillRect((imgWidth - width) / 2, y + 4, width, 3);
  } else {
    var rate = FRTool.getBreedRate(breed1, breed2);
    canvasContext.textAlign = "end";
    canvasContext.fillStyle = leftcolor;
    canvasContext.fillText(breed1.Name, imgWidth / 2 - 6, y);
    canvasContext.fillRect(imgWidth / 2 - width - 1, y + 4, width * 2 * rate[0], 3);
    canvasContext.textAlign = "start";
    canvasContext.fillStyle = rightcolor;
    canvasContext.fillText(breed2.Name, imgWidth / 2 + 6, y);
    canvasContext.fillRect(imgWidth / 2 - width + 1 + width * 2 * rate[0], y + 4, width * 2 * rate[1], 3);
  }
}

{'fraction_non_alphanumeric': 0.17448154657293496, 'fraction_numerical': 0.019121265377855887, 'mean_word_length': 3.419384902143523, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 41, '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': '1291039', 'n_tokens_mistral': 5279, 'n_tokens_neox': 5011, 'n_words': 1039}