|
|
@@ -12,16 +12,17 @@ const apiKey = document.querySelector('#api-key') as HTMLInputElement;
|
|
|
}
|
|
|
document.querySelector('#fetch')!.addEventListener('click', async () => {
|
|
|
const supplyForDays = parseInt((document.querySelector('#days') as HTMLInputElement).value, 10);
|
|
|
- const output = await calculate(username.value, apiKey.value, supplyForDays);
|
|
|
+ const cx = (document.querySelector('#cx') as HTMLInputElement).value;
|
|
|
+ const output = await calculate(username.value, apiKey.value, supplyForDays, cx);
|
|
|
console.log(output);
|
|
|
localStorage.setItem('fio-username', username.value);
|
|
|
localStorage.setItem('fio-api-key', apiKey.value);
|
|
|
});
|
|
|
setupPopover();
|
|
|
|
|
|
-async function calculate(username: string, apiKey: string, supplyForDays: number): Promise<void> {
|
|
|
+async function calculate(username: string, apiKey: string, supplyForDays: number, cx: string): Promise<void> {
|
|
|
const [prices, planets, avail, {bids, orders}] = await Promise.all([
|
|
|
- getPrices(),
|
|
|
+ getPrices(cx),
|
|
|
getPlanets(username, apiKey),
|
|
|
warehouseInventory(username, apiKey),
|
|
|
getBids(username, apiKey)
|
|
|
@@ -86,11 +87,11 @@ async function calculate(username: string, apiKey: string, supplyForDays: number
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function getPrices() {
|
|
|
+async function getPrices(cx: string) {
|
|
|
const rawPrices= await fetch('https://refined-prun.github.io/refined-prices/all.json').then(r => r.json());
|
|
|
const prices = new Map<string, RawPrice>();
|
|
|
for (const p of rawPrices)
|
|
|
- if (p.ExchangeCode === 'IC1')
|
|
|
+ if (p.ExchangeCode === cx)
|
|
|
prices.set(p.MaterialTicker, p);
|
|
|
return prices;
|
|
|
}
|