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.

110 lines
5.9 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
  1. function profileGen(username, container)
  2. {
  3. queryAPIByUser("", username, (user) =>
  4. {
  5. if(!user.hasOwnProperty("id"))
  6. {
  7. alert("User Does Not Exist");
  8. window.location.href = "./GraphGenerator.html";
  9. }
  10. parseOrgs(user.login).then( (orgsReturn) => {
  11. let html =
  12. "<div class=\"card\" style=\"w-100; background-color:rgb(255,255,255);\"> \
  13. <img class=\"card-img-top\" src=\""+user.avatar_url+"\"></img> \
  14. <div class=\"row mx-0\" style=\"background-color:rgb(255,255,255);\"> \
  15. <div class=\"col-7 p-0\"> \
  16. <div class=\"card-body\" style=\"background-color:rgb(255,255,255);\">"+
  17. (user.name != null ? "<h5 class=\"card-title\">"+user.name+"</h5>" : "") +" \
  18. <h6 class=\"card-subtitle\">"+user.login+"</h5> \
  19. </div> \
  20. </div> \
  21. <div class=\"col-2 p-0\"> \
  22. <button type=\"button\" class=\"btn btn-link pt-3\"> \
  23. <a href=\""+graphUrl(user.login)+"\"> \
  24. <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"> \
  25. <path d=\"M5 9.2h3V19H5zM10.6 5h2.8v14h-2.8zm5.6 8H19v6h-2.8z\"/> \
  26. <path fill=\"none\" d=\"M0 0h24v24H0z\"/> \
  27. </svg> \
  28. </a> \
  29. </button> \
  30. </div> \
  31. <div class=\"col-2 p-0\"> \
  32. <button type=\"button\" class=\"btn btn-link pt-3\"> \
  33. <a href=\""+timelineUrl(user.login)+"\"> \
  34. <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"> \
  35. <defs> \
  36. <path id=\"a\" d=\"M0 0h24v24H0z\"/> \
  37. </defs> \
  38. <clipPath> \
  39. <use xlink:href=\"#a\" overflow=\"visible\"/> \
  40. </clipPath> \
  41. <defs> \
  42. <path id=\"b\" d=\"M0 0h24v24H0z\"/></defs><clipPath><use xlink:href=\"#b\" overflow=\"visible\"/> \
  43. </clipPath> \
  44. <path d=\"M23 8c0 1.1-.9 2-2 2-.18 0-.35-.02-.51-.07l-3.56 3.55c.05.16.07.34.07.52 0 1.1-.9 2-2 2s-2-.9-2-2c0-.18.02-.36.07-.52l-2.55-2.55c-.16.05-.34.07-.52.07s-.36-.02-.52-.07l-4.55 4.56c.05.16.07.33.07.51 0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2c.18 0 .35.02.51.07l4.56-4.55C8.02 9.36 8 9.18 8 9c0-1.1.9-2 2-2s2 .9 2 2c0 .18-.02.36-.07.52l2.55 2.55c.16-.05.34-.07.52-.07s.36.02.52.07l3.55-3.56C19.02 8.35 19 8.18 19 8c0-1.1.9-2 2-2s2 .9 2 2z\"/> \
  45. </svg> \
  46. </a> \
  47. </button> \
  48. </div> \
  49. </div> \
  50. <div class=\"card-body py-1\" style=\"background-color:rgb(255,255,255);\"> \
  51. <p class=\"card-text\"><a href=\""+user.html_url+"\" class=\"card-link\">"+user.html_url+"</a></p> \ " +
  52. (user.blog != null ? "<p class=\"card-text \"><a href="+user.blog+" class=\"card-link\">"+user.blog+"</a></p>" : "")+" \
  53. </div> \
  54. <ul class=\"list-group list-group-flush\"> \
  55. <li class=\"list-group-item\">Followers: "+user.followers+"</li> \
  56. <li class=\"list-group-item\">Following: "+user.following+"</li> \
  57. <li class=\"list-group-item\">Repositories: "+user.public_repos+"</li>" +
  58. (user.bio != null ? "<li class=\"list-group-item\">Bio: "+user.bio+"</li>" : "")+
  59. (user.location != null ? "<li class=\"list-group-item\">Location: "+user.location+"</li>" : "")+
  60. (user.email != null ? "<li class=\"list-group-item\">Email: "+user.email+"</li>" : "")+
  61. (user.company != null ? "<li class=\"list-group-item\">Company: "+user.company+"</li>" : "")+
  62. (orgsReturn != [] ? "<li class=\"list-group-item\">"+orgsReturn+"</li>" : "")+ " \
  63. </ul> \
  64. </div>";
  65. $("#"+container).html(html);
  66. })
  67. }, () =>
  68. {
  69. alert("User Does Not Exist");
  70. window.location.href = "./GraphGenerator.html";
  71. });
  72. }
  73. function parseOrgs(name) {
  74. return new Promise( (resolve, reject) => {
  75. let urlpath = `api/users/${name}/orgs`;
  76. let orgs_final = [];
  77. queryUrl(urlpath, (orgs) => {
  78. var prom= [];
  79. for(var i = 0;i < orgs.length; i++) {
  80. prom.push( new Promise( (res, rej) => {
  81. url = orgs[i].url;
  82. queryUrl(url, (orgData) => {
  83. orgs_final.push("<a href=\""+orgData.html_url+"\"><img src=\""+orgData.avatar_url+"\" class=\"img-fluid\" style=\"max-width:49%\"></img></a>");
  84. res();
  85. }, (error) => {
  86. console.log(error);
  87. rej(error);
  88. console.error("error getting org info");
  89. });
  90. })
  91. )
  92. }
  93. Promise.all(prom).then(function() {
  94. resolve(orgs_final.join(" "));
  95. })
  96. }, (error) => {
  97. resolve([]);
  98. });
  99. })
  100. }
  101. function graphUrl(user) {
  102. return "/FriendsGraph.html?name="+user;
  103. }
  104. function timelineUrl(user) {
  105. return "/TimeLineGraph.html?name="+user;
  106. }