[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fckjscoreextensions.js 22 * Extensions to the JavaScript Core. 23 * 24 * All custom extentions functions are PascalCased to differ from the standard 25 * camelCased ones. 26 * 27 * File Authors: 28 * Frederico Caldeira Knabben (www.fckeditor.net) 29 */ 30 31 String.prototype.Contains = function( textToCheck ) 32 { 33 return ( this.indexOf( textToCheck ) > -1 ) ; 34 } 35 36 String.prototype.Equals = function() 37 { 38 var aArgs = arguments ; 39 40 // The arguments could also be a single array. 41 if ( aArgs.length == 1 && aArgs[0].pop ) 42 aArgs = aArgs[0] ; 43 44 for ( var i = 0 ; i < aArgs.length ; i++ ) 45 { 46 if ( this == aArgs[i] ) 47 return true ; 48 } 49 return false ; 50 } 51 52 String.prototype.IEquals = function() 53 { 54 var thisUpper = this.toUpperCase() ; 55 56 var aArgs = arguments ; 57 58 // The arguments could also be a single array. 59 if ( aArgs.length == 1 && aArgs[0].pop ) 60 aArgs = aArgs[0] ; 61 62 for ( var i = 0 ; i < aArgs.length ; i++ ) 63 { 64 if ( thisUpper == aArgs[i].toUpperCase() ) 65 return true ; 66 } 67 return false ; 68 } 69 70 String.prototype.ReplaceAll = function( searchArray, replaceArray ) 71 { 72 var replaced = this ; 73 74 for ( var i = 0 ; i < searchArray.length ; i++ ) 75 { 76 replaced = replaced.replace( searchArray[i], replaceArray[i] ) ; 77 } 78 79 return replaced ; 80 } 81 82 Array.prototype.AddItem = function( item ) 83 { 84 var i = this.length ; 85 this[ i ] = item ; 86 return i ; 87 } 88 89 Array.prototype.IndexOf = function( value ) 90 { 91 for ( var i = 0 ; i < this.length ; i++ ) 92 { 93 if ( this[i] == value ) 94 return i ; 95 } 96 return -1 ; 97 } 98 99 String.prototype.StartsWith = function( value ) 100 { 101 return ( this.substr( 0, value.length ) == value ) ; 102 } 103 104 // Extends the String object, creating a "EndsWith" method on it. 105 String.prototype.EndsWith = function( value, ignoreCase ) 106 { 107 var L1 = this.length ; 108 var L2 = value.length ; 109 110 if ( L2 > L1 ) 111 return false ; 112 113 if ( ignoreCase ) 114 { 115 var oRegex = new RegExp( value + '$' , 'i' ) ; 116 return oRegex.test( this ) ; 117 } 118 else 119 return ( L2 == 0 || this.substr( L1 - L2, L2 ) == value ) ; 120 } 121 122 String.prototype.Remove = function( start, length ) 123 { 124 var s = '' ; 125 126 if ( start > 0 ) 127 s = this.substring( 0, start ) ; 128 129 if ( start + length < this.length ) 130 s += this.substring( start + length , this.length ) ; 131 132 return s ; 133 } 134 135 String.prototype.Trim = function() 136 { 137 // We are not using \s because we don't want "non-breaking spaces to be caught". 138 return this.replace( /(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '' ) ; 139 } 140 141 String.prototype.LTrim = function() 142 { 143 // We are not using \s because we don't want "non-breaking spaces to be caught". 144 return this.replace( /^[ \t\n\r]*/g, '' ) ; 145 } 146 147 String.prototype.RTrim = function() 148 { 149 // We are not using \s because we don't want "non-breaking spaces to be caught". 150 return this.replace( /[ \t\n\r]*$/g, '' ) ; 151 } 152 153 String.prototype.ReplaceNewLineChars = function( replacement ) 154 { 155 return this.replace( /\n/g, replacement ) ; 156 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |