refactor(cloudfunc) getPathElement

This commit is contained in:
coderaiser 2014-05-26 08:18:40 -04:00
parent 9e38885615
commit 1eaf2140e5

View file

@ -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;