Skip to content

Commit

Permalink
Rewrote the donation format
Browse files Browse the repository at this point in the history
  • Loading branch information
NeeEoo committed Nov 8, 2024
1 parent bec6166 commit 5b5e31a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 53 deletions.
120 changes: 81 additions & 39 deletions donators.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,114 @@
{
"name": "snoot",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/53510b90-cd66-4098-8432-455b6764f352_a67bc119-2bd6-40e6-9766-7b6139e35348.png",
"amount": 50,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 50,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "Saladjusted",
"profilePicture": "https://ko-fi.com/img/anon9.png?v=10",
"amount": 4,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 4,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "luscious",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/tiny_9aca08fd-3d01-4c82-ae8e-29bdda307f4c.png",
"amount": 3,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 3,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "Kai :3",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/faab8524-8013-4a4d-933f-de399d4b65fd_88bced50-34b5-419d-81e5-6fb732e61038.png",
"amount": 3,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 3,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "~ Care",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/1f73237b-a38f-499c-8c49-9b97f3ed1ec3_c8fd4a56-829d-48cd-849c-e1e84abe18e9.jpg",
"amount": 3,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 3,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "Pootis TF2",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/46ec1c3e-0b47-4173-8483-9acde233082c_ac05ceff-7fd5-412b-a3d0-c104565685ca.png",
"amount": 100,
"currency": "$",
"hasMembership": 0
"hasMembership": false,
"donations": [
{
"amount": 100,
"currency": "$",
"type": "donation",
"hasMembership": false
}
]
},
{
"name": "Moromaniac",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/33531ebf-09c7-4a49-b788-9286a13da1bc_9e1311c7-e9a3-4aae-8c41-8383158670e1.png",
"amount": 3,
"currency": "$",
"hasMembership": 0
"hasMembership": true,
"donations": [
{
"amount": 3,
"currency": "$",
"type": "donation"
},
{
"amount": 3,
"currency": "$",
"type": "donation"
},
{
"amount": 5,
"currency": "$",
"type": "membership"
}
]
},
{
"name": "CrimsonIsStupid",
"profilePicture": "https://ko-fi.com/img/anon7.png?v=10",
"amount": 5,
"currency": "$",
"hasMembership": 0
},
{
"name": "Moromaniac",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/33531ebf-09c7-4a49-b788-9286a13da1bc_9e1311c7-e9a3-4aae-8c41-8383158670e1.png",
"amount": 3,
"currency": "$",
"hasMembership": 0
},
{
"name": "Moromaniac",
"profilePicture": "https://storage.ko-fi.com/cdn/useruploads/post/33531ebf-09c7-4a49-b788-9286a13da1bc_9e1311c7-e9a3-4aae-8c41-8383158670e1.png",
"amount": 5,
"currency": "$",
"hasMembership": 1
"hasMembership": false,
"donations": [
{
"amount": 5,
"currency": "$",
"type": "donation"
}
]
}
]
}
}
43 changes: 30 additions & 13 deletions src/pages/index.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,42 @@ function buildHtml(_pageDir, _exportPath) {
var obj = {
name: donator.name,
profilePicture: donator.profilePicture,
amount: donator.amount,
currency: donator.currency,
hasMembership: donator.hasMembership != 0
hasMembership: donator.hasMembership,
donations: []
};
var existingDonators = donators.filter(d => d.name == obj.name);
if(existingDonators.length > 0) {
for(const donator of existingDonators) {
obj.amount += donator.amount;
obj.hasMembership = obj.hasMembership || donator.hasMembership;
donators.splice(donators.indexOf(donator), 1);
}
var amounts = {};
var usd = 0.0;
for(const donation of donator.donations) {
obj.donations.push({
amount: donation.amount,
currency: donation.currency,
type: donation.type
});
amounts[donation.currency] = (amounts[donation.currency] ?? 0) + donation.amount;

usd += donation.usdAmount ?? donation.amount;
}

var amountString = [];
for(const currency in amounts) {
amountString.push(amounts[currency] + " " + currency);
}
donators.push(obj);
amountString = amountString.join(", ");

var siteObj = {
name: donator.name,
profilePicture: donator.profilePicture,
amount: usd + " $",//amountString,
totalAmount: usd,
hasMembership: obj.hasMembership
};
donators.push(siteObj);
if(donator.hasMembership) {
members.push(obj);
members.push(siteObj);
}
}

donators.sort((a, b) => b.amount - a.amount);
donators.sort((a, b) => b.totalAmount - a.totalAmount);

var path = "./src/pages/index.html";
var outpath = exportPath + "index.html";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h2>Donators</h2>
<img src="{{profilePicture}}" alt="{{name}}" width="32" height="32">
<div class="donator-info">
<span>{{name}}</span>
<span>{{amount}} {{currency}}</span>
<span>{{amount}}</span>
</div>
</div>
{{/donators}}
Expand Down

0 comments on commit 5b5e31a

Please sign in to comment.