<commit_before>function CharacterPage(utils) {
  this.utils = utils;
  this.must_be_online = false; // Will be set if online is displayed on the page
  this.elements = {};
}

/**
 * Retrieves and stores information from the character.
 */
CharacterPage.prototype.parse = function(callback) {
  var self = this;
  var characters_div = document.getElementById('characters');
  if (characters_div === null) {
    return callback('Characters div not found');
  }
  self.elements.characters_div = characters_div;

  var character_tables = characters_div.getElementsByTagName('table');
  var parsed_character_information = false;
  var parsed_characters = false;

  for (var i = 0, j = character_tables.length; i < j; i++) {
    if (!parsed_character_information && /Character Information/.test(character_tables[i].innerHTML)) {
      if (!self.parseCharacterInformation(character_tables[i])) {
        return callback('Failed to parse character information');
      }
      parsed_character_information = true;
    } else if (!parsed_characters && /Characters/.test(character_tables[i].innerHTML)) {
      self.parseCharacters(character_tables[i]);
      parsed_characters = true;
    }
  }

  if (!parsed_character_information) {
    return callback('No character information found');
  }
  return callback(null);
};

/**
 * Retrieves and stores information from the character information table.
 * Used internally by #parse.
 * @return False if something isn't found or is bad.
 */
CharacterPage.prototype.parseCharacterInformation = function(table) {
  var self = this;
  var rows = table.getElementsByTagName('tr');

  var name_found = false;
  var vocation_found = false;
  var level_found = false;
  var world_found = false;

  for (var i = 0, j = rows.length; i < j; i++) {
    var columns = rows[i].getElementsByTagName('td');

    if (columns.length === 2) {
      var row_name = columns[0].innerHTML;
      var row_value = columns[1].textContent.trim();
      if (!name_found && row_name === 'Name:') {
        self.elements.name_column = columns[1];
        self.name = row_value;
        name_found = true;
      } else if (!vocation_found && row_name === 'Vocation:') {
        self.elements.vocation_column = columns[1];
        self.vocation = row_value;
        vocation_found = true;
      } else if (!level_found && row_name === 'Level:') {
        self.elements.level_column = columns[1];
        self.level = parseInt(row_value, 10);
        level_found = true;
      } else if (!world_found && row_name === 'World:') {
        self.world = row_value;
        world_found = true;
      }
    }
  }

  return !isNaN(self.level) && self.utils.isVocation(self.vocation) && name_found && vocation_found && level_found && world_found;
};

/**<commit_msg>Fix issue when logged in<commit_after>function CharacterPage(utils) {
  this.utils = utils;
  this.must_be_online = false; // Will be set if online is displayed on the page
  this.elements = {};
}

/**
 * Retrieves and stores information from the character.
 */
CharacterPage.prototype.parse = function(callback) {
  var self = this;
  var characters_div = document.getElementById('characters');
  if (characters_div === null) {
    return callback('Characters div not found');
  }
  self.elements.characters_div = characters_div;

  var character_tables = characters_div.getElementsByTagName('table');
  var parsed_character_information = false;
  var parsed_characters = false;

  for (var i = 0, j = character_tables.length; i < j; i++) {
    if (!parsed_character_information && /Character Information/.test(character_tables[i].innerHTML)) {
      if (!self.parseCharacterInformation(character_tables[i])) {
        return callback('Failed to parse character information. Name:' + self.name + ', Vocation:' + self.vocation + ', Level:' + self.level + ', World:' + self.world);
      }
      parsed_character_information = true;
    } else if (!parsed_characters && /Characters/.test(character_tables[i].innerHTML)) {
      self.parseCharacters(character_tables[i]);
      parsed_characters = true;
    }
  }

  if (!parsed_character_information) {
    return callback('No character information found');
  }
  return callback(null);
};

/**
 * Retrieves and stores information from the character information table.
 * Used internally by #parse.
 * @return False if something isn't found or is bad.
 */
CharacterPage.prototype.parseCharacterInformation = function(table) {
  var self = this;
  var rows = table.getElementsByTagName('tr');

  var name_found = false;
  var vocation_found = false;
  var level_found = false;
  var world_found = false;

  for (var i = 0, j = rows.length; i < j; i++) {
    var columns = rows[i].getElementsByTagName('td');

    if (columns.length >= 2) {
      var row_name = columns[0].innerHTML;
      var row_value = columns[1].textContent.trim();
      if (!name_found && row_name === 'Name:') {
        self.elements.name_column = columns[1];
        self.name = row_value;
        name_found = true;
      } else if (!vocation_found && row_name === 'Vocation:') {
        self.elements.vocation_column = columns[1];
        self.vocation = row_value;
        vocation_found = true;
      } else if (!level_found && row_name === 'Level:') {
        self.elements.level_column = columns[1];
        self.level = parseInt(row_value, 10);
        level_found = true;
      } else if (!world_found && row_name === 'World:') {
        self.world = row_value;
        world_found = true;
      }
    }
  }

  return !isNaN(self.level) && self.utils.isVocation(self.vocation) && name_found && vocation_found && level_found && world_found;
};

/**
{'fraction_non_alphanumeric': 0.12834603793653607, 'fraction_numerical': 0.003545470661230278, 'mean_word_length': 3.463607594936709, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '5178440', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1677, 'n_words': 416}