[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 Object.extend(String.prototype, { 2 stripTags: function() { 3 return this.replace(/<\/?[^>]+>/gi, ''); 4 }, 5 6 stripScripts: function() { 7 return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); 8 }, 9 10 extractScripts: function() { 11 var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); 12 var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); 13 return (this.match(matchAll) || []).map(function(scriptTag) { 14 return (scriptTag.match(matchOne) || ['', ''])[1]; 15 }); 16 }, 17 18 evalScripts: function() { 19 return this.extractScripts().map(eval); 20 }, 21 22 escapeHTML: function() { 23 var div = document.createElement('div'); 24 var text = document.createTextNode(this); 25 div.appendChild(text); 26 return div.innerHTML; 27 }, 28 29 unescapeHTML: function() { 30 var div = document.createElement('div'); 31 div.innerHTML = this.stripTags(); 32 return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; 33 }, 34 35 toQueryParams: function() { 36 var pairs = this.match(/^\??(.*)$/)[1].split('&'); 37 return pairs.inject({}, function(params, pairString) { 38 var pair = pairString.split('='); 39 params[pair[0]] = pair[1]; 40 return params; 41 }); 42 }, 43 44 toArray: function() { 45 return this.split(''); 46 }, 47 48 camelize: function() { 49 var oStringList = this.split('-'); 50 if (oStringList.length == 1) return oStringList[0]; 51 52 var camelizedString = this.indexOf('-') == 0 53 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) 54 : oStringList[0]; 55 56 for (var i = 1, len = oStringList.length; i < len; i++) { 57 var s = oStringList[i]; 58 camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 59 } 60 61 return camelizedString; 62 }, 63 64 inspect: function() { 65 return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; 66 } 67 }); 68 69 String.prototype.parseQuery = String.prototype.toQueryParams;
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |