global: multiple fixes

This commit is contained in:
nym21
2025-06-13 10:22:03 +02:00
parent 31110a740d
commit d7d77ae8f0
7 changed files with 145 additions and 140 deletions

View File

@@ -67,14 +67,14 @@ function initPackages() {
const imports = {
async signals() {
return import("../packages/solid-signals/wrapper.js").then((d) =>
d.default.then((d) => d)
d.default.then((d) => d),
);
},
async lightweightCharts() {
return window.document.fonts.ready.then(() =>
import("../packages/lightweight-charts/wrapper.js").then((d) =>
d.default.then((d) => d)
)
d.default.then((d) => d),
),
);
},
async leanQr() {
@@ -82,7 +82,7 @@ function initPackages() {
},
async ufuzzy() {
return import("../packages/ufuzzy/v1.0.18/script.js").then(
({ default: d }) => d
({ default: d }) => d,
);
},
};
@@ -596,7 +596,7 @@ function createUtils() {
window.history.pushState(
null,
"",
`${pathname}?${urlParams.toString()}`
`${pathname}?${urlParams.toString()}`,
);
} catch (_) {}
},
@@ -613,7 +613,7 @@ function createUtils() {
window.history.replaceState(
null,
"",
`${pathname}?${urlParams.toString()}`
`${pathname}?${urlParams.toString()}`,
);
} catch (_) {}
},
@@ -1246,8 +1246,8 @@ function createUtils() {
today.getUTCDate(),
0,
0,
0
)
0,
),
);
},
/**
@@ -1349,7 +1349,7 @@ function createUtils() {
*/
function getNumberOfDaysBetweenTwoDates(oldest, youngest) {
return Math.round(
Math.abs((youngest.getTime() - oldest.getTime()) / date.ONE_DAY_IN_MS)
Math.abs((youngest.getTime() - oldest.getTime()) / date.ONE_DAY_IN_MS),
);
}
@@ -1567,7 +1567,7 @@ function createVecsResources(signals, utils) {
const fetchedRecord = signals.createSignal(
/** @type {Map<string, {loading: boolean, at: Date | null, vec: Signal<T[] | null>}>} */ (
new Map()
)
),
);
return {
@@ -1615,7 +1615,7 @@ function createVecsResources(signals, utils) {
index,
id,
from,
to
to,
)
);
fetched.at = new Date();
@@ -1876,7 +1876,7 @@ function initWebSockets(signals, utils) {
window.document.addEventListener(
"visibilitychange",
reinitWebSocketIfDocumentNotHidden
reinitWebSocketIfDocumentNotHidden,
);
window.document.addEventListener("online", reinitWebSocket);
@@ -1885,7 +1885,7 @@ function initWebSockets(signals, utils) {
ws?.close();
window.document.removeEventListener(
"visibilitychange",
reinitWebSocketIfDocumentNotHidden
reinitWebSocketIfDocumentNotHidden,
);
window.document.removeEventListener("online", reinitWebSocket);
live.set(false);
@@ -1911,7 +1911,7 @@ function initWebSockets(signals, utils) {
symbol: ["BTC/USD"],
interval: 1440,
},
})
}),
);
});
@@ -1941,7 +1941,7 @@ function initWebSockets(signals, utils) {
/** @type {ReturnType<typeof createWebsocket<CandlestickData>>} */
const kraken1dCandle = createWebsocket((callback) =>
krakenCandleWebSocketCreator(callback)
krakenCandleWebSocketCreator(callback),
);
kraken1dCandle.open();
@@ -2000,7 +2000,7 @@ function main() {
}
const frame = window.document.getElementById(
/** @type {string} */ (input.value)
/** @type {string} */ (input.value),
);
if (!frame) {
@@ -2098,23 +2098,23 @@ function main() {
function initDark() {
const preferredColorSchemeMatchMedia = window.matchMedia(
"(prefers-color-scheme: dark)"
"(prefers-color-scheme: dark)",
);
const dark = signals.createSignal(
preferredColorSchemeMatchMedia.matches
preferredColorSchemeMatchMedia.matches,
);
preferredColorSchemeMatchMedia.addEventListener(
"change",
({ matches }) => {
dark.set(matches);
}
},
);
return dark;
}
const dark = initDark();
const qrcode = signals.createSignal(
/** @type {string | null} */ (null)
/** @type {string | null} */ (null),
);
function createLastHeightResource() {
@@ -2125,7 +2125,7 @@ function main() {
lastHeight.set(h);
},
/** @satisfies {Height} */ (5),
"height"
"height",
);
}
fetchLastHeight();
@@ -2145,21 +2145,18 @@ function main() {
env,
signals,
utils,
webSockets,
qrcode,
});
// const urlSelected = utils.url.pathnameToSelectedId();
// function createWindowPopStateEvent() {
// window.addEventListener("popstate", (event) => {
// const urlSelected = utils.url.pathnameToSelectedId();
// const option = options.list.find((option) => urlSelected === option.id);
// if (option) {
// options.selected.set(option);
// }
// });
// }
// createWindowPopStateEvent();
// window.addEventListener("popstate", (_) => {
// const urlSelected = utils.url.pathnameToSelectedId();
// const option = options.list.find(
// (option) => urlSelected === option.id,
// );
// if (option) {
// options.selected.set(option);
// }
// });
function initSelected() {
let firstRun = true;
@@ -2172,10 +2169,10 @@ function main() {
const owner = signals.getOwner();
const chartOption = signals.createSignal(
/** @type {ChartOption | null} */ (null)
/** @type {ChartOption | null} */ (null),
);
const simOption = signals.createSignal(
/** @type {SimulationOption | null} */ (null)
/** @type {SimulationOption | null} */ (null),
);
let previousElement = /** @type {HTMLElement | undefined} */ (
@@ -2186,6 +2183,7 @@ function main() {
let firstTimeLoadingSimulation = true;
signals.createEffect(options.selected, (option) => {
console.log(utils.url.pathnameToSelectedId(), option.id);
if (previousElement) {
previousElement.hidden = true;
utils.url.resetParams(option);
@@ -2222,10 +2220,10 @@ function main() {
webSockets,
vecsResources,
vecIdToIndexes,
})
)
)
)
}),
),
),
),
);
}
firstTimeLoadingChart = false;
@@ -2248,9 +2246,9 @@ function main() {
vecsResources,
option,
vecIdToIndexes,
})
)
)
}),
),
),
);
}
firstTimeLoadingTable = false;
@@ -2278,10 +2276,10 @@ function main() {
signals,
utils,
vecsResources,
})
)
)
)
}),
),
),
),
);
}
firstTimeLoadingSimulation = false;
@@ -2310,7 +2308,7 @@ function main() {
createMobileSwitchEffect();
utils.dom.onFirstIntersection(elements.aside, () =>
signals.runWithOwner(owner, initSelectedFrame)
signals.runWithOwner(owner, initSelectedFrame),
);
}
initSelected();
@@ -2388,7 +2386,7 @@ function main() {
if (indexes?.length) {
const maxIndex = Math.min(
(order || indexes).length - 1,
minIndex + RESULTS_PER_PAGE - 1
minIndex + RESULTS_PER_PAGE - 1,
);
list = Array(maxIndex - minIndex + 1);
@@ -2464,7 +2462,7 @@ function main() {
haystack,
needle,
undefined,
infoThresh
infoThresh,
);
if (!result?.[0]?.length || !result?.[1]) {
@@ -2472,7 +2470,7 @@ function main() {
haystack,
needle,
outOfOrder,
infoThresh
infoThresh,
);
}
@@ -2481,7 +2479,7 @@ function main() {
haystack,
needle,
outOfOrder,
infoThresh
infoThresh,
);
}
@@ -2490,7 +2488,7 @@ function main() {
haystack,
needle,
outOfOrder,
infoThresh
infoThresh,
);
}
@@ -2499,7 +2497,7 @@ function main() {
haystack,
needle,
undefined,
infoThresh
infoThresh,
);
}
@@ -2508,7 +2506,7 @@ function main() {
haystack,
needle,
outOfOrder,
infoThresh
infoThresh,
);
}
@@ -2591,7 +2589,7 @@ function main() {
shareDiv.hidden = false;
});
})
}),
);
}
initShare();
@@ -2613,7 +2611,7 @@ function main() {
localStorage.setItem(barWidthLocalStorageKey, String(width));
} else {
elements.main.style.width = elements.style.getPropertyValue(
"--default-main-width"
"--default-main-width",
);
localStorage.removeItem(barWidthLocalStorageKey);
}
@@ -2649,9 +2647,9 @@ function main() {
window.addEventListener("mouseleave", setResizeFalse);
}
initDesktopResizeBar();
})
)
)
}),
),
),
);
}
main();