mirror of
https://github.com/mipmip/home-manager-option-search.git
synced 2024-09-11 15:16:31 +03:00
Compare commits
4 Commits
aac39bc1c1
...
065337f4c3
Author | SHA1 | Date | |
---|---|---|---|
|
065337f4c3 | ||
|
5180bcd4e7 | ||
|
f0625106ba | ||
|
2c611da1c7 |
@ -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; } }
|
||||
|
44
js/script.js
44
js/script.js
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user