@@ -20,16 +20,20 @@ document.getElementsByClassName('brand')[0].textContent = short_title;
2020
2121let url_user = `https://api.github.com/users/${ github_user } ` ,
2222 url_repos = `${ url_user } /repos?sort=pushed&per_page=100` ,
23+ url_issues = `https://api.github.com/search/issues?q=user:${ github_user } &sort=updated&order=desc` ,
2324 months_short = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' . split ( ' ' ) ;
2425
2526if ( DEV ) {
2627 url_user = '/data/user.json' ;
2728 url_repos = '/data/repos.json' ;
29+ url_issues = '/data/issues.json' ;
2830}
2931
3032let coder = new Vue ( {
3133 el : '#coder' ,
3234 data : {
35+ activetab : 'repos' ,
36+ latest_issues : null ,
3337 repos : [ ] ,
3438 response : { } ,
3539 sort_orders : { } ,
@@ -122,6 +126,12 @@ let coder = new Vue({
122126 series : this . repo_types . values } ) ;
123127 } ,
124128 methods : {
129+ fetchIssues : function ( ) {
130+ this . $http . get ( url_issues ) . then ( response => {
131+ this . response . issues = response ;
132+ this . latest_issues = response . body . items ;
133+ } ) ;
134+ } ,
125135 fetchRepos : function ( ) {
126136 this . $http . get ( url_repos ) . then ( response => {
127137 this . response . repos = response ;
@@ -150,11 +160,17 @@ let coder = new Vue({
150160 repoRanking : function ( property ) {
151161 return this . repos_pushed . filter ( d => d [ property ] ) . sort ( ( a , b ) => b [ property ] - a [ property ] ) ;
152162 } ,
153- sortBy : function ( key , type = 'number' ) {
163+ showTab : function ( name ) {
164+ this . activetab = name ;
165+ if ( ! this . latest_issues ) {
166+ this . fetchIssues ( ) ;
167+ }
168+ } ,
169+ sortBy : function ( key , type = 'number' , property = 'repos' ) {
154170 let default_value = type === 'string' ? '' : 0 ;
155171 this . sort_key = key ;
156172 this . sort_orders [ key ] = ( this . sort_orders [ key ] || 1 ) * - 1 ;
157- this . repos . sort ( ( a , b ) => {
173+ this [ property ] . sort ( ( a , b ) => {
158174 let x = a [ key ] || default_value ,
159175 y = b [ key ] || default_value ;
160176 if ( type === 'string' ) {
0 commit comments