From 1558cc8ec1d532fd827ab0a3fb056b90090d8daf Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 24 Jul 2017 20:21:01 +0200 Subject: Divide before multiply to fix approx at number in edition --- js/src/Main.purs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'js/src') 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 ) -- cgit v1.2.3