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.

79 lines
2.0 KiB

  1. function generateHtmlRow(repoData) {
  2. var html = `
  3. <tr>
  4. <td>
  5. ${repoData.language === 'null'
  6. ? '<div class="bg-light d-inline-block" style="height: 14px; width: 14px; border-radius: 7px"></div>'
  7. : `<i class="devicon-${repoData.language}-plain colored"></i>`}
  8. <a class="text-reset ml-1" href="${repoData.html_url}" target="_blank">${repoData.name}</a>
  9. </td>
  10. <td class="text-right">${repoData.forks}</td>
  11. </tr>
  12. `;
  13. return html;
  14. }
  15. var repos = [];
  16. function fetchAllRepositories(orgName)
  17. {
  18. console.log("Going for it");
  19. return new Promise((resolve, reject)=>
  20. {
  21. getOrganizationRepositories(orgName,
  22. (data)=>
  23. {
  24. console.log("Dam did got it");
  25. repos.push(...data);
  26. resolve();
  27. },
  28. (error)=>
  29. {
  30. console.log("Unable to load table data");
  31. reject("Error fetching repositories");
  32. });
  33. });
  34. }
  35. function createOrgTable(orgName, tableContainer)
  36. {
  37. var html = "";
  38. fetchAllRepositories(orgName).then(function() {
  39. for (var i=0; i < repos.length; i++) {
  40. let icon = repos[i].language;
  41. icon === null
  42. ? icon = 'null'
  43. : icon = icon.toLowerCase();
  44. icon === 'c++'
  45. ? icon = 'cplusplus'
  46. : null;
  47. icon === 'c#'
  48. ? icon = 'csharp'
  49. : null;
  50. repos[i].language = icon;
  51. html += generateHtmlRow(repos[i]);
  52. }
  53. $("#" + tableContainer).html(html);
  54. setTimeout(function() {
  55. $('#dataTable').DataTable({
  56. pageLength: 15,
  57. pagingType: 'simple',
  58. bLengthChange : false,
  59. "bFilter" : false
  60. });
  61. }, 1500);
  62. }).catch(function(error)
  63. {
  64. console.log("Unable to create table");
  65. });
  66. }