diff options
author | Joris | 2017-07-24 20:21:01 +0200 |
---|---|---|
committer | Joris | 2017-07-24 20:21:01 +0200 |
commit | 1558cc8ec1d532fd827ab0a3fb056b90090d8daf (patch) | |
tree | d428ad2e4e2fa3ae764b850d5acda7a674f024e1 /js/src | |
parent | 5eea2801b7fba62a28642c4113bfff0a9ca5847f (diff) |
Divide before multiply to fix approx at number in edition
Diffstat (limited to 'js/src')
-rw-r--r-- | js/src/Main.purs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/js/src/Main.purs b/js/src/Main.purs index 3e470ae..a16b2cd 100644 --- a/js/src/Main.purs +++ b/js/src/Main.purs @@ -34,15 +34,14 @@ onInput numberElems { elem, number } = do Dom.onInput elem (\value -> do case Parser.number value of Just newNumber -> - let mul = newNumber / number - in numberElems - # map (\ne -> do - inputNode <- Dom.selectElementFrom ne.elem (QuerySelector "input") - case inputNode of - Just node -> Dom.setValue (Number.format (ne.number * mul)) node - _ -> pure unit - ) - # Traversable.sequence_ + numberElems + # map (\ne -> do + inputNode <- Dom.selectElementFrom ne.elem (QuerySelector "input") + case inputNode of + Just node -> Dom.setValue (Number.format (ne.number / number * newNumber)) node + _ -> pure unit + ) + # Traversable.sequence_ _ -> pure unit ) |