|
63 | 63 | $item.appendTo("#repos"); |
64 | 64 | } |
65 | 65 |
|
66 | | - $.getJSON("https://api.github.com/orgs/twitter/repos?callback=?", function (result) { |
67 | | - var repos = result.data; |
68 | | - |
69 | | - $(function () { |
70 | | - $("#num-repos").text(repos.length); |
71 | | - |
72 | | - // Convert pushed_at to Date. |
73 | | - $.each(repos, function (i, repo) { |
74 | | - repo.pushed_at = new Date(repo.pushed_at); |
75 | | - |
76 | | - var weekHalfLife = 1.146 * Math.pow(10, -9); |
77 | | - |
78 | | - var pushDelta = (new Date) - Date.parse(repo.pushed_at); |
79 | | - var createdDelta = (new Date) - Date.parse(repo.created_at); |
80 | | - |
81 | | - var weightForPush = 1; |
82 | | - var weightForWatchers = 1.314 * Math.pow(10, 7); |
83 | | - |
84 | | - repo.hotness = weightForPush * Math.pow(Math.E, -1 * weekHalfLife * pushDelta); |
85 | | - repo.hotness += weightForWatchers * repo.watchers / createdDelta; |
86 | | - }); |
87 | | - |
88 | | - // Sort by highest # of watchers. |
89 | | - repos.sort(function (a, b) { |
90 | | - if (a.hotness < b.hotness) return 1; |
91 | | - if (b.hotness < a.hotness) return -1; |
92 | | - return 0; |
93 | | - }); |
94 | | - |
95 | | - $.each(repos, function (i, repo) { |
96 | | - addRepo(repo); |
97 | | - }); |
98 | | - |
99 | | - // Sort by most-recently pushed to. |
100 | | - repos.sort(function (a, b) { |
101 | | - if (a.pushed_at < b.pushed_at) return 1; |
102 | | - if (b.pushed_at < a.pushed_at) return -1; |
103 | | - return 0; |
104 | | - }); |
105 | | - |
106 | | - $.each(repos.slice(0, 3), function (i, repo) { |
107 | | - addRecentlyUpdatedRepo(repo); |
108 | | - }); |
| 66 | + function addRepos(repos, page) { |
| 67 | + repos = repos || []; |
| 68 | + page = page || 1; |
| 69 | + |
| 70 | + var uri = "https://api.github.com/orgs/twitter/repos?callback=?" |
| 71 | + + "&per_page=100" |
| 72 | + + "&page="+page; |
| 73 | + |
| 74 | + $.getJSON(uri, function (result) { |
| 75 | + if (result.data && result.data.length > 0) { |
| 76 | + repos = repos.concat(result.data); |
| 77 | + addRepos(repos, page + 1); |
| 78 | + } |
| 79 | + else { |
| 80 | + $(function () { |
| 81 | + $("#num-repos").text(repos.length); |
| 82 | + |
| 83 | + // Convert pushed_at to Date. |
| 84 | + $.each(repos, function (i, repo) { |
| 85 | + repo.pushed_at = new Date(repo.pushed_at); |
| 86 | + |
| 87 | + var weekHalfLife = 1.146 * Math.pow(10, -9); |
| 88 | + |
| 89 | + var pushDelta = (new Date) - Date.parse(repo.pushed_at); |
| 90 | + var createdDelta = (new Date) - Date.parse(repo.created_at); |
| 91 | + |
| 92 | + var weightForPush = 1; |
| 93 | + var weightForWatchers = 1.314 * Math.pow(10, 7); |
| 94 | + |
| 95 | + repo.hotness = weightForPush * Math.pow(Math.E, -1 * weekHalfLife * pushDelta); |
| 96 | + repo.hotness += weightForWatchers * repo.watchers / createdDelta; |
| 97 | + }); |
| 98 | + |
| 99 | + // Sort by highest # of watchers. |
| 100 | + repos.sort(function (a, b) { |
| 101 | + if (a.hotness < b.hotness) return 1; |
| 102 | + if (b.hotness < a.hotness) return -1; |
| 103 | + return 0; |
| 104 | + }); |
| 105 | + |
| 106 | + $.each(repos, function (i, repo) { |
| 107 | + addRepo(repo); |
| 108 | + }); |
| 109 | + |
| 110 | + // Sort by most-recently pushed to. |
| 111 | + repos.sort(function (a, b) { |
| 112 | + if (a.pushed_at < b.pushed_at) return 1; |
| 113 | + if (b.pushed_at < a.pushed_at) return -1; |
| 114 | + return 0; |
| 115 | + }); |
| 116 | + |
| 117 | + $.each(repos.slice(0, 3), function (i, repo) { |
| 118 | + addRecentlyUpdatedRepo(repo); |
| 119 | + }); |
| 120 | + }); |
| 121 | + } |
109 | 122 | }); |
110 | | - }); |
| 123 | + } |
| 124 | + addRepos(); |
111 | 125 |
|
112 | 126 | $.getJSON("https://api.github.com/orgs/twitter/members?callback=?", function (result) { |
113 | 127 | var members = result.data; |
@@ -220,9 +234,9 @@ <h1>Twitter is built on open source software.</h1> |
220 | 234 | <div id="statistics" class="grid-1 alpha header"> |
221 | 235 | <h1>Statistics</h1> |
222 | 236 | <p> |
223 | | - <a href="https://github.com/twitter/repositories"><span id="num-repos"> </span> public repos</a> |
| 237 | + <a href="https://github.com/twitter/repositories"><span id="num-repos"><img src="assets/spinner.gif" /></span> public repos</a> |
224 | 238 | <br> |
225 | | - <a href="https://github.com/twitter"><span id="num-members"> </span> members</a> |
| 239 | + <a href="https://github.com/twitter"><span id="num-members"><img src="assets/spinner.gif" /></span> members</a> |
226 | 240 | </p> |
227 | 241 | <p class=" email" ><a href=" mailto:[email protected]" >[email protected]</a></p> |
228 | 242 | </div> |
|
0 commit comments