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.

74 lines
1.8 KiB

  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. }
  51. /*
  52. function queryAPIByRepo(apiPath, org, successCallBack, errorCallBack) {
  53. const urlpath = APIROOT + API_ORG_PATH + org + apiPath;
  54. $.ajax({
  55. type:'GET',
  56. url: urlpath,
  57. crossDomain: true,
  58. dataType: "json",
  59. success: successCallBack,
  60. error:errorCallBack,
  61. timeout: 4000
  62. });
  63. }*/