(value)
| 204 | } |
| 205 | |
| 206 | function doSearch(value) { |
| 207 | var $search = Docsify.dom.find('div.search'); |
| 208 | var $panel = Docsify.dom.find($search, '.results-panel'); |
| 209 | var $clearBtn = Docsify.dom.find($search, '.clear-button'); |
| 210 | var $sidebarNav = Docsify.dom.find('.sidebar-nav'); |
| 211 | var $appName = Docsify.dom.find('.app-name'); |
| 212 | |
| 213 | if (!value) { |
| 214 | $panel.classList.remove('show'); |
| 215 | $clearBtn.classList.remove('show'); |
| 216 | $panel.innerHTML = ''; |
| 217 | |
| 218 | if (options.hideOtherSidebarContent) { |
| 219 | $sidebarNav.classList.remove('hide'); |
| 220 | $appName.classList.remove('hide'); |
| 221 | } |
| 222 | return |
| 223 | } |
| 224 | var matchs = search(value); |
| 225 | |
| 226 | var html = ''; |
| 227 | matchs.forEach(function (post) { |
| 228 | html += "<div class=\"matching-post\">\n<a href=\"" + (post.url) + "\">\n<h2>" + (post.title) + "</h2>\n<p>" + (post.content) + "</p>\n</a>\n</div>"; |
| 229 | }); |
| 230 | |
| 231 | $panel.classList.add('show'); |
| 232 | $clearBtn.classList.add('show'); |
| 233 | $panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>"); |
| 234 | if (options.hideOtherSidebarContent) { |
| 235 | $sidebarNav.classList.add('hide'); |
| 236 | $appName.classList.add('hide'); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | function bindEvents() { |
| 241 | var $search = Docsify.dom.find('div.search'); |
no test coverage detected