|
|
@@ -1,8 +1,10 @@
|
|
|
import {setupPopover} from './popover';
|
|
|
|
|
|
-const profits: Promise<Profit[]> = (async function () {
|
|
|
- const response = await fetch('roi.json');
|
|
|
- return await response.json();
|
|
|
+const roi: Promise<{lastModified: Date, profits: Profit[]}> = (async function () {
|
|
|
+ const response = await fetch('https://prun.raylu.net/roi.json');
|
|
|
+ const lastModified = new Date(response.headers.get('last-modified')!);
|
|
|
+ const profits = await response.json();
|
|
|
+ return {lastModified, profits};
|
|
|
})();
|
|
|
|
|
|
const lowVolume = document.querySelector('#low-volume') as HTMLInputElement;
|
|
|
@@ -13,7 +15,9 @@ async function render() {
|
|
|
const formatWhole = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0}).format;
|
|
|
const tbody = document.querySelector('tbody')!;
|
|
|
tbody.innerHTML = '';
|
|
|
- for (const p of await profits) {
|
|
|
+
|
|
|
+ const {lastModified, profits} = await roi;
|
|
|
+ for (const p of profits) {
|
|
|
const volumeRatio = p.output_per_day / p.average_traded_7d;
|
|
|
if (!lowVolume.checked && volumeRatio > 0.05) {
|
|
|
continue;
|
|
|
@@ -38,6 +42,8 @@ async function render() {
|
|
|
output.dataset.tooltip = p.recipe;
|
|
|
tbody.appendChild(tr);
|
|
|
}
|
|
|
+ document.getElementById('last-updated')!.textContent =
|
|
|
+ `last updated: ${lastModified.toLocaleString(undefined, {dateStyle: 'full', timeStyle: 'long', hour12: false})}`;
|
|
|
}
|
|
|
|
|
|
function color(n: number, low: number, high: number): string {
|