Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
libre
marka
Commits
c3fe51db
Commit
c3fe51db
authored
Jan 27, 2016
by
Christopher Guess
Browse files
added support for multiple multipliers
parent
1c32bd37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
js/marka.js
js/marka.js
+5
-6
test/format.html
test/format.html
+1
-1
No files found.
js/marka.js
View file @
c3fe51db
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
;
...
...
test/format.html
View file @
c3fe51db
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment