(value)
| 131 | } |
| 132 | |
| 133 | function doSearch(value) { |
| 134 | const $search = Docsify.dom.find('div.search'); |
| 135 | const $panel = Docsify.dom.find($search, '.results-panel'); |
| 136 | const $clearBtn = Docsify.dom.find($search, '.clear-button'); |
| 137 | const $sidebarNav = Docsify.dom.find('.sidebar-nav'); |
| 138 | const $appName = Docsify.dom.find('.app-name'); |
| 139 | |
| 140 | if (!value) { |
| 141 | $panel.classList.remove('show'); |
| 142 | $clearBtn.classList.remove('show'); |
| 143 | $panel.innerHTML = ''; |
| 144 | |
| 145 | if (options.hideOtherSidebarContent) { |
| 146 | $sidebarNav && $sidebarNav.classList.remove('hide'); |
| 147 | $appName && $appName.classList.remove('hide'); |
| 148 | } |
| 149 | |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | const matchs = search(value); |
| 154 | |
| 155 | let html = ''; |
| 156 | matchs.forEach(post => { |
| 157 | html += `<div class="matching-post"> |
| 158 | <a href="${post.url}"> |
| 159 | <h2>${post.title}</h2> |
| 160 | <p>${post.content}</p> |
| 161 | </a> |
| 162 | </div>`; |
| 163 | }); |
| 164 | |
| 165 | $panel.classList.add('show'); |
| 166 | $clearBtn.classList.add('show'); |
| 167 | $panel.innerHTML = html || `<p class="empty">${NO_DATA_TEXT}</p>`; |
| 168 | if (options.hideOtherSidebarContent) { |
| 169 | $sidebarNav && $sidebarNav.classList.add('hide'); |
| 170 | $appName && $appName.classList.add('hide'); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | function bindEvents() { |
| 175 | const $search = Docsify.dom.find('div.search'); |
no test coverage detected
searching dependent graphs…