|
|
|
|
@ -89,7 +89,7 @@ function reactToURLParameters() {
|
|
|
|
|
const rawHash = location.hash;
|
|
|
|
|
if (rawHash == "") return;
|
|
|
|
|
|
|
|
|
|
const hash = rawHash.slice(1);
|
|
|
|
|
const hash = decodeURIComponent(rawHash.slice(1));
|
|
|
|
|
|
|
|
|
|
if (hash.startsWith("q=")) {
|
|
|
|
|
useSearchTerm(decodeURIComponent(hash.slice(2)), true);
|
|
|
|
|
@ -97,8 +97,8 @@ function reactToURLParameters() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hash.includes("+")) {
|
|
|
|
|
useSearchTerm(`#${decodeURIComponent(hash)}`, true);
|
|
|
|
|
if (!hash.includes("+") && !document.querySelector(`#${hash}`)) {
|
|
|
|
|
useSearchTerm(`#${hash}`, true);
|
|
|
|
|
toggleSearchBarVisibility();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -491,9 +491,19 @@ function addServerIconInteractions() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleSearchBarVisibility() {
|
|
|
|
|
/**
|
|
|
|
|
* @param {?boolean} setShown
|
|
|
|
|
*/
|
|
|
|
|
function toggleSearchBarVisibility(setShown = null) {
|
|
|
|
|
const container = dom.search_container();
|
|
|
|
|
container?.classList.toggle(CLASSES.COMPONENTS.COLLAPSED);
|
|
|
|
|
const hadClass = container?.classList.contains(CLASSES.COMPONENTS.COLLAPSED);
|
|
|
|
|
if (setShown == null) {
|
|
|
|
|
container?.classList.toggle(CLASSES.COMPONENTS.COLLAPSED);
|
|
|
|
|
} else if (setShown == true) {
|
|
|
|
|
container?.classList.remove(CLASSES.COMPONENTS.COLLAPSED);
|
|
|
|
|
} else if (setShown == false) {
|
|
|
|
|
container?.classList.add(CLASSES.COMPONENTS.COLLAPSED);
|
|
|
|
|
}
|
|
|
|
|
if (!container?.classList.contains(CLASSES.COMPONENTS.COLLAPSED)) {
|
|
|
|
|
const searchBar = dom.search_bar();
|
|
|
|
|
searchBar?.focus();
|
|
|
|
|
@ -502,6 +512,9 @@ function toggleSearchBarVisibility() {
|
|
|
|
|
} else {
|
|
|
|
|
useSearchTerm("");
|
|
|
|
|
}
|
|
|
|
|
if (setShown == hadClass) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addSearchInteractions() {
|
|
|
|
|
@ -526,6 +539,22 @@ function addSearchInteractions() {
|
|
|
|
|
dom.search_bar()?.focus();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
dom.btn_share_search()?.addEventListener('click', function() {
|
|
|
|
|
const searchTerm = dom.search_bar()?.value;
|
|
|
|
|
if (!searchTerm) return;
|
|
|
|
|
const searchTermIsTag = searchTerm.startsWith('#') && !searchTerm.includes("+");
|
|
|
|
|
const hash = searchTermIsTag ? searchTerm : `#q=${searchTerm}`;
|
|
|
|
|
const newLocation = new URL(location.href);
|
|
|
|
|
newLocation.hash = hash;
|
|
|
|
|
if (navigator.share) {
|
|
|
|
|
navigator.share({
|
|
|
|
|
url: newLocation.href
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
copyToClipboard(newLocation.href, "Share link copied to clipboard.")
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Array.from(dom.sample_searches()).forEach(button => button.addEventListener('click', function() {
|
|
|
|
|
const targetSearch = button.getAttribute(ATTRIBUTES.SEARCH.TARGET_SEARCH);
|
|
|
|
|
if (targetSearch === null) {
|
|
|
|
|
@ -752,3 +781,13 @@ function sortTable(column) {
|
|
|
|
|
document.documentElement.classList.add("js");
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => onLoad());
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
document.querySelector("#banner-sample-search")?.addEventListener('click', function() {
|
|
|
|
|
useSearchTerm(this.getAttribute('search-target'), true);
|
|
|
|
|
const changed = toggleSearchBarVisibility(true);
|
|
|
|
|
if (!changed) return;
|
|
|
|
|
dom.btn_share_search()?.classList.add('highlight');
|
|
|
|
|
setTimeout(() => dom.btn_share_search()?.classList.remove('highlight'), 2000);
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|