<commit_before>let tableBody = document.querySelector('.datadisplaytable tbody');

function getTeacherNames () {
  let teacherNameList = Array.from(tableBody.querySelectorAll('tr:nth-child(n+4) td:nth-child(18)'));

  teacherNameList = teacherNameList.map(name => {
    let isPrimaryTeacherIndex;
    let teacherName = name.innerText;
    isPrimaryTeacherIndex = teacherName.indexOf('(');
    if (isPrimaryTeacherIndex > -1) {
      return teacherName.slice(0, isPrimaryTeacherIndex - 1);
    }
    return teacherName;
  });

  return teacherNameList;
}

getTeacherNames();

// This layout table is used to present the sections found

let child;
let parent;
let column;
let ratingText;
//
//
// column = document.createElement('th');
// ratingText = document.createTextNode('COLUMN');
// column.appendChild(ratingText);
// column.classList.add('ddheader');
//
// parent = document.querySelector('.datadisplaytable tbody tr:nth-child(3)');
// child = parent.querySelector('th:nth-child(19)');
// parent.insertBefore(column, child);
//
// column = document.createElement('td');
// ratingText = document.createTextNode('COLUMN');
// column.appendChild(ratingText);
// column.classList.add('dddefault');
//
//
// parent = document.querySelector('.datadisplaytable tbody tr:nth-child(4)');
// child = parent.querySelector('td:nth-child(18)');
// parent.insertBefore(column, child);
//
// column = document.createElement('td');
// ratingText = document.createTextNode('COLUMN');
// column.appendChild(ratingText);
// column.classList.add('dddefault');
//
// parent = document.querySelector('.datadisplaytable tbody tr:nth-child(5)');
// child = parent.querySelector('td:nth-child(18)');
// parent.insertBefore(column, child);<commit_msg>refactor content columns<commit_after>let tableBody = document.querySelector('.datadisplaytable tbody');

function getTeacherNames () {
  let teacherNameList = Array.from(tableBody.querySelectorAll('tr:nth-child(n+4) td:nth-child(18)'));

  teacherNameList = teacherNameList.map(name => {
    let isPrimaryTeacherIndex;
    let teacherName = name.innerText;
    isPrimaryTeacherIndex = teacherName.indexOf('(');
    if (isPrimaryTeacherIndex > -1) {
      return teacherName.slice(0, isPrimaryTeacherIndex - 1);
    }
    return teacherName;
  });

  return teacherNameList;
}

function updateHeaderColumn() {
  let rateMyProfessorColumn = document.createElement('th');
  let ratingText = document.createTextNode('Rate My Professor');
  rateMyProfessorColumn.appendChild(ratingText);
  rateMyProfessorColumn.classList.add('ddheader');
  let headers = tableBody.querySelector('tr:nth-child(3)');
  let teacherColumn = headers.querySelector('th:nth-child(20)');
  headers.insertBefore(rateMyProfessorColumn, teacherColumn);
}

function updateContentColumns() {
  let contentRows = Array.from(tableBody.querySelectorAll('tr:nth-child(n+4)'));
  contentRows.forEach(row => {
    let column = document.createElement('td');
    let quality = insertIntoDiv(document.createTextNode('Quality: 4.0'));
    let difficulty = insertIntoDiv(document.createTextNode('Difficulty: 3.3'));
    let link = insertIntoDiv(document.createElement('a'));
    column.setAttribute('style', 'font-size: .75em');
    link.setAttribute('href', 'www.google.com');
    link.appendChild(document.createTextNode('More info...'));
    addChildren(column, quality, difficulty, link);
    column.classList.add('dddefault');
    row.insertBefore(column, row.querySelector('td:nth-child(19)'));
  });
}

function insertIntoDiv(element) {
  return document.createElement('div').appendChild(element);
}

function addChildren(parent, ...children) {
  parent.appendChild(children);
}
updateHeaderColumn();
updateContentColumns();



{'fraction_non_alphanumeric': 0.15533458747648482, 'fraction_numerical': 0.008868583714055361, 'mean_word_length': 5.276559865092748, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4691751', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1120, 'n_words': 186}