<commit_before>'use strict';

function sortProjects(){
  projects.sort(function(a,b){
    var aDate = new Date(a.published);
    var bDate = new Date(b.published);
    return bDate - aDate;
  })
}

$(document).ready(function(){
  sortProjects();

  projects.forEach(function(item){
    var $project = $('#projects').clone();
    //published number of days ago calculations


    $project.removeClass('template');
    $project.find('#project-image').attr('src', item.image);
    $project.find('#project-name').text(item.name);
    $project.find('#project-url').attr('href', item.url).text(item.url);
    $project.find('#project-description').text(item.description);
    $project.attr('data-language', item.language);
    $project.find('#published').text(item.calculateDaysAgo());
    $('body').append($project);
  });
});<commit_msg>refectored some code into functions instead of in document.ready, added condition if published date is in the future it displays in progress instead of days ago<commit_after>'use strict';

///Sorts the projects array by most recent Published date
function sortProjects(){
  projects.sort(function(a,b){
    var aDate = new Date(a.published);
    var bDate = new Date(b.published);
    return bDate - aDate;
  })
}

///display projects on project page
Project.prototype.displayProjectsPage = function(){
  var $project = $('#projects').clone();
  //published number of days ago calculations


  $project.removeClass('template');
  $project.find('#project-image').attr('src', this.image);
  $project.find('#project-name').text(this.name);
  $project.find('#project-url').attr('href', this.url).text(this.url);
  $project.find('#project-description').text(this.description);
  $project.attr('data-language', this.language);
  if(this.calculateDaysAgo() === 0){
    ///if Published date is in the future just display in progress
    $project.find('#published').parent().text('In Progress');
  }else {
    $project.find('#published').text(this.calculateDaysAgo());
  }
  $('body').append($project);
}

$(document).ready(function(){
  sortProjects();
  projects.forEach(function(item){
    item.displayProjectsPage();
  });
});
{'fraction_non_alphanumeric': 0.1802136553646075, 'fraction_numerical': 0.00046446818392940084, 'mean_word_length': 4.713527851458886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2607913', 'n_tokens_mistral': 638, 'n_tokens_neox': 630, 'n_words': 136}