@@ -9,25 +9,52 @@ function generateHtmlRow(repoData)
99}
1010
1111
12- function createOrgTable ( orgName , tableContainer )
12+ var repos = [ ] ;
13+
14+ function fetchAllRepositories ( orgName , page )
1315{
14- var html = "" ;
16+ return new Promise ( function ( resolve , reject )
17+ {
18+ queryAPIByOrg ( API_REPOSITORIES + "?page=" + page , orgName ,
19+ function ( data )
20+ {
21+ repos . push ( ...data ) ;
1522
16- queryAPIByOrg ( API_REPOSITORIES , orgName ,
17- function ( data )
18- {
19- for ( var i = 0 ; i < data . length ; i ++ )
23+ if ( data . length === 30 )
24+ {
25+ fetchAllRepositories ( orgName , page + 1 ) . then ( function ( )
26+ {
27+ resolve ( ) ;
28+ } )
29+ }
30+ else {
31+ resolve ( ) ;
32+ }
33+ } ,
34+ function ( error )
2035 {
21- html += generateHtmlRow ( data [ i ] ) ;
22- }
36+ //console.log("Unable to load table data");
37+ } ) ;
38+ } ) ;
39+ }
40+
41+
42+ function createOrgTable ( orgName , tableContainer )
43+ {
44+ var html = "" ;
2345
24- $ ( "#" + tableContainer ) . html ( html ) ;
25- $ ( '#dataTable' ) . DataTable ( ) ;
2646
27- } ,
28- function ( error )
47+ fetchAllRepositories ( orgName , 1 ) . then ( function ( )
48+ {
49+ for ( var i = 0 ; i < repos . length ; i ++ )
2950 {
30- console . log ( "Unable to load table data" ) ;
31- } ) ;
51+ html += generateHtmlRow ( repos [ i ] ) ;
52+ }
3253
54+ $ ( "#" + tableContainer ) . html ( html ) ;
55+ $ ( '#dataTable' ) . DataTable ( ) ;
56+ } ) . catch ( function ( error )
57+ {
58+ //console.log("Unable to create table");
59+ } ) ;
3360}
0 commit comments