template.js.search_all.js.btl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smart-doc Show documentation
Show all versions of smart-doc Show documentation
Smart-doc is a tool that supports both JAVA RESTFUL API and Apache Dubbo RPC interface document
generation.
let api = [];
const apiDocListSize = ${apiDocList.~size}
<%for(apiGroup in apiDocList) {%>
api.push({
name: '${strUtil.replace(apiGroup.group, "\'", "\\'")}',
order: '${apiGroup.order}',
list: []
})
<%for(api in apiGroup.childrenApiDocs) {%>
api[${apiGroupLP.dataIndex}].list.push({
alias: '${strUtil.replace(api.alias, "\'", "\\'")}',
order: '${api.order}',
link: '${strUtil.replace(removeLineBreaks(api.link), "\'", "\\'")}',
desc: '${strUtil.replace(removeLineBreaks(api.desc), "\'", "\\'")}',
list: []
})
<%for(doc in api.list) {%>
api[${apiGroupLP.dataIndex}].list[${apiLP.dataIndex}].list.push({
order: '${doc.order}',
deprecated: '${doc.deprecated}',
url: '${doc.url}',
desc: '${strUtil.replace(removeLineBreaks(doc.desc), "\'", "\\'")}',
});
<%}%>
<%}%>
<%}%>
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
const theEvent = e;
const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
if (code === 13) {
const search = document.getElementById('search');
const searchValue = search.value.toLocaleLowerCase();
let searchGroup = [];
for (let i = 0; i < api.length; i++) {
let apiGroup = api[i];
let searchArr = [];
for (let i = 0; i < apiGroup.list.length; i++) {
let apiData = apiGroup.list[i];
const desc = apiData.desc;
if (desc.toLocaleLowerCase().indexOf(searchValue) > -1) {
searchArr.push({
order: apiData.order,
desc: apiData.desc,
link: apiData.link,
list: apiData.list
});
} else {
let methodList = apiData.list || [];
let methodListTemp = [];
for (let j = 0; j < methodList.length; j++) {
const methodData = methodList[j];
const methodDesc = methodData.desc;
if (methodDesc.toLocaleLowerCase().indexOf(searchValue) > -1) {
methodListTemp.push(methodData);
break;
}
}
if (methodListTemp.length > 0) {
const data = {
order: apiData.order,
desc: apiData.desc,
link: apiData.link,
list: methodListTemp
};
searchArr.push(data);
}
}
}
if (apiGroup.name.toLocaleLowerCase().indexOf(searchValue) > -1) {
searchGroup.push({
name: apiGroup.name,
order: apiGroup.order,
list: searchArr
});
continue;
}
if (searchArr.length === 0) {
continue;
}
searchGroup.push({
name: apiGroup.name,
order: apiGroup.order,
list: searchArr
});
}
let html;
if (searchValue === '') {
const liClass = "";
const display = "display: none";
html = buildAccordion(api,liClass,display);
document.getElementById('accordion').innerHTML = html;
} else {
const liClass = "open";
const display = "display: block";
html = buildAccordion(searchGroup,liClass,display);
document.getElementById('accordion').innerHTML = html;
}
const Accordion = function (el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
const links = this.el.find('.dd');
links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown);
};
Accordion.prototype.dropdown = function (e) {
const $el = e.data.el;
let $this = $(this), $next = $this.next();
$next.slideToggle();
$this.parent().toggleClass('open');
if (!e.data.multiple) {
$el.find('.submenu').not($next).slideUp("20").parent().removeClass('open');
}
};
new Accordion($('#accordion'), false);
}
}
function buildAccordion(apiGroups, liClass, display) {
let html = "";
if (apiGroups.length > 0) {
if (apiDocListSize === 1) {
let apiData = apiGroups[0].list;
let order = apiGroups[0].order;
for (let j = 0; j < apiData.length; j++) {
html += '';
html += '' + apiData[j].order + '. ' + apiData[j].desc + '';
html += '';
let doc = apiData[j].list;
for (let m = 0; m < doc.length; m++) {
let spanString;
if (doc[m].deprecated === 'true') {
spanString='';
} else {
spanString='';
}
html += '- ' + apiData[j].order + '.' + doc[m].order + '. ' + spanString + doc[m].desc + '
';
}
html += '
';
html += ' ';
}
} else {
for (let i = 0; i < apiGroups.length; i++) {
let apiGroup = apiGroups[i];
html += '';
html += '' + apiGroup.order + '. ' + apiGroup.name + '';
html += '';
let apiData = apiGroup.list;
for (let j = 0; j < apiData.length; j++) {
html += '- ';
html += '' +apiGroup.order+'.'+ apiData[j].order + '. ' + apiData[j].desc + '';
html += '
';
let doc = apiData[j].list;
for (let m = 0; m < doc.length; m++) {
let spanString;
if (doc[m].deprecated === 'true') {
spanString='';
} else {
spanString='';
}
html += '- '+apiGroup.order+'.' + apiData[j].order + '.' + doc[m].order + '. ' + spanString + doc[m].desc + '
';
}
html += '
';
html += ' ';
}
html += '
';
html += ' ';
}
}
}
return html;
}