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
3dee7293
Commit
3dee7293
authored
Jan 29, 2016
by
Christopher Guess
Browse files
fixed test suite class so it work, added commas for large numbers
parent
9b825305
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
js/marka.js
js/marka.js
+19
-2
test/format.html
test/format.html
+1
-1
No files found.
js/marka.js
View file @
3dee7293
...
@@ -103,8 +103,8 @@ Marka.prototype.doConversions = function() {
...
@@ -103,8 +103,8 @@ Marka.prototype.doConversions = function() {
var
node
=
$
(
value
);
var
node
=
$
(
value
);
var
children
=
node
.
children
()
var
children
=
node
.
children
()
self
.
getValueInSetCurrency
(
res
.
number
,
res
.
symbol
,
function
(
value
,
converted
)
{
self
.
getValueInSetCurrency
(
res
.
number
,
res
.
symbol
,
function
(
value
,
converted
)
{
if
(
converted
==
true
)
{
if
(
converted
==
true
)
{
node
.
html
(
value
.
toFixed
(
0
)
+
"
"
+
self
.
getCurrentCurrency
()
+
"
"
);
node
.
html
(
getFormattedCurrency
(
value
)
+
"
"
+
self
.
getCurrentCurrency
()
+
"
"
);
node
.
append
(
children
);
node
.
append
(
children
);
node
.
children
(
"
.marka-dropdown
"
).
html
(
"
<span class=
\"
marka-result
\"
>
"
+
node
.
data
(
"
original_value
"
)
+
"
</span>
"
)
node
.
children
(
"
.marka-dropdown
"
).
html
(
"
<span class=
\"
marka-result
\"
>
"
+
node
.
data
(
"
original_value
"
)
+
"
</span>
"
)
}
else
{
}
else
{
...
@@ -117,6 +117,23 @@ Marka.prototype.doConversions = function() {
...
@@ -117,6 +117,23 @@ Marka.prototype.doConversions = function() {
});
});
}
}
// From http://stackoverflow.com/a/33808863/604031
function
getFormattedCurrency
(
num
)
{
num
+=
''
;
num
=
parseFloat
(
num
).
toFixed
(
2
);
var
x
=
num
.
split
(
'
.
'
);
var
x1
=
x
[
0
];
var
x2
=
x
.
length
>
1
?
'
.
'
+
x
[
1
]
:
''
;
var
rgx
=
/
(\d
+
)(\d{3})
/
;
while
(
rgx
.
test
(
x1
))
{
x1
=
x1
.
replace
(
rgx
,
'
$1
'
+
'
,
'
+
'
$2
'
);
}
var
merged
=
x1
+
x2
;
return
merged
;
}
Marka
.
prototype
.
splitSymbols
=
function
(
text
)
{
Marka
.
prototype
.
splitSymbols
=
function
(
text
)
{
var
numbers
=
/
[\d
,.
]
+/
;
var
numbers
=
/
[\d
,.
]
+/
;
try
{
try
{
...
...
test/format.html
View file @
3dee7293
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<body>
<body>
<h1>
Testing formats
</h1>
<h1>
Testing formats
</h1>
<div
id=
"
t
es
t
"
>
<div
id=
"
articl
es"
>
<h2>
Should be caught:
</h2>
<h2>
Should be caught:
</h2>
<ul>
<ul>
<li>
400 USD
</li>
<li>
400 USD
</li>
...
...
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