Simple data Analysis

by eulomelo

HTML

<!DOCTYPE HTML>
<html>

  <head>
    <title>Simple .txt analysis</title>
    <meta charset="UTF-8">
    <style>
      body {
        font-family: monospace;
      }

    </style>
  </head>
  <center>
    <h1> Simple .txt analysis </h1>
    <input type="file" id="inputfile">
    <input type="button" id="runAnalysis" value="RUN"><br>
    <div id="content"></div>
  </center>
  <script>
    function handleFileSelect(evt) {
      var files = evt.target.files;
      var reader = new FileReader();
      reader.readAsText(files[0]);
      reader.onload = function() {
        filecontent = reader.result;
      }
    }

    document.getElementById('inputfile').addEventListener('change', handleFileSelect, false);

    class Team {
      constructor(name) {
        this.name = name;
        this.points = 0;
        this.victories = 0;
        this.goalsdif = 0;
        this.goalspro = 0;
      }
      update(mygoal, othergoal) {
        this.points += (mygoal > othergoal) ? 3 : (mygoal < othergoal) ? 0 : 1;
        this.victories += (mygoal > othergoal) ? 1 : 0;
        this.goalsdif += mygoal - othergoal;
        this.goalspro += parseInt(mygoal);
      }
    }

    document.getElementById('runAnalysis').addEventListener('click', function() {
      while (document.getElementById('content').firstChild) {
        document.getElementById('content').removeChild(document.getElementById('content').firstChild);
      }
      let data = filecontent.split(/(;|\n)/).filter(x => x != ";").filter(x => x != "\n");
      let teamsnumber = parseInt(data[0]);
      let roundsnumber = parseInt(data[1]);
      let gamesperround = parseInt(data[2]);
      let playingteams = [];
      let games = [];
      for (let i = 1; i < teamsnumber + 1; i++) {
        playingteams.push(new Team(data[2 + i]));
      }
      for (let i = 0; i < roundsnumber; i++) {
        for (let j = 0; j < gamesperround; j++) {
          let k = (3 + teamsnumber) + i * (gamesperround * 5 + 1) + 1 + j * 5;
          let...