<commit_before>'use strict';

// Get userName
var userName = localStorage.userName;
var currentUser = null;
var playerObjectArray = JSON.parse(localStorage.playerObjectArray);
var winsVsLosses = null;

for (var i = 0; i < playerObjectArray.length; i++){
  if(playerObjectArray[i].name === userName){
    currentUser = playerObjectArray[i];
  }
};

// Relevant Object Properties
// currentUser.name
// currentUser.wins
// currentUser.losses
// currentUser.ties
// currentUser.gamesPlayed
// currentUser.gameOutcome

function winPercentage(){
  return (currentUser.wins / (currentUser.wins + currentUser.losses)) * 100;
}

var player = document.getElementById('player-name');
var games = document.getElementById('game-history');
var percentEl = document.getElementById('percentage');
var welcome = document.getElementById('welcome');
var losing = document.getElementById('losing');
var winning = document.getElementById('winning');
var trend = document.getElementById('trend');

if (currentUser.gamesPlayed < 1){
  welcome.style.display = 'block';
}

if (currentUser.gamesPlayed > 0){
  winsVsLosses = winPercentage();
}

if (winsVsLosses <= 50){
  losing.style.display = 'block';
}

if (winsVsLosses > 50){
  winning.style.display = 'block';
}

if (currentUser.gamesPlayed > 25){
  trend.style.display = 'block';
  losing.style.display = 'none';
  winning.style.display = 'none';
}

function newElement(type, content, parent){
  var newEl = document.createElement(type);
  newEl.textContent = content;
  parent.appendChild(newEl);
};

newElement('h1', ('Hello, ' + userName + '!'), player);<commit_msg>Added percentage message<commit_after>'use strict';

// Get userName
var userName = localStorage.userName;
var currentUser = null;
var playerObjectArray = JSON.parse(localStorage.playerObjectArray);
var winsVsLosses = null;

for (var i = 0; i < playerObjectArray.length; i++){
  if(playerObjectArray[i].name === userName){
    currentUser = playerObjectArray[i];
  }
};

// Relevant Object Properties
// currentUser.name
// currentUser.wins
// currentUser.losses
// currentUser.ties
// currentUser.gamesPlayed
// currentUser.gameOutcome

function winPercentage(){
  return (currentUser.wins / (currentUser.wins + currentUser.losses)) * 100;
}

var player = document.getElementById('player-name');
var games = document.getElementById('game-history');
var percentEl = document.getElementById('percentage');
var welcome = document.getElementById('welcome');
var losing = document.getElementById('losing');
var winning = document.getElementById('winning');
var trend = document.getElementById('trend');

if (currentUser.gamesPlayed < 1){
  welcome.style.display = 'block';
}

if (currentUser.gamesPlayed > 0){
  winsVsLosses = winPercentage();
}

if (winsVsLosses <= 50){
  losing.style.display = 'block';
}

if (winsVsLosses > 50){
  winning.style.display = 'block';
}

if (currentUser.gamesPlayed > 25){
  trend.style.display = 'block';
  losing.style.display = 'none';
  winning.style.display = 'none';
}

function newElement(type, content, parent){
  var newEl = document.createElement(type);
  newEl.textContent = content;
  parent.appendChild(newEl);
};

newElement('h1', ('Hello, ' + userName + '!'), player);



newElement('h1', ('Win Percentage: ' + winsVsLosses + '%'), percentEl);
{'fraction_non_alphanumeric': 0.14993917274939172, 'fraction_numerical': 0.008211678832116789, 'mean_word_length': 5.170731707317073, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '717145', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1018, 'n_words': 220}