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.

153 lines
5.1 KiB

  1. var events = [];
  2. var repositoryData;
  3. function addEvent(group, date, content)
  4. {
  5. var dateFormat = new Date(date);
  6. var dd = new Date(dateFormat.getFullYear(), dateFormat.getMonth(), dateFormat.getDay());
  7. events.push({id: events.length, group: group, start: dd, content: content});
  8. }
  9. // {id: 0, group: 0, start: new Date(2013,7,1), end: new Date(2017,5,15), content: 'High School'},
  10. function addRepositories(userName, groupID)
  11. {
  12. return new Promise(function(resolve, reject)
  13. {
  14. queryAPIByUser(API_REPOSITORIES, userName,
  15. function(data)
  16. {
  17. repositoryData = data;
  18. for(var i = 0; i < data.length; i++)
  19. {
  20. data[i].id = events.length;
  21. addEvent(groupID, data[i]['created_at'], data[i]['name'])
  22. }
  23. resolve();
  24. },
  25. function(error)
  26. {
  27. console.log(error);
  28. reject(error);
  29. })
  30. })
  31. }
  32. function timeLineClickEvent(properties)
  33. {
  34. if(properties.item !== null && typeof repositoryData[properties.item].name !== 'undefined')
  35. {
  36. var item = repositoryData[properties.item];
  37. var html = "<div class=\"card\">\n" +
  38. " <div class=\"card-header\">\n" +
  39. item.name +
  40. " </div>\n" +
  41. " <div class=\"card-body\">\n";
  42. html += "<p>" + item.description + "</p>";
  43. console.log(item.license);
  44. if(item.license === null)
  45. {
  46. item.license = new Object();
  47. item.license.name = 'none';
  48. }
  49. html += "<div class='row'><div class=\"col-6\">\n" +
  50. " <ul class=\"list-group\">\n" +
  51. " <li class=\"row\">\n" +
  52. " <div class=\"col-md-6\"><b>Fork Count</b></div>\n" +
  53. " <div class=\"col-md-6\">" +
  54. item.forks +
  55. "</div>\n" +
  56. " </li>\n" +
  57. " <li class=\"row\">\n" +
  58. " <div class=\"col-md-6\"><b>Languages</b></div>\n" +
  59. " <div class=\"col-md-6\">" +
  60. item.language+
  61. "</div>\n" +
  62. " </li>\n" +
  63. " <li class=\"row\">\n" +
  64. " <div class=\"col-md-6\"><b>Liscense</b></div>\n" +
  65. " <div class=\"col-md-6\">" +
  66. item.license.name +
  67. "</div>\n" +
  68. " </li>\n" +
  69. " <li class=\"row\">\n" +
  70. " <div class=\"col-md-6\"><b>Home Page</b></div>\n" +
  71. " <div class=\"col-md-6\">" +
  72. "<a href='" + item.homepage + "'>" +item.homepage + "</a>" +
  73. "</div>\n" +
  74. " </li>\n" +
  75. " </ul>\n" +
  76. " </div>";
  77. html += "<div class=\"col-6\">\n" +
  78. " <ul class=\"list-group\">\n" +
  79. " <li class=\"row\">\n" +
  80. " <div class=\"col-md-6\"><b>Repository URL</b></div>\n" +
  81. " <div class=\"col-md-6\">" +
  82. "<a href='" + item.html_url + "'>" +item.html_url + "</a>" +
  83. "</div>\n" +
  84. " </li>\n" +
  85. " <li class=\"row\">\n" +
  86. " <div class=\"col-md-6\"><b>Open Issues</b></div>\n" +
  87. " <div class=\"col-md-6\">" +
  88. item.open_issues_count +
  89. "</div>\n" +
  90. " </li>\n" +
  91. " <li class=\"row\">\n" +
  92. " <div class=\"col-md-6\"><b>Watchers</b></div>\n" +
  93. " <div class=\"col-md-6\">" +
  94. item.watchers +
  95. "</div>\n" +
  96. " </li>\n" +
  97. " </ul>\n" +
  98. " </div></div>";
  99. html +=" </div>\n" +
  100. "</div>";
  101. $("#repositoryInformation").html(html);
  102. }
  103. }
  104. function createProfileTimeLine(username, containerName)
  105. {
  106. var container = document.getElementById(containerName);
  107. var prom = [addRepositories(username, 1)];
  108. var groups = new vis.DataSet([
  109. {id: 1, content: 'Repositories', value: 2}
  110. ]);
  111. console.log("up up duper");
  112. Promise.all(prom).then(function()
  113. {
  114. // note that months are zero-based in the JavaScript Date object
  115. var items = new vis.DataSet(events);
  116. var options = {
  117. // option groupOrder can be a property name or a sort function
  118. // the sort function must compare two groups and return a value
  119. // > 0 when a > b
  120. // < 0 when a < b
  121. // 0 when a == b
  122. groupOrder: function (a, b) {
  123. return a.value - b.value;
  124. },
  125. margin: {
  126. item: 20,
  127. axis: 40
  128. }
  129. };
  130. var timeline = new vis.Timeline(container);
  131. timeline.setOptions(options);
  132. timeline.setGroups(groups);
  133. timeline.setItems(items);
  134. timeline.on('click', timeLineClickEvent);
  135. });
  136. }