<commit_before>'use strict';

(function(module){

  const portfolio = {
    projects: [],
    count: 0,
    githubUrl: 'https://api.github.com/users/W-Ely/repos',
  };

  function Project(projectData){
    this.name = projectData.name;
    //TODO if the project has a live address use it. Maybe for thumbnail?
    this.address = projectData.html_url,
    this.summary = projectData.description,
    this.lastUpdated = projectData.updated_at.slice(0, 10),
    this.preview = 'assets/Sceenshot.png'
  }

  Project.prototype.toHtml = function() {
    // useing handlebars for javasript templeting.
    return Handlebars.compile($('#project-template').html())(this);
  };

  portfolio.gatherLocalProjects = function(){
    $.getJSON('data/projects.json', function(response){
      response.forEach(function(project) {
        portfolio.projects.push(new Project(project));
      });
      portfolio.buildProjectsPage();
    });
  }

  // bring in those sweet repos
  portfolio.findGithubRepos = function() {
    $.ajax({
      dataType: 'json',
      url: portfolio.githubUrl,
      success: function(response, status){
        response.forEach(function(repo){
          if (!repo.fork) {
            portfolio.projects.push(new Project(repo));
          }
        });
        portfolio.gatherLocalProjects();
      }
    });
    // line remains for development, prevent unneed api calls during testing.
    // portfolio.gatherLocalProjects();
  }

  portfolio.sortThoseProjectsByDate = function(){
    portfolio.projects.sort(function(a, b){
      //regEx to remove hyphens. could use new Date() but didn't
      return b.lastUpdated.replace(/-/g, '') - a.lastUpdated.replace(/-/g, '');
    });
  }

  portfolio.buildProjectsPage = function(){
    portfolio.sortThoseProjectsByDate();
    portfolio.projects.forEach(function(project) {
      $('.projects-carousel').append(project.toHtml());
    });
    //wrap all 'article's in a table and row so it will scroll to the right
    $(".projects-carousel").wrapInner("<table><tr>");
    // put each 'article' in a column
    $("article").wrap("<td>");
    //a map and a reduce for educational purpose. 
    let projectNames = portfolio.projects.map( project => project.name).reduce((acc, name) => acc + ', ' + name);
    console.log(projectNames);
  }

  portfolio.findGithubRepos();

  module.portfolio = portfolio;
  module.Project = Project;

}(window));<commit_msg>arrow functions added to projects.js<commit_after>'use strict';

(function(module){

  const portfolio = {
    projects: [],
    count: 0,
    githubUrl: 'https://api.github.com/users/W-Ely/repos',
  };

  function Project(projectData){
    this.name = projectData.name;
    //TODO if the project has a live address use it. Maybe for thumbnail?
    this.address = projectData.html_url,
    this.summary = projectData.description,
    this.lastUpdated = projectData.updated_at.slice(0, 10),
    this.preview = 'assets/Sceenshot.png'
  }

  Project.prototype.toHtml = function() {
    // useing handlebars for javasript templeting.
    return Handlebars.compile($('#project-template').html())(this);
  };

  portfolio.gatherLocalProjects = () => {
    $.getJSON('data/projects.json', response => {
      response.forEach(project => {
        portfolio.projects.push(new Project(project));
      });
      portfolio.buildProjectsPage();
    });
  }

  // bring in those sweet repos
  portfolio.findGithubRepos = () => {
    $.ajax({
      dataType: 'json',
      url: portfolio.githubUrl,
      success: (response, status) => {
        response.forEach(repo => {
          if (!repo.fork) portfolio.projects.push(new Project(repo));
        });
        portfolio.gatherLocalProjects();
      }
    });
    // line remains for development, prevent unneed api calls during testing.
    // portfolio.gatherLocalProjects();
  }

  portfolio.sortThoseProjectsByDate = () => {
    portfolio.projects.sort((a, b) => {
      //regEx to remove hyphens. could use new Date() but didn't
      return b.lastUpdated.replace(/-/g, '') - a.lastUpdated.replace(/-/g, '');
    });
  }

  portfolio.buildProjectsPage = () => {
    portfolio.sortThoseProjectsByDate();
    portfolio.projects.forEach(project => {
      $('.projects-carousel').append(project.toHtml());
    });
    //wrap all 'article's in a table and row so it will scroll to the right
    $(".projects-carousel").wrapInner("<table><tr>");
    // put each 'article' in a column
    $("article").wrap("<td>");
    //a map and a reduce for educational purpose.
    // let projectNames = portfolio.projects.map( project => project.name).reduce((acc, name) => acc + ', ' + name);
    // console.log(projectNames);
  }

  portfolio.findGithubRepos();

  module.portfolio = portfolio;
  module.Project = Project;

}(window));
{'fraction_non_alphanumeric': 0.15176889261042495, 'fraction_numerical': 0.0016746912288046892, 'mean_word_length': 3.042301184433164, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 2, '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': '208250', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1415, 'n_words': 305}