Skip to content

Commit 4efd396

Browse files
committed
feature: streamline banner data processing by removing redundant API calls
1 parent cc5447b commit 4efd396

File tree

1 file changed

+29
-48
lines changed

1 file changed

+29
-48
lines changed

script.js

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,54 +1275,35 @@ let banners = {
12751275
}
12761276

12771277
window.addEventListener('load', function() {
1278-
fetch('https://genshinlist.com/api/characters')
1279-
.then(response => response.json())
1280-
.then(data => {
1281-
characters = data;
1282-
console.log('Character data:', characters);
1283-
fetch('https://genshinlist.com/api/weapons')
1284-
.then(response => response.json())
1285-
.then(data => {
1286-
weapons = data;
1287-
console.log('Weapons data:', weapons);
1288-
banners.standard.fiveStars = characters.filter((c) => {
1289-
return c.rarity == 5 && !['Venti', 'Klee', 'Xiao', 'Tartaglia', 'Zhongli'].includes(c.name);
1290-
}).concat(weapons.filter((c) => {
1291-
return c.rarity == 5;
1292-
}));
1293-
banners.standard.fourStars = characters.filter((c) => {
1294-
return c.rarity == 4;
1295-
}).concat(weapons.filter((c) => {
1296-
return c.rarity == 4;
1297-
}));
1298-
banners.standard.threeStars = weapons.filter((c) => {
1299-
return c.rarity == 3;
1300-
});
1301-
banners.venti.featured.fiveStar = characters.filter((c) => {
1302-
return c.name == 'Venti';
1303-
});
1304-
banners.venti.featured.fourStars = characters.filter((c) => {
1305-
return c.rarity == 4 && ['Fischl', 'Sucrose', 'Xiangling'].includes(c.name);
1306-
});
1307-
banners.venti.regular.fiveStars = characters.filter((c) => {
1308-
return c.rarity == 5 && !['Venti', 'Klee', 'Xiao', 'Tartaglia', 'Zhongli'].includes(c.name);
1309-
});
1310-
banners.venti.regular.fourStars = characters.filter((c) => {
1311-
return c.rarity == 4 && !['Kaeya', 'Lisa', 'Amber', 'Fischl', 'Sucrose', 'Xiangling'].includes(c.name);
1312-
}).concat(weapons.filter((c) => {
1313-
return c.rarity == 4;
1314-
}));
1315-
banners.venti.regular.threeStars = weapons.filter((c) => {
1316-
return c.rarity == 3;
1317-
});
1318-
console.log(banners)
1319-
})
1320-
.catch(error => {
1321-
console.error('Error fetching character data:', error);
1322-
});
1323-
})
1324-
.catch(error => {
1325-
console.error('Error fetching character data:', error);
1278+
banners.standard.fiveStars = characters.filter((c) => {
1279+
return c.rarity == 5 && !['Venti', 'Klee', 'Xiao', 'Tartaglia', 'Zhongli'].includes(c.name);
1280+
}).concat(weapons.filter((c) => {
1281+
return c.rarity == 5;
1282+
}));
1283+
banners.standard.fourStars = characters.filter((c) => {
1284+
return c.rarity == 4;
1285+
}).concat(weapons.filter((c) => {
1286+
return c.rarity == 4;
1287+
}));
1288+
banners.standard.threeStars = weapons.filter((c) => {
1289+
return c.rarity == 3;
1290+
});
1291+
banners.venti.featured.fiveStar = characters.filter((c) => {
1292+
return c.name == 'Venti';
1293+
});
1294+
banners.venti.featured.fourStars = characters.filter((c) => {
1295+
return c.rarity == 4 && ['Fischl', 'Sucrose', 'Xiangling'].includes(c.name);
1296+
});
1297+
banners.venti.regular.fiveStars = characters.filter((c) => {
1298+
return c.rarity == 5 && !['Venti', 'Klee', 'Xiao', 'Tartaglia', 'Zhongli'].includes(c.name);
1299+
});
1300+
banners.venti.regular.fourStars = characters.filter((c) => {
1301+
return c.rarity == 4 && !['Kaeya', 'Lisa', 'Amber', 'Fischl', 'Sucrose', 'Xiangling'].includes(c.name);
1302+
}).concat(weapons.filter((c) => {
1303+
return c.rarity == 4;
1304+
}));
1305+
banners.venti.regular.threeStars = weapons.filter((c) => {
1306+
return c.rarity == 3;
13261307
});
13271308
});
13281309

0 commit comments

Comments
 (0)