Skip to content

Instantly share code, notes, and snippets.

@bltavares
Created September 29, 2012 21:04
Show Gist options
  • Save bltavares/3805183 to your computer and use it in GitHub Desktop.
Save bltavares/3805183 to your computer and use it in GitHub Desktop.
return (function(){
function extractAssignments(role) {
return $("#" + role + " tbody tr").map(function() {
var $this = $(this);
var name = $this.find(".assignee-names").text().trim().replace(/ +/, " ");
var id;
if(name !== "None") {
id = $this.find(".assignee-names a").attr("href").match(/consultants\/(\d+)/)[1];
}
return {
role: $this.find(".role").text().trim(),
name: name,
id: id,
staffingOffice: $this.find(".staffing_office").text().trim(),
workingOffice: $this.find(".working_office").text().trim(),
startDate: $this.find(".start_date").text().trim(),
endDate: $this.find(".end_date").text().trim()
};
}).toArray();
}
var info = {}; $(".project_details.external .col .cell").each(function() {
var $this = $(this);
info[$this.find(".field").text().replace(/(:| +)/, "")] = $this.find(".value").text().trim();
});
var possible_roles = ["unstaffed_roles", "future_assignments", "current_assignments", "past_assignments"];
var assignments = {};
possible_roles.forEach(function(role){
assignments[role] = extractAssignments(role);
});
var project = {
name: $("h1").text().trim(),
id: window.location.href.match(/projects\/(\d+)/)[1],
info: info,
assignments: assignments
};
return project;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment