Stackedit/public/res/folderList.js

25 lines
690 B
JavaScript
Raw Normal View History

2013-08-12 00:10:37 +00:00
define([
"underscore",
"utils",
"storage",
2013-08-12 00:10:37 +00:00
"classes/FolderDescriptor",
"storage",
], function(_, utils, storage, FolderDescriptor) {
2013-08-12 00:10:37 +00:00
var folderList = {};
// Retrieve folder descriptors from localStorage
utils.retrieveIndexArray("folder.list").forEach(function(folderIndex) {
2013-08-12 00:10:37 +00:00
folderList[folderIndex] = new FolderDescriptor(folderIndex);
});
// Clean fields from deleted folders in local storage
Object.keys(storage).forEach(function(key) {
var match = key.match(/(folder\.\S+?)\.\S+/);
if(match && !folderList.hasOwnProperty(match[1])) {
storage.removeItem(key);
}
});
2013-08-12 00:10:37 +00:00
return folderList;
});