@@ -21,6 +21,26 @@ function getJSON(url, callback) {
21
21
xhr . send ( ) ;
22
22
}
23
23
24
+ function updatePremiumSponsors ( dataURL , rank ) {
25
+ let capRank = rank . charAt ( 0 ) . toUpperCase ( ) + rank . slice ( 1 ) ;
26
+ getJSON ( dataURL + `/sponsors${ capRank } .json` , function ( err , sponsors ) {
27
+ const sponsorsDiv = document . getElementById ( `${ rank } -sponsors` ) ;
28
+ if ( sponsors . length > 0 ) {
29
+ let html = '' ;
30
+ html += `<b>${ capRank } sponsors</b><p>`
31
+ sponsors . forEach ( function ( sponsor ) {
32
+ html += `
33
+ <a href="${ sponsor . url } " target="_blank" title="${ sponsor . name } ">
34
+ <img alt="${ sponsor . name } " src="${ sponsor . image } " style="height: ${ sponsor . imageHeight } px;">
35
+ </a>
36
+ `
37
+ } ) ;
38
+ html += '</p>'
39
+ sponsorsDiv . innerHTML = html ;
40
+ }
41
+ } ) ;
42
+ }
43
+
24
44
function updateInsidersPage ( author_username ) {
25
45
const sponsorURL = `https://github.com/sponsors/${ author_username } `
26
46
const dataURL = `https://raw.githubusercontent.com/${ author_username } /sponsors/main` ;
@@ -48,20 +68,7 @@ function updateInsidersPage(author_username) {
48
68
}
49
69
} ) ;
50
70
} ) ;
51
- getJSON ( dataURL + '/sponsorsBronze.json' , function ( err , sponsors ) {
52
- const bronzeSponsors = document . getElementById ( "bronze-sponsors" ) ;
53
- if ( sponsors ) {
54
- let html = '' ;
55
- html += '<b>Bronze sponsors</b><p>'
56
- sponsors . forEach ( function ( sponsor ) {
57
- html += `
58
- <a href="${ sponsor . url } " target="_blank" title="${ sponsor . name } ">
59
- <img alt="${ sponsor . name } " src="${ sponsor . image } " style="height: ${ sponsor . imageHeight } px;">
60
- </a>
61
- `
62
- } ) ;
63
- html += '</p>'
64
- bronzeSponsors . innerHTML = html ;
65
- }
66
- } ) ;
71
+ updatePremiumSponsors ( dataURL , "gold" ) ;
72
+ updatePremiumSponsors ( dataURL , "silver" ) ;
73
+ updatePremiumSponsors ( dataURL , "bronze" ) ;
67
74
}
0 commit comments