mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(client) createFileTable: add getCurrentFileByName
This commit is contained in:
parent
d3a401b6d7
commit
4d41d47104
2 changed files with 9 additions and 28 deletions
|
|
@ -379,16 +379,12 @@ var Util, DOM, CloudFunc, join;
|
|||
* @param callback
|
||||
*/
|
||||
function createFileTable(json, panelParam, history, callback) {
|
||||
var files,
|
||||
panel = panelParam || DOM.getPanel(),
|
||||
/* getting current element if was refresh */
|
||||
path = DOM.getCurrentDirPath(panel),
|
||||
wasRefresh = path === json.path,
|
||||
names = ['file', 'path', 'link', 'pathLink'];
|
||||
var names = ['file', 'path', 'link', 'pathLink'];
|
||||
|
||||
Files.get(names, function(error, templFile, templPath, templLink, templPathLink) {
|
||||
var n, found, varCurrent, varName, current,
|
||||
Dialog = DOM.Dialog,
|
||||
var Dialog = DOM.Dialog,
|
||||
current,
|
||||
panel = panelParam || DOM.getPanel(),
|
||||
dir = DOM.getCurrentDirName(),
|
||||
name = DOM.getCurrentName(),
|
||||
i = panel.childNodes.length;
|
||||
|
|
@ -410,25 +406,10 @@ var Util, DOM, CloudFunc, join;
|
|||
}
|
||||
});
|
||||
|
||||
files = DOM.getFiles(panel);
|
||||
current = DOM.getCurrentFileByName(name);
|
||||
|
||||
/* searching current file */
|
||||
if (wasRefresh) {
|
||||
n = files.length;
|
||||
|
||||
for (i = 0; i < n ; i++) {
|
||||
varCurrent = files[i],
|
||||
varName = DOM.getCurrentName(varCurrent);
|
||||
found = varName === name;
|
||||
|
||||
if (found) {
|
||||
current = files[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) /* .. */
|
||||
current = files[0];
|
||||
if (!current) /* .. */
|
||||
current = DOM.getFiles(panel)[0];
|
||||
|
||||
DOM.setCurrentFile(current, {
|
||||
history: history
|
||||
|
|
|
|||
|
|
@ -691,8 +691,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.getCurrentFileByName = function(name) {
|
||||
var element,
|
||||
panel = DOM.getPanel();
|
||||
|
||||
panel = CurrentInfo.panel;
|
||||
|
||||
name = 'js-file-' + name;
|
||||
element = DOM.getByDataName(name, panel);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue