Fill the search input form with the current search keywords.

pull/23038/head
TAKAHASHI Shuuji 2020-08-09 12:14:40 +09:00
parent 1d91623257
commit 34d805df72
1 changed files with 9 additions and 0 deletions

View File

@ -17,6 +17,15 @@ limitations under the License.
var Search = {
init: function () {
$(document).ready(function () {
// Fill the search input form with the current search keywords
const searchKeywords = new URLSearchParams(location.search).get('q');
if (searchKeywords !== null && searchKeywords !== '') {
const searchInput = document.querySelector('.td-search-input');
searchInput.focus();
searchInput.value = searchKeywords;
}
// Set a keydown event
$(document).on("keypress", ".td-search-input", function (e) {
if (e.keyCode !== 13) {
return;