From 721de08e87edddc6da72ffde77a4adbc2d7e91e1 Mon Sep 17 00:00:00 2001 From: ghuron Date: Wed, 22 Mar 2017 13:27:56 +0300 Subject: [PATCH] Update quantity parser in main.js Right now it can parse values, that consists solely by figures. But sometimes people put there units of measures as well (such as "16 m", "25 kg", etc. Now we are extracting float from the start of the value --- main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index a0cfb8f..731c1dd 100644 --- a/main.js +++ b/main.js @@ -743,12 +743,12 @@ function handleValue(pageid, qid, value) { value = value.replace(/\./g, ''); //remove thousands separators value = value.replace(',', '.'); //replace decimal mark , by . } - var patt = /^(\+|\-)?[0-9.]+$/; - if (patt.test(value)){ - if (value.indexOf('.') > -1){ + var match = value.match(/^(\+|\-)?[0-9.]+/); + if (match){ + if (match[0].indexOf('.') > -1){ report(pageid, 'error', 'floating point numbers are not supported', qid); } else { - checkConstraints(pageid, qid, value, 0); + checkConstraints(pageid, qid, match[0], 0); } } else { report(pageid, 'error', 'unclear value', qid);