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

@ -1,82 +0,0 @@
"use strict";
// define global vabiable, each to be refactored and de-globalized 1-by-1
let grid = {}; // initial graph based on jittered square grid and data
let pack = {}; // packed graph and data
let seed;
let mapId;
let mapHistory = [];
let elSelected;
let notes = [];
let customization = 0;
let rulers;
let biomesData;
let nameBases;
// defined in main.js
let graphWidth;
let graphHeight;
let svgWidth;
let svgHeight;
let options = {};
let populationRate;
let distanceScale;
let urbanization;
let urbanDensity;
let statesNeutral;
// svg d3 selections
let svg,
defs,
viewbox,
scaleBar,
legend,
ocean,
oceanLayers,
oceanPattern,
lakes,
landmass,
texture,
terrs,
biomes,
cells,
gridOverlay,
coordinates,
compass,
rivers,
terrain,
relig,
cults,
regions,
statesBody,
statesHalo,
provs,
zones,
borders,
stateBorders,
provinceBorders,
routes,
roads,
trails,
searoutes,
temperature,
coastline,
ice,
prec,
population,
emblems,
labels,
icons,
burgLabels,
burgIcons,
anchors,
armies,
markers,
fogging,
ruler,
debug;

View file

@ -640,7 +640,7 @@ function togglePercentageMode() {
async function showHierarchy() {
if (customization) return;
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.87.01");
const HeirarchyTree = await import("../hierarchy-tree.js");
const getDescription = culture => {
const {name, type, rural, urban} = culture;

View file

@ -544,7 +544,7 @@ function togglePercentageMode() {
async function showHierarchy() {
if (customization) return;
const HeirarchyTree = await import("../hierarchy-tree.js?v=1.87.01");
const HeirarchyTree = await import("../hierarchy-tree.js");
const getDescription = religion => {
const {name, type, form, rural, urban} = religion;

View file

@ -490,7 +490,7 @@ async function parseLoadedData(data) {
{
// dynamically import and run auto-udpdate script
const versionNumber = parseFloat(params[0]);
const {resolveVersionConflicts} = await import("../dynamic/auto-update.js?v=06062022");
const {resolveVersionConflicts} = await import("../dynamic/auto-update.js");
resolveVersionConflicts(versionNumber);
}

View file

@ -1,10 +1,10 @@
import {last} from "utils/arrayUtils";
import {ERROR} from "config/logging";
import {locked} from "scripts/options/lock";
import {tip} from "scripts/tooltips";
import {rand, P, ra} from "utils/probabilityUtils";
import {capitalize} from "utils/stringUtils";
import {last} from "utils/arrayUtils";
import {vowel} from "utils/languageUtils";
import {ERROR} from "config/logging";
import {P, ra, rand} from "utils/probabilityUtils";
import {capitalize} from "utils/stringUtils";
window.Names = (function () {
let chains = [];

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();
}