HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/CMSScripts/CMSModules/CMS/NumberShortener.js
/** 
 * NumberShortener util function
 */
cmsdefine(function () {

    return {
        shortenNumber: function (num, decimalFraction, labelsNames) {
            var fraction = decimalFraction || 1,
                labels = labelsNames || { thousand: 'k', million: 'm', billion: 'g' };


            if (num >= 1000000000) {
                return (num / 1000000000).toFixed(fraction).replace(/\.0$/, '') + labels.billion;
            }
            if (num >= 1000000) {
                return (num / 1000000).toFixed(fraction).replace(/\.0$/, '') + labels.million;
            }
            if (num >= 1000) {
                return (num / 1000).toFixed(fraction).replace(/\.0$/, '') + labels.thousand;
            }
            return num;
        }
    };
});