mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Modified pad list manager to return an ordered list.
This commit is contained in:
parent
062dbff738
commit
9687ecbb82
1 changed files with 10 additions and 0 deletions
|
@ -44,6 +44,7 @@ var globalPads = {
|
||||||
|
|
||||||
var padList = {
|
var padList = {
|
||||||
list: [],
|
list: [],
|
||||||
|
sorted : false,
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
db.findKeys("pad:*", "*:*:*", function(err, dbData)
|
db.findKeys("pad:*", "*:*:*", function(err, dbData)
|
||||||
|
@ -57,13 +58,21 @@ var padList = {
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Returns all pads in alphabetical order as array.
|
||||||
|
*/
|
||||||
getPads: function(){
|
getPads: function(){
|
||||||
|
if(!this.sorted){
|
||||||
|
this.list=this.list.sort();
|
||||||
|
this.sorted=true;
|
||||||
|
}
|
||||||
return this.list;
|
return this.list;
|
||||||
},
|
},
|
||||||
addPad: function(name)
|
addPad: function(name)
|
||||||
{
|
{
|
||||||
if(this.list.indexOf(name) == -1){
|
if(this.list.indexOf(name) == -1){
|
||||||
this.list.push(name);
|
this.list.push(name);
|
||||||
|
this.sorted=false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removePad: function(name)
|
removePad: function(name)
|
||||||
|
@ -71,6 +80,7 @@ var padList = {
|
||||||
var index=this.list.indexOf(name);
|
var index=this.list.indexOf(name);
|
||||||
if(index>-1){
|
if(index>-1){
|
||||||
this.list.splice(index,1);
|
this.list.splice(index,1);
|
||||||
|
this.sorted=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue