Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,38 @@ <h2>All active projects</h2>
<th>Type</th>
<th>Name</th>
<th>Last activity</th>
<th>Branch</th>
<th>Up to Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

<div class='gitRepos'>

</div>

<hr>

<h2>Add new project</h2>
<form id="add-project-form">

<div class="form-group">
<label for="project-branch">Project Branch</label>
<input type="text" class="form-control" id="project-branch" list="type-list" autofocus>
<datalist id="type-list">
<option>master</option>
<option>gitbranches</option>
<option>outdated-branch-1</option>
<option>outdated-branch-2</option>
<option>outdated-branch-3</option>
<option>baseline-branch</option>
<option>up-to-date-branch-1</option>
<option>up-to-date-branch-2</option>
</datalist>
</div>

<div class="form-group">
<label for="project-type">Project type</label>
<input type="text" class="form-control" id="project-type" list="type-list" autofocus>
Expand All @@ -44,6 +68,7 @@ <h2>Add new project</h2>
<option>Analysis</option>
</datalist>
</div>

<div class="form-group">
<label for="project-name">Project name</label>
<input type="text" class="form-control" id="project-name">
Expand Down
57 changes: 54 additions & 3 deletions src/projects.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,54 @@
function Project(id, type, name, lastActivity) {
$(document).ready(function() {
getBranches();
});


var compareToMaster = function(){

// url: "https://api.github.com/repos/andrewdonato/webdev-exercise/compare/master...gitBranches",

}


var getBranches = function(){
// https://api.github.com/repos/andrewdonato/webdev-exercise/branches
// var repos = $(".gitRepos").loadRepositories(andrewdonato)
// why aren't my changes sticking?

var request = $.ajax({
url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches",
type: "get"

})
request.done(function(serverData){
branches = serverData;
console.log(branches[2])
})
request.fail(function(serverData){
console.log(serverData);
console.log('server request failed');
})
};













function Project(id, type, name, lastActivity, branch, upToDate) {
this.id = id;
this.type = type;
this.name = name;
this.lastActivity = lastActivity;
this.branch = branch;
this.name = name;
}

// The list of all projects currently in the system.
Expand All @@ -17,13 +63,15 @@ var CURRENT_PROJECTS = [
var MAX_ID = Math.max.apply(null, $.map(CURRENT_PROJECTS, function(pj) { return pj.id; }));

$(function(){

var loadProjects = function($container, projects) {
$.fn.append.apply($container, $.map(projects, function(pj) {
return $("<tr>").append(
$("<td>").text(pj.id),
$("<td>").text(pj.type),
$("<td>").text(pj.name),
$("<td>").text(pj.lastActivity.toString())
$("<td>").text(pj.lastActivity.toString()),
$("<td>").text(pj.branch)
);
}));
};
Expand All @@ -34,14 +82,17 @@ $(function(){
MAX_ID + 1,
$form.find("#project-type").val(),
$form.find("#project-name").val(),
new Date()
new Date(),
$form.find("#project-branch").val()
// this is where I would put whether or not the project is up to date with master
);
};

// Clears the data in the form so that it's easy to enter a new project.
var resetForm = function($form) {
$form.find("#project-type").val("");
$form.find("#project-name").val("");
$form.find("#project-branch").val("");
$form.find("input:first").focus();
};

Expand Down