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/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 e6610f8d..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);
+ 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 0190395d..23533d44 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';
@@ -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.
**/
@@ -247,12 +246,22 @@ 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) }
+ },
+ {
+ 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');
@@ -296,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');
@@ -343,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');
@@ -540,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/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'],
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;
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'],
diff --git a/src/pages/system/system.ts b/src/pages/system/system.ts
index 90c53f16..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');
+ }
}
/**
@@ -825,6 +829,7 @@ export function civCatalog() {
export function generateGalleryArray() {
const array: Array = [
'',
+ 'Analysis Visor',
'System Exploration Guide',
'System Page',
'Default SS Multi-Tool',