Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions accounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,25 @@
/**
* Parses a format string or object and returns format obj for use in rendering
*
* `format` is either a string with the default (positive) format, or object
* containing `pos` (required), `neg` and `zero` values (or a function returning
* either a string or object)
*
* Either string or format.pos must contain "%v" (value) to be valid
*/
* Parameters:
* string has "default positive format, must contain "%v"
* object has 'pos' (required, must contain "%v"), 'neg', 'zero' properties
* function returns a string or object like above
*
* Returns:
* Object has 'pos' (required, must contain "%v"), 'neg', 'zero' properties
*
*/
// Scenarios:
// A: Valid string ==> convert string to a format object
// B: Invalid string ==> use default and turn it into an object, if it's not already
// C: Valid object ==> leave the object alone
// D: Invalid object ==> use default and turn it into an object, if it's not already
// E: Function ==> Depends on waht the function returns
// F: Nothing ==> use default and turn it into an object, if it's not already

function checkCurrencyFormat(format) {
//The default value will be "%s%v" to start.
var defaults = lib.settings.currency.format;

// Allow function as format parameter (should return string or object):
Expand Down Expand Up @@ -169,7 +181,7 @@
* Alias: `accounting.parse(string)`
*
* Decimal must be included in the regular expression to match floats (defaults to
* accounting.settings.number.decimal), so if the number uses a non-standard decimal
* accounting.settings.number.decimal), so if the number uses a non-standard decimal
* separator, provide it as the second argument.
*
* Also matches bracketed negatives (eg. "$ (1.99)" => -1.99)
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>accounting.js</h1>

<p>It's lightweight, has no dependencies and is suitable for all client-side and server-side JavaScript applications.</p>

<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/accounting.js" data-text="accounting.js - JavaScript library for money/currency formatting">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p>
<!-- <p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/accounting.js" data-text="accounting.js - JavaScript library for money/currency formatting">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p> -->
<ul>
<li><a href="#methods" title="library methods overvew">methods &amp; examples</a>
<li><a href="#demo" title="demo">demo</a>
Expand Down Expand Up @@ -356,11 +356,11 @@ <h2>Links</h2>
<p>accounting.js is maintained by <strong><a href="https://openexchangerates.org" title="Open Exchange Rates free currency data API" target="_blank">Open Exchange Rates</a></strong> - the lightweight currency data API for startups, SMEs and Fortune 500s.</p>
<p>Feedback, support or questions? <strong><a href="mailto:[email protected]" title="Contact Open Exchange Rates">Contact Open Exchange Rates</a></strong> for guidance.</p>
<p>Bugs, issues, suggestions or contributions? Please <strong><a href="https://github.com/openexchangerates/accounting.js" title="accounting.js Github repository">post them here</a></strong>.</p>
<p>accounting.js works great with <strong><a href="http://openexchangerates.github.com/money.js" title="money.js - JavaScript currency conversion library">money.js</a></strong> - the tiny (1kb) standalone JavaScript currency conversion library, for web & nodeJS</p>
<p>accounting.js works great with <strong><a href="http://openexchangerates.github.com/money.js" title="money.js - JavaScript currency conversion library">money.js</a></strong> - the tiny (1kb) standalone JavaScript currency conversion library, for web &amp; nodeJS</p>

<br />
<hr />
<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/accounting.js" data-text="accounting.js - JavaScript library for money/currency formatting">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p>
<!-- <p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://openexchangerates.github.io/accounting.js" data-text="accounting.js - JavaScript library for money/currency formatting">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p> -->
</section>


Expand Down