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

  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_ORG_MEMBERS = "/members";
  12. const API_REPOS = "/repos";
  13. const API_FOLLOWING = "/following";
  14. const API_FOLLOWERS = "/followers";
  15. const API_REPOSITORIES = "/repos";
  16. const API_ORGANIZATIONS = "/orgs";
  17. /**
  18. * Builds a query for the github rest api and
  19. * allows you to get at the data using a
  20. * callback which gives you a json object.
  21. *
  22. * @param apiPath the path on the github api ie API_FOLLOWING
  23. * @param user the username to query
  24. * @param successCallBack callback to complete when data is returned
  25. * @param errorCallBack callback which is invoked on error
  26. */
  27. function queryAPIByUser(apiPath, user, successCallBack, errorCallBack) {
  28. const urlpath = APIROOT + API_USER_PATH + user + apiPath;
  29. console.log(urlpath);
  30. $.ajax({
  31. type:'GET',
  32. url: urlpath,
  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. console.log(urlpath);
  42. $.ajax({
  43. type:'GET',
  44. url: urlpath,
  45. dataType: "json",
  46. success: successCallBack,
  47. error:errorCallBack,
  48. timeout: 4000
  49. });
  50. }
  51. function queryUrl(url, successCallBack, errorCallBack) {
  52. url = url.split("https://api.github.com/").join("api/");
  53. $.ajax({
  54. type:'GET',
  55. url: url,
  56. crossDomain: true,
  57. dataType: "json",
  58. success: successCallBack,
  59. error:errorCallBack,
  60. timeout: 3000
  61. });
  62. }