cleaned up JS
This commit is contained in:
parent
186026fa6d
commit
cdd0c13cdc
7 changed files with 82 additions and 75 deletions
|
@ -1,3 +1,6 @@
|
|||
/*
|
||||
This script is responsible for fetching new results on the same page when the user scrolls to the bottom of the page.
|
||||
*/
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const templateData = document.getElementById('template-data');
|
||||
let page = parseInt(templateData.getAttribute('data-page')) || 1;
|
||||
|
@ -12,10 +15,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
if (loading || !hasMoreResults) return;
|
||||
loading = true;
|
||||
|
||||
// Show loading indicator if taking more than 100ms
|
||||
// Show loading indicator if taking more than 150ms
|
||||
loadingTimeout = setTimeout(() => {
|
||||
loadingIndicator.style.display = 'flex';
|
||||
}, 100);
|
||||
}, 150);
|
||||
|
||||
fetch(`/search?q=${encodeURIComponent(query)}&t=${encodeURIComponent(searchType)}&p=${newPage}`)
|
||||
.then(response => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue