moved to API
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
let config = {
|
||||
getAlphabets: () => null,
|
||||
getGematriaDb: () => null,
|
||||
getGematriaElements: () => ({
|
||||
cipherEl: null,
|
||||
inputEl: null,
|
||||
@@ -24,6 +25,10 @@
|
||||
return config.getAlphabets?.() || null;
|
||||
}
|
||||
|
||||
function getConfiguredGematriaDb() {
|
||||
return config.getGematriaDb?.() || null;
|
||||
}
|
||||
|
||||
function getElements() {
|
||||
return config.getGematriaElements?.() || {
|
||||
cipherEl: null,
|
||||
@@ -169,14 +174,20 @@
|
||||
return state.loadingPromise;
|
||||
}
|
||||
|
||||
state.loadingPromise = fetch("data/gematria-ciphers.json")
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load gematria ciphers (${response.status})`);
|
||||
state.loadingPromise = Promise.resolve()
|
||||
.then(async () => {
|
||||
const configuredDb = getConfiguredGematriaDb();
|
||||
if (configuredDb) {
|
||||
return configuredDb;
|
||||
}
|
||||
return response.json();
|
||||
|
||||
const referenceData = await window.TarotDataService?.loadReferenceData?.();
|
||||
return referenceData?.gematriaCiphers || null;
|
||||
})
|
||||
.then((db) => {
|
||||
if (!db) {
|
||||
throw new Error("Gematria cipher data unavailable from API.");
|
||||
}
|
||||
state.db = sanitizeGematriaDb(db);
|
||||
return state.db;
|
||||
})
|
||||
@@ -342,6 +353,11 @@
|
||||
...config,
|
||||
...nextConfig
|
||||
};
|
||||
|
||||
const configuredDb = getConfiguredGematriaDb();
|
||||
if (configuredDb) {
|
||||
state.db = sanitizeGematriaDb(configuredDb);
|
||||
}
|
||||
}
|
||||
|
||||
window.AlphabetGematriaUi = {
|
||||
|
||||
Reference in New Issue
Block a user