2021-10-14 11:22:47 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import "./card-info-base.css";
|
2021-10-14 11:22:47 +02:00
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import { ModuleName, setupI18n } from "../lib/i18n";
|
|
|
|
import { checkNightMode } from "../lib/nightmode";
|
2021-10-14 11:22:47 +02:00
|
|
|
import CardInfo from "./CardInfo.svelte";
|
|
|
|
|
2022-01-16 06:05:35 +01:00
|
|
|
const i18n = setupI18n({
|
|
|
|
modules: [ModuleName.CARD_STATS, ModuleName.SCHEDULING, ModuleName.STATISTICS],
|
|
|
|
});
|
|
|
|
|
2022-11-03 02:37:47 +01:00
|
|
|
export async function setupCardInfo(
|
|
|
|
target: HTMLElement,
|
|
|
|
props = {},
|
|
|
|
): Promise<CardInfo> {
|
2021-10-14 11:22:47 +02:00
|
|
|
checkNightMode();
|
2022-01-16 06:05:35 +01:00
|
|
|
await i18n;
|
|
|
|
|
2022-11-03 02:37:47 +01:00
|
|
|
return new CardInfo({ target, props });
|
2022-01-16 06:05:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (window.location.hash.startsWith("#test")) {
|
|
|
|
// use #testXXXX where XXXX is card ID to test
|
|
|
|
const cardId = parseInt(window.location.hash.substr("#test".length), 10);
|
2022-07-12 02:34:48 +02:00
|
|
|
setupCardInfo(document.body).then(
|
|
|
|
(cardInfo: CardInfo): Promise<void> => cardInfo.updateStats(cardId),
|
2022-04-15 06:36:50 +02:00
|
|
|
);
|
2021-10-16 23:32:00 +02:00
|
|
|
}
|