refactored

This commit is contained in:
coderaiser 2012-12-23 06:42:04 -05:00
parent 9ed41613ff
commit 5fcd84c559

View file

@ -109,25 +109,15 @@ var CloudCommander, Util, DOM, $;
* pItems = [{pName, pFunc}]
*/
function getAllItems(pItems){
var lRet = {};
var lRet = {},
lName,
lFunc;
if( Util.isArray(pItems) ){
var lName,
lFunc,
i, n = pItems.length;
for(i = 0; i < n; i++){
var lItem = pItems[i];
if(lItem){
lName = lItem.name;
for(var lProp in lItem){
lName = lProp;
lFunc = lItem[lProp];
}
lRet[lName] = getItem(lName, lFunc);
}
if(pItems)
for(lName in pItems){
lFunc = pItems[lName];
lRet[lName] = getItem(lName, lFunc);
}
}
return lRet;
}
@ -148,13 +138,12 @@ var CloudCommander, Util, DOM, $;
},
// define the elements of the menu
items: getAllItems([
{ 'View' : Util.retExec(showEditor, true) },
{ 'Edit' : Util.retExec(showEditor) },
{ 'Delete' : Util.retExec(DOM.promptRemoveCurrent) },
{ 'Upload to' : getUploadToItem( ['GitHub', 'GDrive', 'DropBox'] ) },
{
'Download' : function(key, opt){
items: getAllItems({
'View' : Util.retExec(showEditor, true),
'Edit' : Util.retExec(showEditor),
'Delete' : Util.retExec(DOM.promptRemoveCurrent),
'Upload to' : getUploadToItem( ['GitHub', 'GDrive', 'DropBox'] ),
'Download' : function(key, opt){
DOM.Images.showLoad();
var lPath = DOM.getCurrentPath(),
@ -183,8 +172,7 @@ var CloudCommander, Util, DOM, $;
responseText: 'Error: You trying to' +
'download same file to often'});
}
}
])
})
};
}