From 3dedc0329ff113306753da4320cfe7f542978edd Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sat, 12 Aug 2023 17:09:59 +0200 Subject: [PATCH 1/6] System: add AV to gallery dropdown dropdown --- src/pages/system/system.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/system/system.ts b/src/pages/system/system.ts index 90c53f16..96d2c9d8 100644 --- a/src/pages/system/system.ts +++ b/src/pages/system/system.ts @@ -825,6 +825,7 @@ export function civCatalog() { export function generateGalleryArray() { const array: Array = [ '', + 'Analysis Visor', 'System Exploration Guide', 'System Page', 'Default SS Multi-Tool', From bb932e53a978d249e3d0c702dba114383e66260d Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 13 Aug 2023 20:31:35 +0200 Subject: [PATCH 2/6] fix #391 --- src/common.ts | 5 +++++ src/miscLogic/planetMoonLogic.ts | 7 ++++++- src/pages/fauna/elementFunctions.ts | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/common.ts b/src/common.ts index fac8f239..11903109 100644 --- a/src/common.ts +++ b/src/common.ts @@ -1238,4 +1238,9 @@ export function getWormAlbum(civShort: string): string { return "EisHub Shaihuluda"; } return ''; +} + +export function limitCreatureSize(input: HTMLInputElement) { + const firstLetter = input.value.substring(0, 1); + input.maxLength = firstLetter === '-' ? 4 : 3; // NoSonar negative numbers must have a limit of 4 to allow for `-0.1`. Else use 3 for `0.1` } \ No newline at end of file diff --git a/src/miscLogic/planetMoonLogic.ts b/src/miscLogic/planetMoonLogic.ts index 0190395d..68558b46 100644 --- a/src/miscLogic/planetMoonLogic.ts +++ b/src/miscLogic/planetMoonLogic.ts @@ -2,7 +2,7 @@ * @fileoverview Provides functions that can be used by Planet and Moon pages. */ -import { addDomAsElement, extractNumber, forceDatalist, getChildIndex, getWormAlbum, image, loadHTML, oddEven, removeSection, removeSpecificSection, sanitiseString, setDropdownOptions, sortObj, toggleSection, wikiCode } from '../common'; +import { addDomAsElement, extractNumber, forceDatalist, getChildIndex, getWormAlbum, image, limitCreatureSize, loadHTML, oddEven, removeSection, removeSpecificSection, sanitiseString, setDropdownOptions, sortObj, toggleSection, wikiCode } from '../common'; import { globalElements, globalFunctions, links, pageData } from '../variables/objects'; import creatureInputs from '../htmlSnippets/creatureInputs.html?raw'; import floraInputs from '../htmlSnippets/floraInputs.html?raw'; @@ -247,6 +247,11 @@ export function addFauna(element: HTMLButtonElement) { handler: 'change', func: function () { addGenus(this as unknown as HTMLSelectElement) } }, + { + element: 'creaturePropInput', + handler: 'input', + func: function () { limitCreatureSize(this as unknown as HTMLInputElement) } + }, ] const inputDom = loadHTML(creatureInputs, { i }, evtListeners) as Document; diff --git a/src/pages/fauna/elementFunctions.ts b/src/pages/fauna/elementFunctions.ts index d1249485..17b99963 100644 --- a/src/pages/fauna/elementFunctions.ts +++ b/src/pages/fauna/elementFunctions.ts @@ -1,4 +1,4 @@ -import { addInfoBullet, enableTextMarking, hideOrgName, numberError } from "../../common"; +import { addInfoBullet, enableTextMarking, hideOrgName, limitCreatureSize, numberError } from "../../common"; import { planetMoonSentence } from "../../miscLogic/locationLogic"; import { toggleRedirect } from "../../modules/actions"; import { albumDiscoverer, albumName, albumOther } from "../../modules/albumactions"; @@ -52,7 +52,7 @@ const creatureElementFunctions: ElementFunctions = [ }, { element: ['heightInput', 'height2Input'], - func: function () { genderProps("height", "height2"); albumOther(); numberError(this as unknown as HTMLInputElement) } + func: function () { genderProps("height", "height2"); albumOther(); numberError(this as unknown as HTMLInputElement); limitCreatureSize(this as unknown as HTMLInputElement) } }, { element: ['weightInput', 'weight2Input'], From 9ce112b49e9bbee5d1ff8fb52de3f0a3129f19a3 Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 13 Aug 2023 20:40:28 +0200 Subject: [PATCH 3/6] fix 0 value in creature height input --- src/pages/fauna/fauna.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/fauna/fauna.ts b/src/pages/fauna/fauna.ts index e84ad614..f0e50cc8 100644 --- a/src/pages/fauna/fauna.ts +++ b/src/pages/fauna/fauna.ts @@ -244,8 +244,8 @@ export function genderProps(property1Name: string, property2Name: string) { // adds .0 let property1Number, property2Number; if (property1Name != 'gender') { - property1Number = parseFloat(property1Value) ? parseFloat(property1Value).toFixed(1) : ''; - property2Number = parseFloat(property2Value) ? parseFloat(property2Value).toFixed(1) : ''; + property1Number = isNaN(parseFloat(property1Value)) ? '' : parseFloat(property1Value).toFixed(1); + property2Number = isNaN(parseFloat(property2Value)) ? '' : parseFloat(property2Value).toFixed(1); } const property1Data = property1Number ?? property1Value; From b1eacb08facef274bd6d8eb5bad42a1a1f67c22b Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 13 Aug 2023 20:42:15 +0200 Subject: [PATCH 4/6] fix #390 --- src/miscLogic/celestialobjectslogic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miscLogic/celestialobjectslogic.ts b/src/miscLogic/celestialobjectslogic.ts index e6610f8d..d41478b7 100644 --- a/src/miscLogic/celestialobjectslogic.ts +++ b/src/miscLogic/celestialobjectslogic.ts @@ -92,7 +92,7 @@ export function wikiCodePercentage(element: HTMLInputElement | null = null) { } const dest = element.dataset.destNoauto as string; const propertyValue = pageData[dest] as string; - const propertyData = numberError(element, propertyValue); + const propertyData = numberError(element, propertyValue, 1); wikiCode(propertyData ? propertyData + '%' : '', dest); } From 41e222ed6545f0e1f5b62b1332f5d33ae14a6ad4 Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 13 Aug 2023 20:45:01 +0200 Subject: [PATCH 5/6] fix #392 --- src/pages/system/system.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/system/system.ts b/src/pages/system/system.ts index 96d2c9d8..abad268d 100644 --- a/src/pages/system/system.ts +++ b/src/pages/system/system.ts @@ -493,6 +493,10 @@ export function enableTradeableAdd() { export function resetExternal() { const sections: NodeListOf = document.querySelectorAll('[data-tradeable], [data-planet]'); removeSection(Array.from(sections)); + const markedElements = document.querySelectorAll('.mark'); + for (const element of Array.from(markedElements)) { + element.classList.remove('mark'); + } } /** From 3f32c71cc699ab3425b383b95bb4dc94f24dcf5d Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 13 Aug 2023 21:37:51 +0200 Subject: [PATCH 6/6] close #392 --- src/htmlSnippets/creatureInputs.html | 6 +++++ src/htmlSnippets/floraInputs.html | 6 +++++ src/htmlSnippets/mineralInputs.html | 6 +++++ src/miscLogic/celestialobjectslogic.ts | 8 +++---- src/miscLogic/planetMoonLogic.ts | 33 ++++++++++++++++++++++---- src/pages/system/elementFunctions.ts | 2 +- 6 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/htmlSnippets/creatureInputs.html b/src/htmlSnippets/creatureInputs.html index 99e94c0a..93be54ad 100644 --- a/src/htmlSnippets/creatureInputs.html +++ b/src/htmlSnippets/creatureInputs.html @@ -136,4 +136,10 @@
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/htmlSnippets/floraInputs.html b/src/htmlSnippets/floraInputs.html index 30f21774..34776670 100644 --- a/src/htmlSnippets/floraInputs.html +++ b/src/htmlSnippets/floraInputs.html @@ -101,4 +101,10 @@
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/htmlSnippets/mineralInputs.html b/src/htmlSnippets/mineralInputs.html index b647547f..977a8365 100644 --- a/src/htmlSnippets/mineralInputs.html +++ b/src/htmlSnippets/mineralInputs.html @@ -90,4 +90,10 @@
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/miscLogic/celestialobjectslogic.ts b/src/miscLogic/celestialobjectslogic.ts index d41478b7..5e383c3d 100644 --- a/src/miscLogic/celestialobjectslogic.ts +++ b/src/miscLogic/celestialobjectslogic.ts @@ -82,17 +82,17 @@ export function docByExternal() { * Add percentage sign to e-sell/buy property data for wikiCode output. * @param {HTMLElement|null} element - the element to apply percentage formatting to. */ -export function wikiCodePercentage(element: HTMLInputElement | null = null) { +export function wikiCodePercentage(element: HTMLInputElement | null = null, decimals: number = 0) { if (!element) { const inputs: NodeListOf = document.querySelectorAll('[data-percentage-input]'); for (const input of Array.from(inputs)) { - wikiCodePercentage(input); + wikiCodePercentage(input, decimals); } return; } const dest = element.dataset.destNoauto as string; - const propertyValue = pageData[dest] as string; - const propertyData = numberError(element, propertyValue, 1); + const propertyValue = element.value; + const propertyData = numberError(element, propertyValue, decimals); wikiCode(propertyData ? propertyData + '%' : '', dest); } diff --git a/src/miscLogic/planetMoonLogic.ts b/src/miscLogic/planetMoonLogic.ts index 68558b46..23533d44 100644 --- a/src/miscLogic/planetMoonLogic.ts +++ b/src/miscLogic/planetMoonLogic.ts @@ -210,7 +210,6 @@ export function sentinelSentence() { /** * Adds a new fauna section to the page and updates the output section accordingly. * - * @async * @param {Element} element - The button element that was clicked to add the fauna section. * @returns {Promise} A promise that resolves when the fauna section is successfully added. **/ @@ -252,12 +251,17 @@ export function addFauna(element: HTMLButtonElement) { handler: 'input', func: function () { limitCreatureSize(this as unknown as HTMLInputElement) } }, + { + element: 'creatureLink', + handler: 'change', + func: function () { linkItem(this as unknown as HTMLInputElement) } + }, ] const inputDom = loadHTML(creatureInputs, { i }, evtListeners) as Document; const outputHTML = `
|-
-
|[[File:|150px]] || || / / || || m || kg ||
`; +
|[[File:|150px]] || [[]] || / / || || m || kg ||
`; addDomAsElement(inputDom, inputSection as HTMLElement, 'beforebegin'); @@ -301,12 +305,17 @@ export function addFlora(element: HTMLButtonElement) { handler: 'input', func: function () { floraMineralResourceLinks(this as unknown as HTMLInputElement) } }, + { + element: 'floraLink', + handler: 'change', + func: function () { linkItem(this as unknown as HTMLInputElement) } + }, ] const inputDom = loadHTML(floraInputs, { i }, evtListeners) as Document; const outputHTML = `
|-
-
|[[File:|150px]] || || || || || || ||
`; +
|[[File:|150px]] || [[]] || || || || || ||
`; addDomAsElement(inputDom, inputSection as HTMLElement, 'beforebegin'); @@ -348,12 +357,17 @@ export function addMineral(element: HTMLButtonElement) { handler: 'input', func: function () { floraMineralResourceLinks(this as unknown as HTMLInputElement) } }, + { + element: 'mineralLink', + handler: 'change', + func: function () { linkItem(this as unknown as HTMLInputElement) } + }, ] const inputDom = loadHTML(mineralInputs, { i }, eventListeners) as Document; const outputHTML = `
|-
-
|[[File:|150px]] || || || || || ||
`; +
|[[File:|150px]] || [[]] || || || || ||
`; addDomAsElement(inputDom, inputSection as HTMLElement, 'beforebegin'); @@ -545,4 +559,15 @@ export function resetExternal() { enableResourceAdd(); if (typeof globalFunctions.enableMoonAdd == 'function') globalFunctions.enableMoonAdd(); +} + +function linkItem(element: HTMLInputElement) { + const isChecked = element.checked; + const dest = element.dataset.destNoauto; + if (dest) { + const brackets: NodeListOf = document.getElementsByName(dest); + for (const bracket of Array.from(brackets)) { + bracket.style.display = isChecked ? '' : 'none'; + } + } } \ No newline at end of file diff --git a/src/pages/system/elementFunctions.ts b/src/pages/system/elementFunctions.ts index e56fc972..6bbf8835 100644 --- a/src/pages/system/elementFunctions.ts +++ b/src/pages/system/elementFunctions.ts @@ -26,7 +26,7 @@ const systemElementFunctions: ElementFunctions = [ }, { element: ['economybuyInput', 'economysellInput'], - func: function () { wikiCodePercentage(this as unknown as HTMLInputElement) } + func: function () { wikiCodePercentage(this as unknown as HTMLInputElement, 1) } }, { element: ['wealthInput', 'conflictInput'],