|
@@ -23,10 +23,18 @@ document.querySelector('#fetch')!.addEventListener('click', async () => {
|
|
|
const cx = (document.querySelector('#cx') as HTMLInputElement).value;
|
|
const cx = (document.querySelector('#cx') as HTMLInputElement).value;
|
|
|
if (!(cx in warehouseNames))
|
|
if (!(cx in warehouseNames))
|
|
|
throw new Error(`invalid CX ${cx}`);
|
|
throw new Error(`invalid CX ${cx}`);
|
|
|
- const output = await calculate(username.value, apiKey.value, supplyForDays, cx as keyof typeof warehouseNames);
|
|
|
|
|
- console.log(output);
|
|
|
|
|
- localStorage.setItem('fio-username', username.value);
|
|
|
|
|
- localStorage.setItem('fio-api-key', apiKey.value);
|
|
|
|
|
|
|
+ const loader = document.querySelector('#loader') as HTMLElement;
|
|
|
|
|
+ loader.innerHTML = '';
|
|
|
|
|
+ loader.style.display = 'block';
|
|
|
|
|
+ try {
|
|
|
|
|
+ const output = await calculate(username.value, apiKey.value, supplyForDays, cx as keyof typeof warehouseNames);
|
|
|
|
|
+ console.log(output);
|
|
|
|
|
+ localStorage.setItem('fio-username', username.value);
|
|
|
|
|
+ localStorage.setItem('fio-api-key', apiKey.value);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ loader.style.display = 'none';
|
|
|
});
|
|
});
|
|
|
document.querySelector('#copy-xit-act')!.addEventListener('click', () => {
|
|
document.querySelector('#copy-xit-act')!.addEventListener('click', () => {
|
|
|
navigator.clipboard.writeText(xitAct.value);
|
|
navigator.clipboard.writeText(xitAct.value);
|
|
@@ -34,6 +42,9 @@ document.querySelector('#copy-xit-act')!.addEventListener('click', () => {
|
|
|
setupPopover();
|
|
setupPopover();
|
|
|
|
|
|
|
|
async function calculate(username: string, apiKey: string, supplyForDays: number, cx: keyof typeof warehouseNames): Promise<void> {
|
|
async function calculate(username: string, apiKey: string, supplyForDays: number, cx: keyof typeof warehouseNames): Promise<void> {
|
|
|
|
|
+ const tbody = document.querySelector('tbody')!;
|
|
|
|
|
+ tbody.innerHTML = '';
|
|
|
|
|
+
|
|
|
const prices = await getPrices(cx);
|
|
const prices = await getPrices(cx);
|
|
|
const planets = await getPlanets(username, apiKey);
|
|
const planets = await getPlanets(username, apiKey);
|
|
|
const avail = await warehouseInventory(username, apiKey, warehouseNames[cx]);
|
|
const avail = await warehouseInventory(username, apiKey, warehouseNames[cx]);
|
|
@@ -72,8 +83,6 @@ async function calculate(username: string, apiKey: string, supplyForDays: number
|
|
|
|
|
|
|
|
const toBuy: Record<string, number> = {};
|
|
const toBuy: Record<string, number> = {};
|
|
|
const priceLimits: Record<string, number> = {};
|
|
const priceLimits: Record<string, number> = {};
|
|
|
- const tbody = document.querySelector('tbody')!;
|
|
|
|
|
- tbody.innerHTML = '';
|
|
|
|
|
const format = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0}).format;
|
|
const format = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0}).format;
|
|
|
for (const m of materials) {
|
|
for (const m of materials) {
|
|
|
const tr = document.createElement('tr');
|
|
const tr = document.createElement('tr');
|