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;
};
String.prototype.rtrim = function () {
return this.replace(/\s+$/, "");
}
if (typeof (prefix) == "undefined")
{ prefix = { __namespace: true }; }
if (typeof (prefix.namespace1) == "undefined") {
prefix.namespace1 = {};
}
//This will establish a more unique namespace for functions in this library. This will reduce the
// potential for functions to be overwritten due to a duplicate name when the library is loaded.
prefix.namespace1.namespace2 = {
someFunction: function{
var temp1 = "this is a test string {0}";
temp1.format("hello");
},
namespace
};
http://www.somacon.com/p355.php
No comments:
Post a Comment