apinode
Version:
An API server that can greatly reduce the work needed to implment API services. It can also cooperate with other API node to make it a mesh of services.
57 lines (52 loc) • 1.27 kB
HTML
<%
var eps = _params.endpoints;
var indent = _params.indent >= 0 ? _params.indent : 20;
var active = _params.active || "";
//console.log(JSON.stringify(eps), '', 4);
%>
<%
function isString(s) {
if (typeof s === 'string' || s instanceof String)
return true;
else
return false;
}
%>
<nav class="sidebar-nav">
<ul class="metismenu" id="menu">
<%for(var i in eps){
if(isString(eps[i])){
nextlevel(null, eps[i] , '');
} else {
for(var k in eps[i]){
nextlevel(eps[i][k], k, '')
}
}
};%>
</ul>
</nav>
<%
function nextlevel (obj, objName, path) {
var level = path.split('/').length - 1;
var nextPath = path + '/' + objName;
var id = nextPath.replace(/\//g,'_');
if(obj == null){
%>
<li><a style="padding-left: <%=(level*25 + 15)+'px'%>"
href="javascript: <%=ctrl%>.selectEndpoint('<%=nextPath%>')"><%=objName%></a></li>
<%} else {%>
<li class="<%=active.startsWith(nextPath) ? 'active' : ''%>">
<a href="#" style="padding-left: <%=(level*indent + 15)+'px'%>"><%=objName%><span class="fa arrow"></a>
<ul>
<%for(var i in obj){
if(isString(obj[i])){
nextlevel(null, obj[i] , nextPath);
} else {
for(var k in obj[i]){
nextlevel(obj[i][k], k, nextPath)
}
}
};%>
</ul>
</li>
<%}}%>