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.

59 lines
1.4 KiB

  1. function generateHtmlRow(repoData)
  2. {
  3. var html = "<tr class=\"table_row\">";
  4. html+="<td><a href='" + repoData.url + "'>" + repoData.name + "</a></td>";
  5. html+="<td>" + repoData.forks + "</td>";
  6. html+="<td>" + repoData.language + "</td>";
  7. html +="</tr>";
  8. return html;
  9. }
  10. var repos = [];
  11. function fetchAllRepositories(orgName, page)
  12. {
  13. return new Promise(function(resolve, reject)
  14. {
  15. queryAPIByOrg(API_REPOSITORIES + "?page=" + page, orgName,
  16. function(data)
  17. {
  18. repos.push(...data);
  19. if (data.length === 30)
  20. {
  21. fetchAllRepositories(orgName, page + 1).then(function ()
  22. {
  23. resolve();
  24. })
  25. }
  26. else {
  27. resolve();
  28. }
  29. },
  30. function(error)
  31. {
  32. //console.log("Unable to load table data");
  33. });
  34. });
  35. }
  36. function createOrgTable(orgName, tableContainer)
  37. {
  38. var html = "";
  39. fetchAllRepositories(orgName, 1).then(function()
  40. {
  41. for(var i=0; i < repos.length; i++)
  42. {
  43. html += generateHtmlRow(repos[i]);
  44. }
  45. $("#" + tableContainer).html(html);
  46. $('#dataTable').DataTable();
  47. }).catch(function(error)
  48. {
  49. //console.log("Unable to create table");
  50. });
  51. }