KingNish commited on
Commit
21a5615
·
verified ·
1 Parent(s): cbf0a6d

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +30 -25
templates/index.html CHANGED
@@ -82,8 +82,6 @@
82
  </head>
83
  <body>
84
  <div class="intro-page" id="intro-page">
85
- <h1>Welcome to HelpingAI Search</h1>
86
- <p>Discover the web with our powerful search engine.</p>
87
  <div class="search-container">
88
  <form id="search-form">
89
  <div class="search-box">
@@ -93,6 +91,8 @@
93
  <div id="suggestions"></div>
94
  </form>
95
  </div>
 
 
96
  </div>
97
  <div class="main-content" id="main-content">
98
  <div class="search-container">
@@ -257,27 +257,32 @@ function hideLoading() {
257
  }
258
  let startTime;
259
  async function performSearch(query) {
260
- showLoading();
261
- seenUrls.clear();
262
- allResultsFetched = false;
263
- resultsContainer.innerHTML = '';
264
- noResultsMessage.style.display = 'none';
265
- loadingMoreIndicator.classList.remove('active');
266
- suggestionsContainer.style.display = 'none';
267
- mainSuggestionsContainer.style.display = 'none';
268
- startTime = performance.now(); // Start time calculation here
269
- const initialResults = await fetchResults(query, INITIAL_RESULTS);
270
- updateURLWithQuery(query);
271
- displayResults(initialResults);
272
- hideLoading();
273
- if (initialResults.length > 0) {
274
- cachedSearchResults = await fetchResults(query, CACHED_RESULTS);
275
- cachedSearchResults = removeDuplicateResults(cachedSearchResults);
276
- } else {
277
- cachedSearchResults = [];
278
- }
279
- introPage.style.display = 'none';
280
- mainContent.style.display = 'flex';
 
 
 
 
 
281
  }
282
 
283
  function updateURLWithQuery(query) {
@@ -346,7 +351,7 @@ function displayResults(results, append = false) {
346
  noResultsMessage.style.display = resultsContainer.children.length === 0 ? 'block' : 'none';
347
  if (!append) {
348
  const endTime = performance.now();
349
- const timeTaken = (endTime / 2 - startTime).toFixed(2);
350
  document.getElementById('results-info').textContent = `About ${timeTaken} milliseconds`;
351
  }
352
  }
@@ -463,7 +468,7 @@ window.addEventListener("scroll", () => {
463
  scrollHeight,
464
  clientHeight
465
  } = document.documentElement;
466
- if (scrollTop + clientHeight >= scrollHeight - 100 && !loadingMoreIndicator.classList.contains("active")) {
467
  loadingMoreIndicator.classList.add("active");
468
  const resultsToDisplay = cachedSearchResults.splice(0, RESULTS_PER_PAGE);
469
  if (resultsToDisplay.length > 0) {
 
82
  </head>
83
  <body>
84
  <div class="intro-page" id="intro-page">
 
 
85
  <div class="search-container">
86
  <form id="search-form">
87
  <div class="search-box">
 
91
  <div id="suggestions"></div>
92
  </form>
93
  </div>
94
+ <h1>Welcome to HelpingAI Search</h1>
95
+ <p>Discover the web with our powerful search engine.</p>
96
  </div>
97
  <div class="main-content" id="main-content">
98
  <div class="search-container">
 
257
  }
258
  let startTime;
259
  async function performSearch(query) {
260
+ showLoading();
261
+ seenUrls.clear();
262
+ allResultsFetched = false;
263
+ resultsContainer.innerHTML = '';
264
+ noResultsMessage.style.display = 'none';
265
+ loadingMoreIndicator.classList.remove('active');
266
+ suggestionsContainer.style.display = 'none';
267
+ mainSuggestionsContainer.style.display = 'none';
268
+
269
+ // Initialize startTime here
270
+ startTime = performance.now();
271
+
272
+ const initialResults = await fetchResults(query, INITIAL_RESULTS);
273
+ updateURLWithQuery(query);
274
+ displayResults(initialResults);
275
+ hideLoading();
276
+
277
+ if (initialResults.length > 0) {
278
+ cachedSearchResults = await fetchResults(query, CACHED_RESULTS);
279
+ cachedSearchResults = removeDuplicateResults(cachedSearchResults);
280
+ } else {
281
+ cachedSearchResults = [];
282
+ }
283
+
284
+ introPage.style.display = 'none';
285
+ mainContent.style.display = 'flex';
286
  }
287
 
288
  function updateURLWithQuery(query) {
 
351
  noResultsMessage.style.display = resultsContainer.children.length === 0 ? 'block' : 'none';
352
  if (!append) {
353
  const endTime = performance.now();
354
+ const timeTaken = (endTime / 2 - startTime/2).toFixed(2);
355
  document.getElementById('results-info').textContent = `About ${timeTaken} milliseconds`;
356
  }
357
  }
 
468
  scrollHeight,
469
  clientHeight
470
  } = document.documentElement;
471
+ if (scrollTop + clientHeight >= scrollHeight - 50 && !loadingMoreIndicator.classList.contains("active")) {
472
  loadingMoreIndicator.classList.add("active");
473
  const resultsToDisplay = cachedSearchResults.splice(0, RESULTS_PER_PAGE);
474
  if (resultsToDisplay.length > 0) {