From fe72accf9b04d53891dde4086245f389b3d6d193 Mon Sep 17 00:00:00 2001 From: Chuck Williams Date: Thu, 4 May 2017 01:51:16 -0600 Subject: [PATCH] Refactors JS & Fixes "Uncaught TypeError: Cannot read property 'siteApi' of undefined" error. --- _includes/globals_js_data.html | 5 +++++ _layouts/default.html | 17 +---------------- _layouts/post.html | 12 +----------- src/js/globals.js | 12 ++++++++++++ 4 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 _includes/globals_js_data.html create mode 100644 src/js/globals.js diff --git a/_includes/globals_js_data.html b/_includes/globals_js_data.html new file mode 100644 index 0000000..4f32784 --- /dev/null +++ b/_includes/globals_js_data.html @@ -0,0 +1,5 @@ + diff --git a/_layouts/default.html b/_layouts/default.html index 0ff9e89..3ef5113 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -34,22 +34,7 @@ - + {% include globals_js_data.html %} diff --git a/_layouts/post.html b/_layouts/post.html index ed61744..7698893 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -74,17 +74,7 @@ - + {% include globals_js_data.html %} diff --git a/src/js/globals.js b/src/js/globals.js new file mode 100644 index 0000000..f5d02ea --- /dev/null +++ b/src/js/globals.js @@ -0,0 +1,12 @@ +/** + * Created by cwilliams on 5/4/17. + */ +function formatNumber (num) { + return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") +} + +function formatCurrency (num,decimal) { + var _decimal; + _decimal = typeof decimal !== "undefined" ? decimal : 2; + return parseFloat(num).toFixed(_decimal).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") +}