v0.4 updates

This commit is contained in:
Joss Crowcroft
2014-07-14 20:44:03 +01:00
parent 532125394d
commit 4a95cc7e14
6 changed files with 26 additions and 24 deletions

View File

@@ -1,12 +1,12 @@
/*!
* accounting.js v0.3.1
* Copyright 2011, Joss Crowcroft
* accounting.js v0.4
* Copyright 2014 Open Exchange Rates
*
* Freely distributable under the MIT license.
* Portions of accounting.js are inspired or borrowed from underscore.js
*
* Full details and documentation:
* http://josscrowcroft.github.com/accounting.js/
* http://openexchangerates.github.io/accounting.js/
*/
(function(root, undefined) {

2
accounting.min.js vendored
View File

@@ -1,4 +1,4 @@
/*!
* accounting.js v0.3.1, copyright 2011 Joss Crowcroft, MIT license, http://josscrowcroft.github.com/accounting.js
* accounting.js v0.4, copyright 2014 Open Exchange Rates, MIT license, http://openexchangerates.github.io/accounting.js
*/
(function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;e<h;e++)c[e]=b.call(d,a[e],e,a);return c}function n(a,b){a=Math.round(Math.abs(a));return isNaN(a)?b:a}function x(a){var b=c.settings.currency.format;"function"===typeof a&&(a=a());return q(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:!a||!a.pos||!a.pos.match("%v")?!q(b)?b:c.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:a}var c={version:"0.3.1",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},w=Array.prototype.map,u=Array.isArray,v=Object.prototype.toString,o=c.unformat=c.parse=function(a,b){if(m(a))return j(a,function(a){return o(a,b)});a=a||0;if("number"===typeof a)return a;var b=b||".",c=RegExp("[^0-9-"+b+"]",["g"]),c=parseFloat((""+a).replace(/\((.*)\)/,"-$1").replace(c,"").replace(b,"."));return!isNaN(c)?c:0},y=c.toFixed=function(a,b){var b=n(b,c.settings.number.precision),d=Math.pow(10,b);return(Math.round(c.unformat(a)*d)/d).toFixed(b)},t=c.formatNumber=function(a,b,d,i){if(m(a))return j(a,function(a){return t(a,b,d,i)});var a=o(a),e=s(r(b)?b:{precision:b,thousand:d,decimal:i},c.settings.number),h=n(e.precision),f=0>a?"-":"",g=parseInt(y(Math.abs(a||0),h),10)+"",l=3<g.length?g.length%3:0;return f+(l?g.substr(0,l)+e.thousand:"")+g.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+e.thousand)+(h?e.decimal+y(Math.abs(a),h).split(".")[1]:"")},A=c.formatMoney=function(a,b,d,i,e,h){if(m(a))return j(a,function(a){return A(a,b,d,i,e,h)});var a=o(a),f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format);return(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal))};c.formatColumn=function(a,b,d,i,e,h){if(!a)return[];var f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format),l=g.pos.indexOf("%s")<g.pos.indexOf("%v")?!0:!1,k=0,a=j(a,function(a){if(m(a))return c.formatColumn(a,f);a=o(a);a=(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal));if(a.length>k)k=a.length;return a});return j(a,function(a){return q(a)&&a.length<k?l?a.replace(f.symbol,f.symbol+Array(k-a.length+1).join(" ")):Array(k-a.length+1).join(" ")+a:a})};if("undefined"!==typeof exports){if("undefined"!==typeof module&&module.exports)exports=module.exports=c;exports.accounting=c}else"function"===typeof define&&define.amd?define([],function(){return c}):(c.noConflict=function(a){return function(){p.accounting=a;c.noConflict=z;return c}}(p.accounting),p.accounting=c)})(this);

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>accounting.js - format money / currency in JavaScript</title>
<link href="demo-resources/style.css" rel="stylesheet"/>
<link rel="canonical" href="http://josscrowcroft.github.com/accounting.js/" />
<link rel="canonical" href="http://openexchangerates.github.io/accounting.js/" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17884149-3']);
@@ -21,7 +21,7 @@
<section>
<h1>accounting.js</h1>
<p><strong>accounting.js</strong> is a tiny JavaScript library for number, money and currency formatting, with optional excel-style column rendering (to line up symbols and decimals). It's lightweight, fully localisable and has zero dependencies.</p>
<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://josscrowcroft.github.com/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>
@@ -279,14 +279,14 @@ accounting.unformat("&euro; 1.000.000,00", ","); // 1000000</pre>
<section id="roadmap">
<h2>Roadmap</h2>
<p>See the <a href="https://github.com/josscrowcroft/accounting.js/issues" title="accounting.js issues">Github Issues page</a> for up-to-date progress.</p>
<p>See the <a href="https://github.com/openexchangerates/accounting.js/issues" title="accounting.js issues">Github Issues page</a> for up-to-date progress.</p>
<h4>Next Version:</h4>
<ul>
<li><s>Add more fine-grained control of formatting, with negatives and zero-values</s></li>
<li><s>Implement <code>map()</code> and type-checking helper methods to clean up API methods</s></li>
<li>Find performance bottlenecks and work on speed optimisations</li>
<li>Write more tests, docs and examples, add FAQ</li>
<li>Implement <a href="https://github.com/josscrowcroft/accounting.js/issues/" title="accounting.js issues">feedback</a></li>
<li>Implement <a href="https://github.com/openexchangerates/accounting.js/issues/" title="accounting.js issues">feedback</a></li>
</ul>
<h4>Later:</h4>
<ul>
@@ -301,26 +301,25 @@ accounting.unformat("&euro; 1.000.000,00", ","); // 1000000</pre>
<section id="support">
<h2>Feedback / Support</h2>
<p>Please create issues on the <a href="https://github.com/josscrowcroft/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a> if you have feedback or need support, or comment on <a href="http://www.josscrowcroft.com" title="Joss">Joss's blog</a>.</p>
<p>Please create issues on the <a href="https://github.com/openexchangerates/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a> if you have feedback or need support, <a href="mailto:info@openexchangerates.org" title="Contact Open Exchange Rates">contact Open Exchange Rates here</a>.</p>
</section>
<section id="download">
<h2>Download</h2>
<ul>
<li><strong><a href="https://raw.github.com/josscrowcroft/accounting.js/master/accounting.js" title="accounting.js">accounting.js</a></strong> - Latest version from Github (12kb)</li>
<li><strong><a href="https://raw.github.com/josscrowcroft/accounting.js/master/accounting.min.js" title="accounting.min.js">accounting.min.js</a></strong> - Latest version from Github (3kb, minified)</li>
<li>Or check out the <a href="https://github.com/josscrowcroft/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a> for the full package.</li>
<li><strong><a href="https://raw.github.com/openexchangerates/accounting.js/master/accounting.js" title="accounting.js">accounting.js</a></strong> - Latest version from Github (12kb)</li>
<li><strong><a href="https://raw.github.com/openexchangerates/accounting.js/master/accounting.min.js" title="accounting.min.js">accounting.min.js</a></strong> - Latest version from Github (3kb, minified)</li>
<li>Or check out the <a href="https://github.com/openexchangerates/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a> for the full package.</li>
</ul>
</section>
<section id="moar">
<br />
<hr />
<p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="josscrowcroft" data-url="http://josscrowcroft.github.com/accounting.js" data-text="accounting.js - JavaScript library for money/currency formatting">Tweet</a> &nbsp; <g:plusone size="medium"></g:plusone></p>
<h3>Moar Info</h3>
<p><small><strong>accounting.js</strong> was made by <a href="http://www.josscrowcroft.com" title="Joss">Joss</a> (that's me) in Hong Kong, for internal use in our enterprise analytics application at <a href="http://demandanalytics.com" title="Demand Analytics">Demand Analytics</a>. It seemed to be working pretty well, so I'm releasing it in the hope that other people and apps can make use of and contribute to it.</small></p>
<p><small>You can follow me on Twitter at <a href="http://twitter.com/josscrowcroft" title="@josscrowcroft on Twitter">@josscrowcroft</a>, I mostly post about JS, HTML5, startups, Hong Kong and things I've built.</small></p>
<p><small>Any questions? Just email me <a href="http://www.josscrowcroft.com/contact/" title="Contact Joss">here</a> or post on the <a href="https://github.com/josscrowcroft/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a>.</small></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>
<h3>More Info</h3>
<p><small>Twitter: <a href="http://twitter.com/josscrowcroft" title="@josscrowcroft on Twitter">@josscrowcroft</a></small></p>
<p><small>Any questions? <a href="mailto:info@openexchangerates.org" title="Contact Open Exchange Rates">Contact Open Exchange Rates here</a> or post on the <a href="https://github.com/openexchangerates/accounting.js" title="accounting.js Github repository">accounting.js Github repository</a>.</small></p>
</section>

View File

@@ -1,4 +1,4 @@
Copyright (c) 2011 Joss Crowcroft
Copyright (c) 2014 Open Exchange Rates
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -1,12 +1,12 @@
{
"name" : "accounting",
"description" : "number, money and currency formatting library",
"homepage": "http://josscrowcroft.github.com/accounting.js",
"homepage": "http://openexchangerates.github.io/accounting.js",
"keywords" : ["accounting", "number", "money", "currency", "format", "utilities"],
"author": "Joss Crowcroft <josscrowcroft@gmail.com> (http://www.josscrowcroft.com)",
"author": "Open Exchange Rates <info@openexchangerates.org> (https://www.openexchangerates.org)",
"contributors" : [],
"dependencies" : [],
"repository" : {"type": "git", "url": "git://github.com/josscrowcroft/accounting.js.git"},
"repository" : {"type": "git", "url": "git://github.com/openexchangerates/accounting.js.git"},
"main" : "accounting.js",
"version" : "0.3.1"
"version" : "0.4"
}

View File

@@ -1,6 +1,6 @@
**accounting.js** is a tiny JavaScript library for number, money and currency formatting, and excel-style column rendering to line up symbols and decimals. It's lightweight, fully localisable and has zero dependencies.
Check out the plugin homepage (with demos and docs) here: **http://josscrowcroft.github.com/accounting.js/**
Check out the plugin homepage (with demos and docs) here: **http://openexchangerates.github.io/accounting.js/**
Please checkout / download the latest stable tag before using in a production environment and report any bugs with your setup info!
@@ -13,6 +13,9 @@ Please checkout / download the latest stable tag before using in a production en
## Changelog
### v0.4
* Transfer repository to Open Exchange Rates for ongoing maintenance
### v0.3.0
* Rewrote library structure similar to underscore.js for use as a nodeJS/npm and AMD module - now you can go `npm install accounting`, and then `var accounting = require("accounting");` in your nodeJS scripts.
* It also works with requireJS or any AMD module loader.
@@ -72,4 +75,4 @@ Please checkout / download the latest stable tag before using in a production en
0 | $ 0.00 | HK$ -- | 0.00 GBP
```
There's more on the plugin homepage: **http://josscrowcroft.github.com/accounting.js/**
There's more on the plugin homepage: **http://openexchangerates.github.io/accounting.js/**