2022-11-27 17:16:38 +08:00
|
|
|
<%
|
|
|
|
function layoutDiv() {
|
|
|
|
var el = '<widget class="widget-wrapper search">'
|
|
|
|
el += '<div class="widget-body">'
|
|
|
|
el += '<div class="search-wrapper" id="search">'
|
|
|
|
el += '<form class="search-form">'
|
|
|
|
var filter = ''
|
2022-11-29 21:54:15 +08:00
|
|
|
if (item.filter == 'auto') {
|
|
|
|
if (page.layout == 'wiki') {
|
|
|
|
let matches = page.path.match(/(.*?)\/(.*?)\//i)
|
|
|
|
if (matches?.length > 0) {
|
|
|
|
filter = matches[0]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (item.filter?.length > 0) {
|
|
|
|
filter = item.filter
|
2022-11-27 17:16:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
el += '<input type="text" class="search-input" id="search-input"'
|
|
|
|
if (filter.length > 0) {
|
2022-11-29 21:54:15 +08:00
|
|
|
if (!filter.startsWith('/')) {
|
|
|
|
filter = '/' + filter
|
|
|
|
}
|
2022-11-27 17:16:38 +08:00
|
|
|
el += ' data-filter="' + filter + '"'
|
|
|
|
el += ' placeholder="' + (item.placeholder || __('search.search_in', filter)) + '">'
|
|
|
|
} else {
|
|
|
|
el += ' placeholder="' + (item.placeholder || __('search.search')) + '">'
|
|
|
|
}
|
|
|
|
el += '</form>'
|
|
|
|
el += '<div id="search-result"></div>'
|
|
|
|
el += '<div class="search-no-result">' + __('search.no_results') + '</div>'
|
|
|
|
el += '</div>'
|
|
|
|
el += '</div>'
|
|
|
|
el += '</widget>'
|
|
|
|
return el
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
<%- layoutDiv() %>
|