1 /* 2 * Naos Framework 3 * 4 * LICENSE 5 * http://www.naos-framework.com/website.naos.framework/en/license 6 * 7 * Copyright (c) 2008 Jupiter GmbH 8 */ 9 10 /** 11 * Removes spaces on the left side of the String object. 12 * @type String 13 */ 14 String.prototype.leftTrim = function () { 15 return (this.replace(/^\s+/,"")); 16 }; 17 18 /** 19 * Removes spaces on the right side of the String object. 20 * @type String 21 */ 22 String.prototype.rightTrim = function () { 23 return (this.replace(/\s+$/,"")); 24 }; 25 26 /** 27 * Removes spaces on the left and the right side of the String object. 28 * @type String 29 */ 30 String.prototype.basicTrim = function () { 31 return (this.replace(/\s+$/,"").replace(/^\s+/,"")); 32 }; 33 34 /** 35 * Removes spaces on the left and the right side as well as double spaces. 36 * @type String 37 */ 38 String.prototype.superTrim = function () { 39 return(this.replace(/\s+/g," ").replace(/\s+$/,"").replace(/^\s+/,"")); 40 }; 41 42 /** 43 * Removes all spaces of the String object. 44 * @type String 45 */ 46 String.prototype.removeWhiteSpaces = function () { 47 return (this.replace(/\s+/g,"")); 48 }; 49 50 /** 51 * Encodes the String object for a riskless use in HTML and XML data. 52 * @type String 53 */ 54 String.prototype.encodeXML = function () { 55 return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/'/g,''').replace(/"/g,'"'); 56 }; 57 58 /** 59 * Encodes the String object for a riskles use in HTML and XML data, 60 * additionally replaces newlines with <br/> tags. 61 * 62 * @type String 63 */ 64 String.prototype.encodeXMLViewable = function () { 65 return this.encodeXML().replace(/\n/g,'<br/>'); 66 }; 67