Commit c3fe51db authored by Christopher Guess's avatar Christopher Guess
Browse files

added support for multiple multipliers

parent 1c32bd37
cached_exchange_rates = {};
var cached_exchange_rates = {};
dollar_multiplier_lookup_table = {
var dollar_multiplier_lookup_table = {
ten: 10,
hundred: 100,
thousand: 1000,
......@@ -43,7 +43,7 @@ Marka.prototype.match = function() {
var currencyWords = "(" + currencySymbols + "|kr|[Dd]ollars|[Cc]ents on the dollar|[Cc]ents|[Ee]uros|[Pp]ounds|[Rr]upees|[Zz]loty)";
var numbers = "[\\d,.]+";
var optSpace = "[\\s]*";
var magnitudes = "([Mm]illion|[Bb]illion|[Hh]undred|[Tt]housand|[Tt]rillion|[Ll]akh|[Cc]rore|[Ss]core){0,1}";
var magnitudes = "(([Mm]illion|[Bb]illion|[Hh]undred|[Tt]housand|[Tt]rillion|[Ll]akh|[Cc]rore|[Ss]core)[\\s]*)*";
var currencyCode = "[A-Z]{2,3}";
var optAsterisk = "[*]{0,1}";
var optBraceOpen = "[\(]{0,1}";
......@@ -76,7 +76,6 @@ Marka.prototype.doConversions = function() {
var children = node.children()
self.getValueInSetCurrency(res.number, res.symbol, function(value, converted) {
if (converted) {
console.log(self.getCurrentCurrency())
node.text(value.toFixed(2) + " " + self.getCurrentCurrency());
} else {
node.text(node.data("original_value"))
......@@ -96,12 +95,12 @@ Marka.prototype.splitSymbols = function(text) {
return false;
}
number = number.replace(",", "")
realnumber = parseFloat(number);
var realnumber = parseFloat(number);
if (!realnumber) { return false; }
var residual = text.replace(numbers, "")
for(var property in dollar_multiplier_lookup_table){
value = dollar_multiplier_lookup_table[property];
var value = dollar_multiplier_lookup_table[property];
var index = residual.search(property);
if(index > -1){
realnumber = realnumber * value;
......
......@@ -45,7 +45,7 @@
<li>$2 lakh</li>
<li>$4 crore</li>
<li>$200 score</li>
<li>$1 hundred million</li>
<li>$1 million hundred</li>
</ul>
<h2>Should not be caught:</h2>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment