mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(cloudfunc) getPathElement
This commit is contained in:
parent
9e38885615
commit
1eaf2140e5
1 changed files with 21 additions and 14 deletions
|
|
@ -330,24 +330,31 @@ var Util;
|
|||
var pathHTML = '',
|
||||
path = '/',
|
||||
template = '<a data-name="js-path-link" href="/fs{{ path }}" title="{{ path }}">{{ name }}</a>{{ slash }}',
|
||||
names = url.split('/')
|
||||
.slice(0, -1);
|
||||
|
||||
names[0] = '/';
|
||||
namesRaw = url.split('/')
|
||||
.slice(1, -1),
|
||||
names = [].concat('/', namesRaw),
|
||||
|
||||
length = names.length - 1;
|
||||
|
||||
names.forEach(function(name, index) {
|
||||
var slash = '/';
|
||||
var slash = '',
|
||||
isLast = index === length;
|
||||
|
||||
if (!index)
|
||||
slash = '';
|
||||
else
|
||||
path += name + '/';
|
||||
if (index)
|
||||
path += name + '/';
|
||||
|
||||
pathHTML += Util.render(template, {
|
||||
path: path,
|
||||
name: name,
|
||||
slash: slash
|
||||
});
|
||||
if (index && isLast) {
|
||||
pathHTML += name + '/';
|
||||
} else {
|
||||
if (index)
|
||||
slash = '/';
|
||||
|
||||
pathHTML += Util.render(template, {
|
||||
path: path,
|
||||
name: name,
|
||||
slash: slash
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return pathHTML;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue