supports.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $(function () {
  2. function createSupportItem (item) {
  3. if (!item.image) {
  4. item.image = 'https://images.opencollective.com/' + item.profile.split('/').pop() + '/avatar.png'
  5. }
  6. if (!item.website) {
  7. item.website = item.profile || ''
  8. }
  9. item.website = item.website.split(' ')[0]
  10. return [
  11. '<a class="support-item" href="' + item.website + '" target="_blank" title="$' + item.totalAmountDonated + ' by ' + item.name + '">',
  12. '<img class="support-' + (item.classes || 'silver') + '-avatar" src="' + item.image + '" alt="' + item.name + '">',
  13. '</a>'
  14. ].join('')
  15. }
  16. $.getJSON('https://examples.wenzhixin.net.cn/opencollective/supports.json', function (res) {
  17. var ranks = [
  18. {
  19. title: 'Gold',
  20. minimum: 200
  21. },
  22. {
  23. title: 'Bronze',
  24. minimum: 20,
  25. maximum: 200
  26. },
  27. {
  28. title: 'Backer',
  29. maximum: 20
  30. }
  31. ]
  32. ranks.forEach(function (rank) {
  33. rank.supports = res.filter(function (row) {
  34. return row.totalDonations >= (rank.minimum || 0) &&
  35. row.totalDonations < (rank.maximum || Number.MAX_VALUE)
  36. })
  37. })
  38. new window.Vue({
  39. el: '#supports',
  40. data: {
  41. ranks: ranks
  42. }
  43. })
  44. $('#supports').show()
  45. })
  46. })