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.

86 lines
2.2 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, page)
  17. {
  18. return new Promise(function(resolve, reject)
  19. {
  20. queryAPIByOrg(API_REPOSITORIES + "?page=" + page, orgName,
  21. function(data)
  22. {
  23. repos.push(...data);
  24. if (data.length === 30)
  25. {
  26. fetchAllRepositories(orgName, page + 1).then(function ()
  27. {
  28. resolve();
  29. })
  30. }
  31. else {
  32. resolve();
  33. }
  34. },
  35. function(error)
  36. {
  37. //console.log("Unable to load table data");
  38. });
  39. });
  40. }
  41. function createOrgTable(orgName, tableContainer)
  42. {
  43. var html = "";
  44. fetchAllRepositories(orgName, 1).then(function() {
  45. for (var i=0; i < repos.length; i++) {
  46. let icon = repos[i].language;
  47. icon === null
  48. ? icon = 'null'
  49. : icon = icon.toLowerCase();
  50. icon === 'c++'
  51. ? icon = 'cplusplus'
  52. : null;
  53. icon === 'c#'
  54. ? icon = 'csharp'
  55. : null;
  56. repos[i].language = icon;
  57. html += generateHtmlRow(repos[i]);
  58. }
  59. $("#" + tableContainer).html(html);
  60. setTimeout(function() {
  61. $('#dataTable').DataTable({
  62. pageLength: 15,
  63. pagingType: 'simple',
  64. bLengthChange : false,
  65. "bFilter" : false
  66. });
  67. }, 1500);
  68. }).catch(function(error)
  69. {
  70. //console.log("Unable to create table");
  71. });
  72. }