All active projects

+

@@ -27,7 +28,7 @@

All active projects

- + diff --git a/src/projects.js b/src/projects.js index e7351e8..a154abe 100644 --- a/src/projects.js +++ b/src/projects.js @@ -26,31 +26,36 @@ $(function(){ $("
Type Name Last activityCommits ahead of master branchCommits behind of master branch
").text(pj.type), $("").text(pj.name), $("").text(pj.lastActivity.toString()), - $("").text(pj.gitDiff) + $("").text(pj.gitDiff) ); })); }; - var githubCall = function(githubCompare) { - var differences = 0; - $.ajax({ + var githubCall = function(githubCompare, MAX_ID) { + var behindBy; + console.log('function called') + var promise = $.ajax({ method: 'GET', - url: githubCompare + url: githubCompare, }).done(function(response) { - differences = response['ahead_by']; - console.log(differences); - return differences; + behindBy = response['behind_by']; + $('#git-diff' + (MAX_ID+1) ).text(behindBy); + console.log(behindBy); + //return behindBy; }).fail(function(response) { - return "Request to GitHub failed" + return "Request to GitHub failed" }); + return behindBy; } // Creates a new project based on the user input in the form. var createProject = function($form) { + var differences = 99; var githubBranch = $form.find("#github-new-branch").val(); var githubCompare = "https://api.github.com/repos/quixey/webdev-exercise/compare/master..." + githubBranch; - var diffs = githubCall(githubCompare); + var diffs = githubCall(githubCompare, MAX_ID); + diffs console.log(diffs); return new Project( MAX_ID + 1, @@ -59,7 +64,6 @@ $(function(){ new Date(), diffs ); - }; // Clears the data in the form so that it's easy to enter a new project.