mirror of
https://github.com/Coldsmiles/infstarweb.git
synced 2026-04-23 02:30:41 +08:00
- Introduced fund_progress.txt to track server upgrade funding and vehicle replacement costs. - Created sponsors.txt to log sponsorship contributions with details including name, project, amount, and date. - Developed components.js for reusable UI components including navbar and footer. - Implemented data_utils.js for parsing sponsor data and calculating totals. - Added script.js for managing server status, crowdfunding display, and sponsor data fetching. - Created sponsor_script.js for detailed sponsor data management, filtering, and UI interactions. - Developed stats_script.js for player statistics display, including leaderboards and detailed player stats in a modal.
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
const DataUtils = {
|
|
parseSponsorsText: function(text) {
|
|
const sponsors = [];
|
|
|
|
if (!text) {
|
|
return sponsors;
|
|
}
|
|
|
|
const lines = text.trim().split('\n');
|
|
lines.forEach(line => {
|
|
const parts = line.split(',');
|
|
if (parts.length < 3) {
|
|
return;
|
|
}
|
|
|
|
const name = parts[0].trim();
|
|
const project = parts[1].trim();
|
|
const amountStr = parts[2].trim().replace('¥', '');
|
|
const amount = parseFloat(amountStr);
|
|
const date = parts[3] ? parts[3].trim() : '';
|
|
|
|
if (!isNaN(amount)) {
|
|
sponsors.push({ name, project, amount, date });
|
|
}
|
|
});
|
|
|
|
return sponsors;
|
|
},
|
|
|
|
buildSponsorTotals: function(sponsors) {
|
|
const totals = {};
|
|
|
|
sponsors.forEach(item => {
|
|
if (!totals[item.name]) {
|
|
totals[item.name] = 0;
|
|
}
|
|
totals[item.name] += item.amount;
|
|
});
|
|
|
|
return totals;
|
|
}
|
|
};
|