Improve GroupsList each() method and use it in count() and export() methods
This commit is contained in:
parent
13f3db00d5
commit
cc37ad1ffc
1 changed files with 9 additions and 11 deletions
|
@ -28,13 +28,9 @@ function GroupList() {
|
|||
}
|
||||
|
||||
this.export=function() {
|
||||
ret={};
|
||||
for (el in this) {
|
||||
if (this.isGroup(this[el])) {
|
||||
ret[el]=this[el].export();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return this.each(function(idx,group) {
|
||||
return group.export();
|
||||
});
|
||||
}
|
||||
|
||||
this.import=function(groups) {
|
||||
|
@ -60,18 +56,20 @@ function GroupList() {
|
|||
|
||||
this.each=function(fct) {
|
||||
var idx=0;
|
||||
var ret={};
|
||||
for (el in this) {
|
||||
if(this.isGroup(this[el])) {
|
||||
fct(idx++,this[el]);
|
||||
ret[el]=fct(idx++,this[el]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
this.count=function() {
|
||||
len=0;
|
||||
for (el in this) {
|
||||
if (this.isGroup(this[el])) len=len+1;
|
||||
}
|
||||
this.each(function(idx,group) {
|
||||
len=len+1;
|
||||
});
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue