Spaces:
Sleeping
Sleeping
Update static/js/script.js
Browse files- static/js/script.js +19 -9
static/js/script.js
CHANGED
|
@@ -28,6 +28,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 28 |
const resultsSection = document.querySelector('[data-section="results"]');
|
| 29 |
console.log('Results section rendered:', !!resultsSection);
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
// Handle Translate Form Submission
|
| 32 |
if (translateForm) {
|
| 33 |
translateForm.addEventListener('submit', function (e) {
|
|
@@ -40,12 +47,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 40 |
return;
|
| 41 |
}
|
| 42 |
if (loading1) {
|
|
|
|
| 43 |
loading1.classList.remove('d-none');
|
| 44 |
loading1.style.opacity = '0';
|
| 45 |
loading1.animate([
|
| 46 |
-
{ opacity: 0, transform: 'translateY(
|
| 47 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 48 |
-
], { duration:
|
| 49 |
translateBtn.disabled = true;
|
| 50 |
translateBtn.style.transform = 'scale(0.95)';
|
| 51 |
}
|
|
@@ -65,12 +73,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 65 |
return;
|
| 66 |
}
|
| 67 |
if (loading2) {
|
|
|
|
| 68 |
loading2.classList.remove('d-none');
|
| 69 |
loading2.style.opacity = '0';
|
| 70 |
loading2.animate([
|
| 71 |
-
{ opacity: 0, transform: 'translateY(
|
| 72 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 73 |
-
], { duration:
|
| 74 |
crawlBtn.disabled = true;
|
| 75 |
crawlBtn.style.transform = 'scale(0.95)';
|
| 76 |
}
|
|
@@ -90,12 +99,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 90 |
alert('Please enter a search keyword.');
|
| 91 |
} else {
|
| 92 |
if (loadingSearch) {
|
|
|
|
| 93 |
loadingSearch.classList.remove('d-none');
|
| 94 |
loadingSearch.style.opacity = '0';
|
| 95 |
loadingSearch.animate([
|
| 96 |
-
{ opacity: 0, transform: 'translateY(
|
| 97 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 98 |
-
], { duration:
|
| 99 |
}
|
| 100 |
}
|
| 101 |
});
|
|
@@ -106,7 +116,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 106 |
// Highlight search keywords and debug results
|
| 107 |
const highlightElements = document.querySelectorAll('.search-result');
|
| 108 |
console.log('Found search result elements:', highlightElements.length);
|
| 109 |
-
highlightElements.forEach(function (element) {
|
| 110 |
const keywordInput = element.querySelector('.highlight-text')?.getAttribute('data-keyword');
|
| 111 |
if (keywordInput) {
|
| 112 |
const keywords = keywordInput.toLowerCase().split(/\s+/);
|
|
@@ -119,9 +129,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
| 119 |
console.log('Highlighted keywords:', keywords, 'in element:', element.id);
|
| 120 |
element.style.opacity = '0';
|
| 121 |
element.animate([
|
| 122 |
-
{ opacity: 0, transform: 'translateX(-
|
| 123 |
{ opacity: 1, transform: 'translateX(0)' }
|
| 124 |
-
], { duration: 500, easing: 'ease-out', delay: 100 });
|
| 125 |
} else {
|
| 126 |
console.warn('No keyword found for element:', element.id);
|
| 127 |
}
|
|
|
|
| 28 |
const resultsSection = document.querySelector('[data-section="results"]');
|
| 29 |
console.log('Results section rendered:', !!resultsSection);
|
| 30 |
|
| 31 |
+
// Debug search results section
|
| 32 |
+
const searchResultsSection = document.querySelector('[data-section="search_results"]');
|
| 33 |
+
console.log('Search results section found:', {
|
| 34 |
+
present: !!searchResultsSection,
|
| 35 |
+
resultsCount: searchResultsSection?.getAttribute('data-results-count') || 0
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
// Handle Translate Form Submission
|
| 39 |
if (translateForm) {
|
| 40 |
translateForm.addEventListener('submit', function (e) {
|
|
|
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
if (loading1) {
|
| 50 |
+
console.log('Showing translate spinner');
|
| 51 |
loading1.classList.remove('d-none');
|
| 52 |
loading1.style.opacity = '0';
|
| 53 |
loading1.animate([
|
| 54 |
+
{ opacity: 0, transform: 'translateY(20px)' },
|
| 55 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 56 |
+
], { duration: 500, easing: 'ease-in-out', fill: 'forwards' });
|
| 57 |
translateBtn.disabled = true;
|
| 58 |
translateBtn.style.transform = 'scale(0.95)';
|
| 59 |
}
|
|
|
|
| 73 |
return;
|
| 74 |
}
|
| 75 |
if (loading2) {
|
| 76 |
+
console.log('Showing crawl spinner');
|
| 77 |
loading2.classList.remove('d-none');
|
| 78 |
loading2.style.opacity = '0';
|
| 79 |
loading2.animate([
|
| 80 |
+
{ opacity: 0, transform: 'translateY(20px)' },
|
| 81 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 82 |
+
], { duration: 500, easing: 'ease-in-out', fill: 'forwards' });
|
| 83 |
crawlBtn.disabled = true;
|
| 84 |
crawlBtn.style.transform = 'scale(0.95)';
|
| 85 |
}
|
|
|
|
| 99 |
alert('Please enter a search keyword.');
|
| 100 |
} else {
|
| 101 |
if (loadingSearch) {
|
| 102 |
+
console.log('Showing search spinner');
|
| 103 |
loadingSearch.classList.remove('d-none');
|
| 104 |
loadingSearch.style.opacity = '0';
|
| 105 |
loadingSearch.animate([
|
| 106 |
+
{ opacity: 0, transform: 'translateY(20px)' },
|
| 107 |
{ opacity: 1, transform: 'translateY(0)' }
|
| 108 |
+
], { duration: 500, easing: 'ease-in-out', fill: 'forwards' });
|
| 109 |
}
|
| 110 |
}
|
| 111 |
});
|
|
|
|
| 116 |
// Highlight search keywords and debug results
|
| 117 |
const highlightElements = document.querySelectorAll('.search-result');
|
| 118 |
console.log('Found search result elements:', highlightElements.length);
|
| 119 |
+
highlightElements.forEach(function (element, index) {
|
| 120 |
const keywordInput = element.querySelector('.highlight-text')?.getAttribute('data-keyword');
|
| 121 |
if (keywordInput) {
|
| 122 |
const keywords = keywordInput.toLowerCase().split(/\s+/);
|
|
|
|
| 129 |
console.log('Highlighted keywords:', keywords, 'in element:', element.id);
|
| 130 |
element.style.opacity = '0';
|
| 131 |
element.animate([
|
| 132 |
+
{ opacity: 0, transform: 'translateX(-20px)' },
|
| 133 |
{ opacity: 1, transform: 'translateX(0)' }
|
| 134 |
+
], { duration: 500, easing: 'ease-out', fill: 'forwards', delay: index * 100 });
|
| 135 |
} else {
|
| 136 |
console.warn('No keyword found for element:', element.id);
|
| 137 |
}
|