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.

75 lines
1.8 KiB

5 years ago
  1. /**
  2. * Simple file which uses jQuery's ajax
  3. * calls to make it easier to get data
  4. * from the github api.
  5. *
  6. * @author Jeffery Russell 2-16-19
  7. */
  8. const APIROOT = "api";
  9. const API_USER_PATH = "/users/";
  10. const API_ORG_PATH = "/orgs/";
  11. const API_REPOS = "/repos/";
  12. const API_FOLLOWING = "/following";
  13. const API_FOLLOWERS = "/followers";
  14. const API_REPOSITORIES = "/repos";
  15. const API_ORGANIZATIONS = "/orgs";
  16. /**
  17. * Builds a query for the github rest api and
  18. * allows you to get at the data using a
  19. * callback which gives you a json object.
  20. *
  21. * @param apiPath the path on the github api ie API_FOLLOWING
  22. * @param user the username to query
  23. * @param successCallBack callback to complete when data is returned
  24. * @param errorCallBack callback which is invoked on error
  25. */
  26. function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) {
  27. const urlpath = APIROOT + API_USER_PATH + user + apiPath;
  28. console.log(urlpath);
  29. $.ajax({
  30. type:'GET',
  31. url: urlpath,
  32. crossDomain: true,
  33. dataType: "json",
  34. success: successCallBack,
  35. error:errorCallBack,
  36. timeout: 4000
  37. });
  38. }
  39. function queryAPIByOrg(apiPath, org, successCallBack, errorCallBack) {
  40. const urlpath = APIROOT + API_ORG_PATH + org + apiPath;
  41. $.ajax({
  42. type:'GET',
  43. url: urlpath,
  44. crossDomain: true,
  45. dataType: "json",
  46. success: successCallBack,
  47. error:errorCallBack,
  48. timeout: 4000
  49. });
  50. console.log("past");
  51. }
  52. /*
  53. function queryAPIByRepo(apiPath, org, successCallBack, errorCallBack) {
  54. const urlpath = APIROOT + API_ORG_PATH + org + apiPath;
  55. $.ajax({
  56. type:'GET',
  57. url: urlpath,
  58. crossDomain: true,
  59. dataType: "json",
  60. success: successCallBack,
  61. error:errorCallBack,
  62. timeout: 4000
  63. });
  64. }*/