Added functionality to use spcsser/ueberDB findKey functionality.

This commit is contained in:
Swen 2013-01-09 20:45:39 +01:00
parent 7a49c82e16
commit c9f137b2e5
1 changed files with 3 additions and 7 deletions

View File

@ -46,12 +46,12 @@ var padList = {
list: [], list: [],
init: function() init: function()
{ {
db.get("pads", function(err, dbData) db.findKeys("pad:*", "*:*:*", function(err, dbData)
{ {
if(ERR(err)) return; if(ERR(err)) return;
if(dbData != null){ if(dbData != null){
dbData.forEach(function(val){ dbData.forEach(function(val){
padList.addPad(val,false); padList.addPad(val.replace(/pad:/,""),false);
}); });
} }
}); });
@ -60,13 +60,10 @@ var padList = {
getPads: function(){ getPads: function(){
return this.list; return this.list;
}, },
addPad: function(name,immediateSave) addPad: function(name)
{ {
if(this.list.indexOf(name) == -1){ if(this.list.indexOf(name) == -1){
this.list.push(name); this.list.push(name);
if(immediateSave == undefined || immediateSave == true){
db.set("pads", this.list);
}
} }
}, },
removePad: function(name) removePad: function(name)
@ -74,7 +71,6 @@ 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);
db.set("pads", this.list);
} }
} }
}; };