Merci pour vos réponses, en fait le (for i in ne fonctionne pas avec prototype (cette librairie redéfinie l'objet Array...) et le script de koala donne ceci :
Pierrot Lefou
René Martin
Alphonse Gicquel
Germaine Delabarre
Lucette Pépra
Christiane Montigne
Elysée Tayole
Gertrude Colbert
function() { var indexArray = new Array(); for ( index in this ) {
var ignoreThis = false;
for ( var i = 0 ; i < Rico.ArrayExtensions.length ; i++ ) {
if ( this[index] == Rico.ArrayExtensions[i] ) {
ignoreThis = true; break; } }
if ( !ignoreThis ) indexArray[ indexArray.length ] = index;
} return indexArray; } function() {
var indexArray = new Array(); for ( index in this ) {
var ignoreThis = false;
for ( var i = 0 ; i < Rico.ArrayExtensions.length ; i++ ) {
if ( this[index] == Rico.ArrayExtensions[i] ) {
ignoreThis = true; break; } }
if ( !ignoreThis ) indexArray[ indexArray.length ] = index;
} return indexArray; }
function(item) { for ( var i = 0 ; i < this.length ; i++ )
if ( this[i] == item ) { this.remove(i); break;
} } function(item) { for ( var i = 0 ; i < this.length ; i++ )
if ( this[i] == item ) { this.remove(i); break;
} }
function(dx) { if( isNaN(dx) || dx > this.length ) return false;
for( var i=0,n=0; i<this.length; i++ ) if( i != dx )
this[n++]=this[i]; this.length-=1; } function(dx) {
if( isNaN(dx) || dx > this.length ) return false;
for( var i=0,n=0; i<this.length; i++ ) if( i != dx )
this[n++]=this[i]; this.length-=1; }
function(object) { for (var i = 0; i < this.length; i++)
if (this[i] == object) return i; return -1; } function(object) {
for (var i = 0; i < this.length; i++) if (this[i] == object) return i;
return -1; }
function() { var values = $A(arguments);
return this.select(function(value) { return !values.include(value);
}); } function() { var values = $A(arguments);
return this.select(function(value) { return !values.include(value);
}); }
function() { return this.inject([], function(array, value) {
return array.concat(value.constructor == Array ?
value.flatten() : [value]); }); } function() {
return this.inject([], function(array, value) {
return array.concat(value.constructor == Array ?
value.flatten() : [value]); }); }
function() { return this.select(function(value) {
return value != undefined || value != null; }); } function() {
return this.select(function(value) {
return value != undefined || value != null; }); }
function() { return this[this.length - 1]; } function() {
return this[this.length - 1]; }
function() { return this[0]; } function() { return this[0]; }
function() { this.length = 0; return this; } function() {
this.length = 0; return this; }
function(iterator) { for (var i = 0; i < this.length; i++)
iterator(this[i]); } function(iterator) {
for (var i = 0; i < this.length; i++) iterator(this[i]); }
function reverse() { [native code]} function reverse() { [native code]}
function() { return this.collect(Prototype.K); } function() {
return this.collect(Prototype.K); }
function(object) { var found = false; this.each(function(value) {
if (value == object) { found = true; throw $break; }
}); return found; } function(object) { var found = false;
this.each(function(value) { if (value == object) { found = true;
throw $break; } }); return found; }
function(iterator) { var results = []; this.each(function(value, index) {
if (iterator(value, index)) results.push(value); });
return results; } function(iterator) { var results = [];
this.each(function(value, index) { if (iterator(value, index))
results.push(value); }); return results; }
function (iterator) { var result; this.each(function(value, index) {
if (iterator(value, index)) { result = value; throw $break;
} }); return result; } function (iterator) { var result;
this.each(function(value, index) { if (iterator(value, index)) {
result = value; throw $break; } }); return result; }
function(iterator) { var results = []; this.each(function(value, index) {
results.push(iterator(value, index)); }); return results;
} function(iterator) { var results = [];
this.each(function(value, index) {
results.push(iterator(value, index)); }); return results; }
function() { return '[' + this.map(Object.inspect).join(', ') + ']';
} function() { return '[' + this.map(Object.inspect).join(', ') + ']'; }
function() { var iterator = Prototype.K, args = $A(arguments);
if (typeof args.last() == 'function') iterator = args.pop();
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
iterator(value = collections.pluck(index)); return value; });
} function() { var iterator = Prototype.K, args = $A(arguments);
if (typeof args.last() == 'function') iterator = args.pop();
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
iterator(value = collections.pluck(index)); return value; }); }
function() { return this.collect(Prototype.K); } function() {
return this.collect(Prototype.K); }
function(iterator) { return this.collect(function(value, index) {
return {value: value, criteria: iterator(value, index)};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0; }).pluck('value');
} function(iterator) { return this.collect(function(value, index) {
return {value: value, criteria: iterator(value, index)};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0; }).pluck('value'); }
function(iterator) { var results = []; this.each(function(value, index) {
if (!iterator(value, index)) results.push(value); });
return results; } function(iterator) { var results = [];
this.each(function(value, index) { if (!iterator(value, index))
results.push(value); }); return results; }
function(property) { var results = []; this.each(function(value, index) {
results.push(value[property]); }); return results;
} function(property) { var results = [];
this.each(function(value, index) { results.push(value[property]);
}); return results; }
function(iterator) { var trues = [], falses = [];
this.each(function(value, index) {
((iterator || Prototype.K)(value, index) ?
trues : falses).push(value); }); return [trues, falses];
} function(iterator) { var trues = [], falses = [];
this.each(function(value, index) {
((iterator || Prototype.K)(value, index) ?
trues : falses).push(value); }); return [trues, falses]; }
function(iterator) { var result; this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (value <= (result || value)) result = value; });
return result; } function(iterator) { var result;
this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (value <= (result || value)) result = value; });
return result; }
function(iterator) { var result; this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (value >= (result || value)) result = value; });
return result; } function(iterator) { var result;
this.each(function(value, index) {
value = (iterator || Prototype.K)(value, index);
if (value >= (result || value)) result = value; });
return result; }
function(method) { var args = $A(arguments).slice(1);
return this.collect(function(value) {
return value[method].apply(value, args); }); } function(method) {
var args = $A(arguments).slice(1); return this.collect(function(value) {
return value[method].apply(value, args); }); }
function(memo, iterator) { this.each(function(value, index) {
memo = iterator(memo, value, index); }); return memo;
} function(memo, iterator) { this.each(function(value, index) {
memo = iterator(memo, value, index); }); return memo; }
function(object) { var found = false; this.each(function(value) {
if (value == object) { found = true; throw $break; }
}); return found; } function(object) { var found = false;
this.each(function(value) { if (value == object) { found = true;
throw $break; } }); return found; }
function(pattern, iterator) { var results = [];
this.each(function(value, index) { var stringValue = value.toString();
if (stringValue.match(pattern))
results.push((iterator || Prototype.K)(value, index)); })
return results; } function(pattern, iterator) { var results = [];
this.each(function(value, index) { var stringValue = value.toString();
if (stringValue.match(pattern))
results.push((iterator || Prototype.K)(value, index)); })
return results; }
function(iterator) { var results = []; this.each(function(value, index) {
if (iterator(value, index)) results.push(value); });
return results; } function(iterator) { var results = [];
this.each(function(value, index) { if (iterator(value, index))
results.push(value); }); return results; }
function (iterator) { var result; this.each(function(value, index) {
if (iterator(value, index)) { result = value; throw $break;
} }); return result; } function (iterator) { var result;
this.each(function(value, index) { if (iterator(value, index)) {
result = value; throw $break; } }); return result; }
function(iterator) { var results = []; this.each(function(value, index) {
results.push(iterator(value, index)); }); return results;
} function(iterator) { var results = [];
this.each(function(value, index) {
results.push(iterator(value, index)); }); return results; }
function(iterator) { var result = true; this.each(function(value, index) {
if (result = !!(iterator || Prototype.K)(value, index))
throw $break; }); return result; } function(iterator) {
var result = true; this.each(function(value, index) {
if (result = !!(iterator || Prototype.K)(value, index))
throw $break; }); return result; }
function(iterator) { var result = true; this.each(function(value, index) {
result = result && !!(iterator || Prototype.K)(value, index);
if (!result) throw $break; }); return result;
} function(iterator) { var result = true;
this.each(function(value, index) {
result = result && !!(iterator || Prototype.K)(value, index);
if (!result) throw $break; }); return result; }
function(iterator) { var index = 0; try {
this._each(function(value) { try {
iterator(value, index++); } catch (e) {
if (e != $continue) throw e; } }); } catch (e) {
if (e != $break) throw e; } } function(iterator) { var index = 0;
try { this._each(function(value) { try {
iterator(value, index++); } catch (e) {
if (e != $continue) throw e; } }); } catch (e) {
if (e != $break) throw e; } }
function(object) { return Object.extend.apply(this, [this, object]);
} function(object) { return Object.extend.apply(this, [this, object]); }
Pierrot Lefou
René Martin
Alphonse Gicquel
Germaine Delabarre
Lucette Pépra
Christiane Montigne
Elysée Tayole
Gertrude Colbert
On voit apparaitre les méthodes de l'objet array, y'a du Rico aussi... compliqué !
par contre, la première partie fonctionne bien avec la boucle for. je pense que c'est parce que tu utilise ici un objet et non pas un Array ? me trompe-je ?
En tous les cas merci pour ton script, il me montre à quel point je débute en JS !
Je vais maintenant essayer que le script me retourne "nom" et "prénom" ...
Merci encore
[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]