[icinga-checkins] icinga.org: icingaweb2/master: JS: implement Icinga.Utils.padString()

git at icinga.org git at icinga.org
Mon Feb 22 11:28:39 CET 2016


Module: icingaweb2
Branch: master
Commit: c4a69191a31e0364d615e8cb8b1f7645784f0377
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=c4a69191a31e0364d615e8cb8b1f7645784f0377

Author: Alexander A. Klimov <alexander.klimov at netways.de>
Date:   Mon Feb 22 11:14:41 2016 +0100

JS: implement Icinga.Utils.padString()

refs #10625

---

 public/js/icinga/utils.js |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js
index dea9c37..8c69485 100644
--- a/public/js/icinga/utils.js
+++ b/public/js/icinga/utils.js
@@ -386,6 +386,24 @@
                     }[c];
                 }
             );
+        },
+
+        /**
+         * Pad a string with another one
+         *
+         * @param   {String}    str         the string to pad
+         * @param   {String}    padding     the string to use for padding
+         * @param   {Number}    minLength   the minimum length of the result
+         *
+         * @returns {String}    the padded string
+         */
+        padString: function(str, padding, minLength) {
+            str = String(str);
+            padding = String(padding);
+            while (str.length < minLength) {
+                str = padding + str;
+            }
+            return str;
         }
     };
 



More information about the icinga-checkins mailing list