|
| 1 | +function addSponsor(divId, member, size) { |
| 2 | + div = document.getElementById(divId); |
| 3 | + var a = document.createElement('a'); |
| 4 | + a.setAttribute('href', member.website || member.profile || '#'); |
| 5 | + var img = document.createElement('img'); |
| 6 | + img.setAttribute('src', member.image || 'img/missing-avatar.svg'); |
| 7 | + if (size) { |
| 8 | + img.setAttribute('height', size); |
| 9 | + img.setAttribute('width', size); |
| 10 | + } |
| 11 | + img.setAttribute('alt', member.name); |
| 12 | + img.setAttribute('style', 'margin:6px;'); |
| 13 | + if (member.marginBottom) |
| 14 | + img.setAttribute('style', img.getAttribute('style') + 'margin-bottom:' + member.marginBottom + 'px;') |
| 15 | + a.appendChild(img); |
| 16 | + div.appendChild(a); |
| 17 | +}; |
| 18 | + |
| 19 | +const PlatinumSize = 98; |
| 20 | +const GoldSize = 76; |
| 21 | +const SilverSize = 60; |
| 22 | +const BackerSize = 45; |
| 23 | +const ContributorSize = 36; |
| 24 | + |
| 25 | +var sponsors = function() { |
| 26 | + var xhr = new XMLHttpRequest(); |
| 27 | + xhr.open('GET', 'https://opencollective.com/typelevel/members/all.json', true); |
| 28 | + xhr.responseType = 'json'; |
| 29 | + xhr.onload = function() { |
| 30 | + var status = xhr.status; |
| 31 | + if (status === 200) { |
| 32 | + for(i = 0; i < xhr.response.length; i++) { |
| 33 | + var member = xhr.response[i]; |
| 34 | + if (member.isActive) { |
| 35 | + switch (member.tier) { |
| 36 | + case 'Platinum Sponsor': |
| 37 | + addSponsor('platinum-sponsors', member, PlatinumSize); |
| 38 | + case 'Gold Sponsor': |
| 39 | + addSponsor('gold-sponsors', member, GoldSize); |
| 40 | + case 'Silver Sponsor': |
| 41 | + addSponsor('silver-sponsors', member, SilverSize); |
| 42 | + case 'backer': |
| 43 | + addSponsor('backers', member, BackerSize); |
| 44 | + break; |
| 45 | + default: |
| 46 | + if (member.totalAmountDonated > 0) { |
| 47 | + addSponsor('other-contributors', member, ContributorSize); |
| 48 | + } |
| 49 | + } |
| 50 | + }; |
| 51 | + } |
| 52 | + } |
| 53 | + }; |
| 54 | + xhr.send(); |
| 55 | +}; |
| 56 | +sponsors(); |
| 57 | +// Add sponsors who predate open collective |
| 58 | +addSponsor('gold-sponsors', { |
| 59 | + name: "47 Degrees", |
| 60 | + website: "https://47deg.com", |
| 61 | + image: "https://typelevel.org/cats/img/sponsors/47_degree.png" |
| 62 | +}); |
| 63 | +addSponsor('gold-sponsors', { |
| 64 | + name: "Iterators", |
| 65 | + website: "https://iteratorshq.com", |
| 66 | + image: "https://typelevel.org/cats/img/sponsors/iterators.png", |
| 67 | + marginBottom: 20 |
| 68 | +}); |
| 69 | +addSponsor('gold-sponsors', { |
| 70 | + name: "Triplequote", |
| 71 | + website: "https://triplequote.com", |
| 72 | + image: "https://typelevel.org/cats/img/sponsors/triplequote.png", |
| 73 | + marginBottom: 20 |
| 74 | +}); |
| 75 | +addSponsor('gold-sponsors', { |
| 76 | + name: "Underscore", |
| 77 | + website: "https://underscore.com", |
| 78 | + image: "https://typelevel.org/cats/img/sponsors/underscore.png", |
| 79 | + marginBottom: 10 |
| 80 | +}); |
| 81 | +addSponsor('silver-sponsors', { |
| 82 | + name: "Ebiznext", |
| 83 | + website: "https://ebiznext.com", |
| 84 | + image: "https://typelevel.org/cats/img/sponsors/ebiznext.png", |
| 85 | + marginBottom: 10 |
| 86 | +}); |
| 87 | +addSponsor('silver-sponsors', { |
| 88 | + name: "Inner Product", |
| 89 | + website: "https://inner-product.com", |
| 90 | + image: "https://typelevel.org/cats/img/sponsors/inner-product.png" |
| 91 | +}); |
| 92 | +addSponsor('silver-sponsors', { |
| 93 | + name: "Evolution Gaming Engineering", |
| 94 | + website: "https://evolutiongaming.com", |
| 95 | + image: "https://typelevel.org/cats/img/sponsors/evolution_gaming_engineering.png" |
| 96 | +}); |
0 commit comments