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.

156 lines
5.2 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></li>";
  68. if(item.homepage !== null)
  69. {
  70. html +=
  71. " <li class=\"row\">\n" +
  72. " <div class=\"col-md-6\"><b>Home Page</b></div>\n" +
  73. " <div class=\"col-md-6\">" +
  74. "<a href='" + item.homepage + "'>" +item.homepage + "</a>" +
  75. "</div>\n" +
  76. " </li>\n" +
  77. " </ul>\n";
  78. }
  79. html += "</div><div class=\"col-6\">\n" +
  80. " <ul class=\"list-group\">\n" +
  81. " <li class=\"row\">\n" +
  82. " <div class=\"col-md-6\"><b>Repository URL</b></div>\n" +
  83. " <div class=\"col-md-6\">" +
  84. "<a href='" + item.html_url + "'>" +item.html_url + "</a>" +
  85. "</div>\n" +
  86. " </li>\n" +
  87. " <li class=\"row\">\n" +
  88. " <div class=\"col-md-6\"><b>Open Issues</b></div>\n" +
  89. " <div class=\"col-md-6\">" +
  90. item.open_issues_count +
  91. "</div>\n" +
  92. " </li>\n" +
  93. " <li class=\"row\">\n" +
  94. " <div class=\"col-md-6\"><b>Watchers</b></div>\n" +
  95. " <div class=\"col-md-6\">" +
  96. item.watchers +
  97. "</div>\n" +
  98. " </li>\n" +
  99. " </ul>\n" +
  100. " </div></div>";
  101. html +=" </div>\n" +
  102. "</div>";
  103. $("#repositoryInformation").html(html);
  104. }
  105. }
  106. function createProfileTimeLine(username, containerName)
  107. {
  108. var container = document.getElementById(containerName);
  109. var prom = [addRepositories(username, 1)];
  110. var groups = new vis.DataSet([
  111. {id: 1, content: 'Repositories', value: 2}
  112. ]);
  113. Promise.all(prom).then(function()
  114. {
  115. // note that months are zero-based in the JavaScript Date object
  116. var items = new vis.DataSet(events);
  117. var options = {
  118. // option groupOrder can be a property name or a sort function
  119. // the sort function must compare two groups and return a value
  120. // > 0 when a > b
  121. // < 0 when a < b
  122. // 0 when a == b
  123. groupOrder: function (a, b) {
  124. return a.value - b.value;
  125. },
  126. margin: {
  127. item: 20,
  128. axis: 40
  129. }
  130. };
  131. var timeline = new vis.Timeline(container);
  132. timeline.setOptions(options);
  133. timeline.setGroups(groups);
  134. timeline.setItems(items);
  135. timeline.on('click', timeLineClickEvent);
  136. });
  137. }