Improve the layout of the home page
This commit is contained in:
parent
ad245ae8b4
commit
ea0d2ad97b
10 changed files with 120 additions and 15 deletions
13
static/search.js
Normal file
13
static/search.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
const searchInput = document.getElementById('movie-search');
|
||||
const datalist = document.getElementById('movies');
|
||||
const dataitems = new Map();
|
||||
Array.from(datalist.children).forEach(function (ch) {
|
||||
dataitems.set(ch.value, ch.getAttribute('data-value'));
|
||||
});
|
||||
|
||||
searchInput.addEventListener('change', function(e) {
|
||||
const targetLocation = dataitems.get(e.target.value);
|
||||
if (targetLocation) {
|
||||
window.location.href = targetLocation;
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue