Compare commits

...

4 Commits

Author SHA1 Message Date
Pim Snel
065337f4c3
Merge pull request #9 from PrimaMateria/feature/search-query-url-param
search query url param
2023-06-06 11:43:43 +02:00
Pim Snel
5180bcd4e7
Merge pull request #6 from mk3z/main
Add padding to the bottom of the list container
2023-06-06 11:43:25 +02:00
matus.benko
f0625106ba search query url param
On search it reads the search input value, sets the param, and searches.
On doc load it reads the param, sets the search input value, and searches.
Removed searchEnter, as I didn't find any usage of it.
2023-06-06 00:20:31 +02:00
Matias Zwinger
2c611da1c7
Add padding to the bottom of the list container
Previously the last list item was partially obstructed by the footer
2023-02-08 18:38:11 +02:00
2 changed files with 20 additions and 27 deletions

View File

@ -179,7 +179,8 @@ th {
.container {
width: 75em;
margin: 0 auto;
padding: 0; }
padding: 0;
padding-bottom: 47px; }
@media only all and (min-width: 60em) and (max-width: 74.938em) {
.container {
width: 60em; } }

View File

@ -12,30 +12,11 @@ var rebuildAndRerunSearch = function() {
searchOptions();
};
var searchEnter = function() {
event.preventDefault();
console.log(window.location.href);
if(searchInput.value !== ""){
newurl = window.location.href.split('?')[0]+"?"+searchInput.value.trim();
console.log(newurl);
window.location.href = encodeURI(newurl);
}
}
var docOnload = function(){
var queryString = "";
if(window.location.href.includes("?")){
queryString = decodeURI(window.location.href.split('?')[1]);
searchInput.value = queryString;
}
if(queryString !== ""){
searchOptions();
}
const urlParams = new URLSearchParams(window.location.search);
const query = urlParams.get('query');
searchInput.value = query;
searchOptions(query);
$("#advcheck").prop("checked", false);
// $("#advcheck").removeAttr("checked");
@ -145,12 +126,23 @@ var updateOptionCountAndTable = function() {
}
};
var searchOptions = function() {
results = search.search(searchInput.value);
var setSearchQueryToUrlParam = function(query) {
const urlParams = new URLSearchParams();
urlParams.set('query', query);
const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
window.history.replaceState({}, '', newUrl);
};
var searchOptions = function(query) {
results = search.search(query);
updateOptionCountAndTable();
};
searchInput.oninput = searchOptions;
searchInput.oninput = function () {
const query = searchInput.value;
setSearchQueryToUrlParam(query);
searchOptions(query);
}
var updateOptionCount = function(numOptions) {
optionCountBadge.innerText = numOptions + ' options';