www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit afc285af7ea3c1f9a5b2235335ecd15df53313b0
parent 1eee3ba0f18eb5663da670b80e62660729313f8b
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 30 Sep 2024 12:47:11 -0700

Allow fractional numbers in user units

Diffstat:
Mfiles/floorplans/floorplan/editor.js | 7++++++-
Mfiles/floorplans/floorplan/main.js | 2+-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js @@ -190,10 +190,15 @@ class Units { do { let n = this.get(unit) if (units >= n) { - let amount = Math.floor(units / n) + let amount = units / n + if (this.data[unit].base) { + amount = Math.floor(amount) + } units -= amount * n // not sure about floating mod in js parts.push({ unit: unit, symbol: this.data[unit].symbol, amount: amount }) } + + } while (units > 0 && (unit = this.data[unit].base)) if (units > 0) { parts.push({ "amount": units }) diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js @@ -1016,7 +1016,7 @@ function unitInput(editor, input, value) { function parseUserLength(editor, length) { - let a = length.replaceAll(" ", "").split(/([0-9]+)/) + let a = length.replaceAll(" ", "").split(/([0-9.]+)/) let amount let rebuilt = [] for (let i in a) {