2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* Extensions to the JavaScript Core.
23
* All custom extentions functions are PascalCased to differ from the standard
27
String.prototype.Contains = function( textToCheck )
29
return ( this.indexOf( textToCheck ) > -1 ) ;
32
String.prototype.Equals = function()
34
var aArgs = arguments ;
36
// The arguments could also be a single array.
37
if ( aArgs.length == 1 && aArgs[0].pop )
40
for ( var i = 0 ; i < aArgs.length ; i++ )
42
if ( this == aArgs[i] )
48
String.prototype.IEquals = function()
50
var thisUpper = this.toUpperCase() ;
52
var aArgs = arguments ;
54
// The arguments could also be a single array.
55
if ( aArgs.length == 1 && aArgs[0].pop )
58
for ( var i = 0 ; i < aArgs.length ; i++ )
60
if ( thisUpper == aArgs[i].toUpperCase() )
66
String.prototype.ReplaceAll = function( searchArray, replaceArray )
70
for ( var i = 0 ; i < searchArray.length ; i++ )
72
replaced = replaced.replace( searchArray[i], replaceArray[i] ) ;
78
Array.prototype.AddItem = function( item )
85
Array.prototype.IndexOf = function( value )
87
for ( var i = 0 ; i < this.length ; i++ )
89
if ( this[i] == value )
95
String.prototype.StartsWith = function( value )
97
return ( this.substr( 0, value.length ) == value ) ;
100
// Extends the String object, creating a "EndsWith" method on it.
101
String.prototype.EndsWith = function( value, ignoreCase )
103
var L1 = this.length ;
104
var L2 = value.length ;
111
var oRegex = new RegExp( value + '$' , 'i' ) ;
112
return oRegex.test( this ) ;
115
return ( L2 == 0 || this.substr( L1 - L2, L2 ) == value ) ;
118
String.prototype.Remove = function( start, length )
123
s = this.substring( 0, start ) ;
125
if ( start + length < this.length )
126
s += this.substring( start + length , this.length ) ;
131
String.prototype.Trim = function()
133
// We are not using \s because we don't want "non-breaking spaces to be caught".
134
return this.replace( /(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '' ) ;
137
String.prototype.LTrim = function()
139
// We are not using \s because we don't want "non-breaking spaces to be caught".
140
return this.replace( /^[ \t\n\r]*/g, '' ) ;
143
String.prototype.RTrim = function()
145
// We are not using \s because we don't want "non-breaking spaces to be caught".
146
return this.replace( /[ \t\n\r]*$/g, '' ) ;
149
String.prototype.ReplaceNewLineChars = function( replacement )
151
return this.replace( /\n/g, replacement ) ;
b'\\ No newline at end of file'