Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes #397

Merged
merged 5 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fauna.html
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ <h1 class="title is-3">Hub Wiki Page Creator - Fauna</h1>
</div>

<div>==Location==</div>
<div>It can be found on the <output id="celestialBody"></output> in the [[<output id="locSystem"
<div>It can be found on the [[<output id="celestialBody"></output>]] in the [[<output id="locSystem"
name="system"></output>]] [[star system]].</div>
<br>
<div>{{CoordGlyphConvert|<output id="portalglyphs1" name="portalglyphs"></output>}}
Expand Down
2 changes: 1 addition & 1 deletion sandworm.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ <h1 class="title is-3">Hub Wiki Page Creator - Sandworm</h1>
<br>

<div>==Location==</div>
<div>It can be found on the <output id="celestialBody"></output> in the [[<output id="locSystem"
<div>It can be found on the [[<output id="celestialBody"></output>]] in the [[<output id="locSystem"
name="system"></output>]] [[star system]].</div>
<br>
<div>{{CoordGlyphConvert|<output id="portalglyphs1" name="portalglyphs"></output>}}</div>
Expand Down
10 changes: 5 additions & 5 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ export function shortenGHub(civ: string): string {
* @returns {string|Object} The formatted statistics string (and optionally, the raw calculation values).
*/
export function numberStats(element: HTMLInputElement | null = null, decimals: number | undefined = undefined, outputRaw: boolean = false) {
if (arguments.length == 0) {
if (arguments.length === 0) {
const numbers: NodeListOf<HTMLInputElement> = document.querySelectorAll('[data-dest-number]');
for (const element of Array.from(numbers)) {
const decimals = element.dataset.destNumber as string;
Expand All @@ -880,11 +880,12 @@ export function numberStats(element: HTMLInputElement | null = null, decimals: n

const dest = element.dataset.destNoauto as string;
const propertyValue = pageData[dest] as string;
const prependString = propertyValue.startsWith('-') && !parseFloat(propertyValue) ? '-' : '';
const propertyData = numberError(element, propertyValue, decimals, outputRaw);
if (getDestElements(dest)[0]) {
wikiCode(propertyData.toString(), dest);
wikiCode(prependString + propertyData.toString(), dest);
} else {
pageData[dest] = propertyData;
pageData[dest] = prependString + propertyData;
}
}

Expand Down Expand Up @@ -1241,6 +1242,5 @@ export function getWormAlbum(civShort: string): string {
}

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`
input.maxLength = input.value.startsWith('-') ? 4 : 3; // NoSonar negative numbers must have a limit of 4 to allow for `-0.1`. Else use 3 for `0.1`
}
4 changes: 2 additions & 2 deletions src/htmlSnippets/creatureInputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</div>
<div class="tableCell data" data-fauna="section${i}" data-section="fauna fauna${i}">
<input data-dest-noauto="faunaWeight${i}" data-dest-number="1" type="text" id="faunaWeightInput${i}" maxlength="5"
placeholder="0.0" data-evt-id="creaturePropInput">
placeholder="0.0">
</div>
<div class="tableCell text" data-fauna="section${i}" data-section="fauna fauna${i}">
<label for="faunaHeightInput${i}">Height in m:</label>
Expand All @@ -129,7 +129,7 @@
</div>
<div class="tableCell data" data-fauna="section${i}" data-section="fauna fauna${i}">
<input data-dest-noauto="faunaHeight${i}" data-dest-number="1" type="text" id="faunaHeightInput${i}" maxlength="3"
placeholder="0.0" data-evt-id="creaturePropInput">
placeholder="0.0" data-evt-id="creatureHeightInput">
</div>
<div class="tableCell text" data-fauna="section${i}" data-section="fauna fauna${i}">
<label for="faunaDiscovererInput${i}">Discoverer:</label>
Expand Down
2 changes: 1 addition & 1 deletion src/miscLogic/planetMoonLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export function addFauna(element: HTMLButtonElement) {
func: function () { addGenus(this as unknown as HTMLSelectElement) }
},
{
element: 'creaturePropInput',
element: 'creatureHeightInput',
handler: 'input',
func: function () { limitCreatureSize(this as unknown as HTMLInputElement) }
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fauna/elementFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const creatureElementFunctions: ElementFunctions = [
},
{
element: ['weightInput', 'weight2Input'],
func: function () { genderProps("height", "height2"); numberError(this as unknown as HTMLInputElement) }
func: function () { genderProps("weight", "weight2"); numberError(this as unknown as HTMLInputElement) }
},
{
element: 'gender',
Expand Down
6 changes: 4 additions & 2 deletions src/pages/fauna/fauna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ export function genderProps(property1Name: string, property2Name: string) {
// adds .0
let property1Number, property2Number;
if (property1Name != 'gender') {
property1Number = isNaN(parseFloat(property1Value)) ? '' : parseFloat(property1Value).toFixed(1);
property2Number = isNaN(parseFloat(property2Value)) ? '' : parseFloat(property2Value).toFixed(1);
const prependString1 = property1Value.startsWith('-') && !parseFloat(property1Value) ? '-' : '';
const prependString2 = property2Value.startsWith('-') && !parseFloat(property2Value) ? '-' : '';
property1Number = isNaN(parseFloat(property1Value)) ? '' : prependString1 + parseFloat(property1Value).toFixed(1);
property2Number = isNaN(parseFloat(property2Value)) ? '' : prependString2 + parseFloat(property2Value).toFixed(1);
}

const property1Data = property1Number ?? property1Value;
Expand Down