Website for visualizing a persons github network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. function profileGen(username, container) {
  2. queryAPIByUser("", username, (user) => {
  3. parseOrgs(user.login).then(function(orgsReturn) {
  4. let html =
  5. "<div> \
  6. <img src=\""+user.avatar_url+"\"></img> \
  7. <h1>"+user.name+"</h1> \
  8. <h2>"+user.login+"</h2> \
  9. <p>Followers: "+user.followers+"</p> \
  10. <p>Following: "+user.following+"</p> \
  11. <p>"+(user.bio != null ? "Bio: "+user.bio : "")+"</p> \
  12. <p>"+(user.location != null ? "Location: "+user.location : "")+"</p> \
  13. <p>"+(user.email != null ? "Email: "+user.email : "")+"</p> \
  14. <p>"+(user.blog != null ? "Site: "+user.blog : "")+"</p> \
  15. <p>"+(user.company != null ? "Company: "+user.company : "")+"</p> \
  16. <p>"+(user.organizations_url != null ? "Organizations: "+orgsReturn: "")+"</p> \
  17. <a href=\""+user.html_url+"\">"+user.html_url+"</h2> \
  18. <h2></h2> \
  19. </div>"
  20. $("#"+container).html(html);
  21. })
  22. }, () => {
  23. console.error("error getting user info");
  24. });
  25. }
  26. async function parseOrgs(name) {
  27. const urlpath = `api/users/${name}/orgs`;
  28. let orgs_final = [];
  29. await queryUrl(urlpath, async (orgs) => {
  30. orgs.map(org => {
  31. return new Promise(function (res, rej) {
  32. url = org.url;
  33. queryUrl(url, (orgData) => {
  34. orgs_final.push("<a href=\"" + orgData.html_url + "\"><img src=\"" + orgData.avatar_url + "\"></img></a>");
  35. //console.log(orgs_final);
  36. res();
  37. }, () => {
  38. console.error("error getting org info");
  39. });
  40. });
  41. });
  42. console.log(orgs);
  43. await Promise.all(orgs);
  44. }, () => {
  45. console.error("error getting orgs");
  46. });
  47. console.log(orgs_final);
  48. console.log(orgs_final.length);
  49. console.log(orgs_final[0]);
  50. return orgs_final.join(" ");
  51. }
  52. function queryUrl(url, successCallBack, errorCallBack) {
  53. console.log(url);
  54. $.ajax({
  55. type:'GET',
  56. url: url,
  57. crossDomain: true,
  58. dataType: "json",
  59. success: successCallBack,
  60. error:errorCallBack
  61. });
  62. }