aboutsummaryrefslogtreecommitdiffstats
path: root/include/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'include/main.js')
-rw-r--r--include/main.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/main.js b/include/main.js
index 31b441afb..1a377a1a4 100644
--- a/include/main.js
+++ b/include/main.js
@@ -307,3 +307,15 @@
});
}
+/**
+ * sprintf in javascript
+ * "{0} and {1}".format('zero','uno');
+ **/
+String.prototype.format = function() {
+ var formatted = this;
+ for (var i = 0; i < arguments.length; i++) {
+ var regexp = new RegExp('\\{'+i+'\\}', 'gi');
+ formatted = formatted.replace(regexp, arguments[i]);
+ }
+ return formatted;
+};