feature(storage) rm dir -> rm subdirs of dir from storage

This commit is contained in:
coderaiser 2014-04-17 09:58:47 -04:00
parent f05038d55e
commit 81b18a99c3
2 changed files with 17 additions and 1 deletions

View file

@ -787,7 +787,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
else
DOM.deleteCurrent(current);
Storage.remove(dir);
Storage.removeMatch(dir);
});
};

View file

@ -40,6 +40,22 @@ var Util, DOM;
return this;
};
this.removeMatch = function(string, callback) {
var name, is,
reg = new RegExp('^' + string + '.*$');
for (name in localStorage) {
is = name.match(reg);
if (is)
localStorage.removeItem(name);
}
Util.exec(callback);
return this;
};
/** если доступен localStorage и
* в нём есть нужная нам директория -
* записываем данные в него