formatCurrency
dbebb59ef2c75a77edbb43d84701645bd2d328b5
1 files changed
src/NetproxySolution.Web/wwwroot/scripts/macros.js
diff --git a/src/NetproxySolution.Web/wwwroot/scripts/macros.js b/src/NetproxySolution.Web/wwwroot/scripts/macros.js
index 7046c17..60d0b1c 100644
--- a/src/NetproxySolution.Web/wwwroot/scripts/macros.js
+++ b/src/NetproxySolution.Web/wwwroot/scripts/macros.js
@@ -1,5 +1,5 @@
// version 1.3 2020-08-30 (C) AAB van der Heijden
-// Updated 2.2 2024-11-30
+// Updated 2.3 2024-12-05
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
window.$id = document.getElementById.bind(document);
@@ -139,3 +139,15 @@ NodeList.prototype.off = function (event, handler)
this.forEach(el => el.off(event, handler));
return this;
};
+
+window.formatCurrency = (value, locale = 'nl-NL', currency = 'EUR', options = {}) =>
+{
+ const formatter = new Intl.NumberFormat(locale,
+ {
+ style: 'currency',
+ currency: currency,
+ ...options
+ });
+
+ return formatter.format(value);
+};