refactor: first build

This commit is contained in:
Azgaar 2022-07-05 22:55:03 +03:00
parent 3018d94618
commit 41180c57bf
26 changed files with 37 additions and 35 deletions

View file

@ -1029,19 +1029,19 @@ function refreshAllEditors() {
// dynamically loaded editors
export async function editStates() {
if (customization) return;
const Editor = await import("../dynamic/editors/states-editor.js?v=12062022");
const Editor = await import("../dynamic/editors/states-editor.js");
Editor.open();
}
export async function editCultures() {
if (customization) return;
const Editor = await import("../dynamic/editors/cultures-editor.js?v=1.87.01");
const Editor = await import("../dynamic/editors/cultures-editor.js");
Editor.open();
}
export async function editReligions() {
if (customization) return;
const Editor = await import("../dynamic/editors/religions-editor.js?v=1.87.01");
const Editor = await import("../dynamic/editors/religions-editor.js");
Editor.open();
}

View file

@ -87,7 +87,7 @@ document
// show popup with a list of Patreon supportes (updated manually)
async function showSupporters() {
const {supporters} = await import("../dynamic/supporters.js?v=19062022");
const {supporters} = await import("../dynamic/supporters.js");
alertMessage.innerHTML =
"<ul style='column-count: 5; column-gap: 2em'>" + supporters.map(n => `<li>${n}</li>`).join("") + "</ul>";
$("#alert").dialog({
@ -651,7 +651,7 @@ function changeEra() {
}
async function openTemplateSelectionDialog() {
const HeightmapSelectionDialog = await import("../dynamic/heightmap-selection.js?v=1.87.00");
const HeightmapSelectionDialog = await import("../dynamic/heightmap-selection.js");
HeightmapSelectionDialog.open();
}

View file

@ -1,3 +1,4 @@
import {ERROR} from "config/logging";
import {tip} from "scripts/tooltips";
import {isJsonValid} from "utils/stringUtils";
import {byId} from "utils/shorthands";
@ -56,20 +57,18 @@ async function getStylePreset(desiredPreset) {
}
}
const style = await fetchSystemPreset(presetToLoad);
const style = await importSystemPreset(presetToLoad);
return [presetToLoad, style];
}
async function fetchSystemPreset(preset) {
const style = await fetch(`./styles/${preset}.json`)
.then(res => res.json())
.catch(err => {
ERROR && console.error("Error on loading style preset", preset, err);
return null;
});
async function importSystemPreset(preset) {
const style = await import(`../../assets/styles/${preset}.json`).catch(err => {
ERROR && console.error("Error on loading style preset", preset, err);
return null;
});
if (!style) throw new Error("Cannot fetch style preset", preset);
return style;
if (!style.default) throw new Error("Cannot fetch style preset", preset);
return style.default;
}
function applyStyle(style) {

View file

@ -869,6 +869,6 @@ function viewCellDetails() {
}
async function overviewCharts() {
const Overview = await import("../dynamic/overview/charts-overview.js?v=1.87.03");
const Overview = await import("../dynamic/overview/charts-overview.js");
Overview.open();
}