Permalink
Browse files

Modified pad list manager to return an ordered list.

  • Loading branch information...
spcsser
spcsser committed Jan 11, 2013
1 parent 062dbff commit 9687ecbb829721ff6272cfbc7d4a8e3eba9a4892
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/node/db/PadManager.js
View
@@ -44,6 +44,7 @@ var globalPads = {
var padList = {
list: [],
+ sorted : false,
init: function()
{
db.findKeys("pad:*", "*:*:*", function(err, dbData)
@@ -57,20 +58,29 @@ var padList = {
});
return this;
},
+ /**
+ * Returns all pads in alphabetical order as array.
+ */
getPads: function(){
+ if(!this.sorted){
+ this.list=this.list.sort();
+ this.sorted=true;
+ }
return this.list;
},
addPad: function(name)
{
if(this.list.indexOf(name) == -1){
this.list.push(name);
+ this.sorted=false;
}
},
removePad: function(name)
{
var index=this.list.indexOf(name);
if(index>-1){
this.list.splice(index,1);
+ this.sorted=false;
}
}
};

0 comments on commit 9687ecb

Please sign in to comment.