Spaces:
Paused
Paused
Update static/index.html
Browse files- static/index.html +102 -12
static/index.html
CHANGED
|
@@ -25,10 +25,11 @@
|
|
| 25 |
color: #f6ae2d;
|
| 26 |
text-decoration: underline;
|
| 27 |
}
|
| 28 |
-
.markdown-content h1, .markdown-content h2, .markdown-content h3 {
|
| 29 |
color: #f6ae2d;
|
| 30 |
margin-top: 1rem;
|
| 31 |
margin-bottom: 0.5rem;
|
|
|
|
| 32 |
}
|
| 33 |
.markdown-content p {
|
| 34 |
margin-bottom: 1rem;
|
|
@@ -37,6 +38,9 @@
|
|
| 37 |
margin-left: 1.5rem;
|
| 38 |
margin-bottom: 1rem;
|
| 39 |
}
|
|
|
|
|
|
|
|
|
|
| 40 |
.markdown-content code {
|
| 41 |
background-color: rgba(246, 174, 45, 0.2);
|
| 42 |
padding: 0.2rem 0.4rem;
|
|
@@ -56,6 +60,17 @@
|
|
| 56 |
color: #777;
|
| 57 |
margin-bottom: 1rem;
|
| 58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
</style>
|
| 60 |
</head>
|
| 61 |
<body class="bg-gray-100 dark:bg-dark min-h-screen transition-colors duration-300">
|
|
@@ -86,7 +101,7 @@
|
|
| 86 |
>
|
| 87 |
<button
|
| 88 |
id="analyze-btn"
|
| 89 |
-
class="px-6 py-3 bg-primary hover:bg-yellow-500 text-secondary font-semibold rounded-lg transition-colors duration-300 flex items-center justify-center gap-2"
|
| 90 |
>
|
| 91 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
| 92 |
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
|
|
@@ -97,22 +112,42 @@
|
|
| 97 |
<div id="error-message" class="mt-2 text-red-500 hidden"></div>
|
| 98 |
</div>
|
| 99 |
|
| 100 |
-
<div id="loading" class="hidden
|
| 101 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</div>
|
| 103 |
|
| 104 |
<div id="result-container" class="hidden bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 transition-colors duration-300">
|
| 105 |
<h2 class="text-2xl font-semibold text-secondary dark:text-primary mb-4">Analysis Result</h2>
|
| 106 |
<div id="result" class="markdown-content text-gray-700 dark:text-gray-300"></div>
|
| 107 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
</main>
|
| 109 |
|
| 110 |
<footer class="mt-12 text-center text-gray-500 dark:text-gray-400">
|
| 111 |
-
<p>©
|
| 112 |
</footer>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
// Theme toggle
|
| 117 |
const themeToggle = document.getElementById('theme-toggle');
|
| 118 |
const themeIconDark = document.getElementById('theme-icon-dark');
|
|
@@ -149,6 +184,7 @@
|
|
| 149 |
const resultDiv = document.getElementById('result');
|
| 150 |
const loadingDiv = document.getElementById('loading');
|
| 151 |
const errorMessage = document.getElementById('error-message');
|
|
|
|
| 152 |
|
| 153 |
analyzeBtn.addEventListener('click', async () => {
|
| 154 |
const url = inputUrl.value.trim();
|
|
@@ -164,8 +200,7 @@
|
|
| 164 |
}
|
| 165 |
|
| 166 |
clearError();
|
| 167 |
-
|
| 168 |
-
resultContainer.classList.add('hidden');
|
| 169 |
|
| 170 |
try {
|
| 171 |
const response = await fetch(window.location.origin + '/analyze', {
|
|
@@ -177,20 +212,63 @@
|
|
| 177 |
});
|
| 178 |
|
| 179 |
if (!response.ok) {
|
| 180 |
-
throw new Error(Server returned ${response.status});
|
| 181 |
}
|
| 182 |
|
| 183 |
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
resultDiv.innerHTML = marked.parse(data.result);
|
| 185 |
resultContainer.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
} catch (error) {
|
| 187 |
showError('Failed to analyze URL. Please try again later.');
|
| 188 |
console.error('Error:', error);
|
| 189 |
-
|
| 190 |
-
loadingDiv.classList.add('hidden');
|
| 191 |
}
|
| 192 |
});
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
function isValidUrl(string) {
|
| 195 |
try {
|
| 196 |
new URL(string);
|
|
@@ -212,10 +290,22 @@
|
|
| 212 |
|
| 213 |
// Allow pressing Enter in the input field
|
| 214 |
inputUrl.addEventListener('keypress', (e) => {
|
| 215 |
-
if (e.key === 'Enter') {
|
| 216 |
analyzeBtn.click();
|
| 217 |
}
|
| 218 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
</script>
|
| 220 |
</body>
|
| 221 |
-
</html>
|
|
|
|
| 25 |
color: #f6ae2d;
|
| 26 |
text-decoration: underline;
|
| 27 |
}
|
| 28 |
+
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4 {
|
| 29 |
color: #f6ae2d;
|
| 30 |
margin-top: 1rem;
|
| 31 |
margin-bottom: 0.5rem;
|
| 32 |
+
font-weight: bold;
|
| 33 |
}
|
| 34 |
.markdown-content p {
|
| 35 |
margin-bottom: 1rem;
|
|
|
|
| 38 |
margin-left: 1.5rem;
|
| 39 |
margin-bottom: 1rem;
|
| 40 |
}
|
| 41 |
+
.markdown-content li {
|
| 42 |
+
margin-bottom: 0.5rem;
|
| 43 |
+
}
|
| 44 |
.markdown-content code {
|
| 45 |
background-color: rgba(246, 174, 45, 0.2);
|
| 46 |
padding: 0.2rem 0.4rem;
|
|
|
|
| 60 |
color: #777;
|
| 61 |
margin-bottom: 1rem;
|
| 62 |
}
|
| 63 |
+
.markdown-content strong {
|
| 64 |
+
font-weight: bold;
|
| 65 |
+
color: #f6ae2d;
|
| 66 |
+
}
|
| 67 |
+
@keyframes pulse {
|
| 68 |
+
0%, 100% { opacity: 1; }
|
| 69 |
+
50% { opacity: 0.5; }
|
| 70 |
+
}
|
| 71 |
+
.loading-message {
|
| 72 |
+
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
| 73 |
+
}
|
| 74 |
</style>
|
| 75 |
</head>
|
| 76 |
<body class="bg-gray-100 dark:bg-dark min-h-screen transition-colors duration-300">
|
|
|
|
| 101 |
>
|
| 102 |
<button
|
| 103 |
id="analyze-btn"
|
| 104 |
+
class="px-6 py-3 bg-primary hover:bg-yellow-500 text-secondary font-semibold rounded-lg transition-colors duration-300 flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
| 105 |
>
|
| 106 |
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
| 107 |
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
|
|
|
|
| 112 |
<div id="error-message" class="mt-2 text-red-500 hidden"></div>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
+
<div id="loading" class="hidden">
|
| 116 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-8 text-center">
|
| 117 |
+
<div class="flex justify-center items-center mb-4">
|
| 118 |
+
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-primary"></div>
|
| 119 |
+
</div>
|
| 120 |
+
<p class="text-gray-600 dark:text-gray-300 loading-message">Analyzing content...</p>
|
| 121 |
+
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2">This may take a few minutes as we perform a comprehensive analysis</p>
|
| 122 |
+
<div id="progress-timer" class="text-xs text-gray-400 dark:text-gray-500 mt-4">Time elapsed: 0:00</div>
|
| 123 |
+
</div>
|
| 124 |
</div>
|
| 125 |
|
| 126 |
<div id="result-container" class="hidden bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 transition-colors duration-300">
|
| 127 |
<h2 class="text-2xl font-semibold text-secondary dark:text-primary mb-4">Analysis Result</h2>
|
| 128 |
<div id="result" class="markdown-content text-gray-700 dark:text-gray-300"></div>
|
| 129 |
</div>
|
| 130 |
+
|
| 131 |
+
<div id="info-box" class="mt-8 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4">
|
| 132 |
+
<h3 class="text-lg font-semibold text-blue-700 dark:text-blue-300 mb-2">How it works</h3>
|
| 133 |
+
<p class="text-blue-600 dark:text-blue-400 text-sm">
|
| 134 |
+
TrueEye analyzes news articles and web content to detect bias, identify target audiences,
|
| 135 |
+
and reveal hidden agendas. Simply paste a URL and let our AI-powered system provide you
|
| 136 |
+
with a comprehensive media literacy report.
|
| 137 |
+
</p>
|
| 138 |
+
</div>
|
| 139 |
</main>
|
| 140 |
|
| 141 |
<footer class="mt-12 text-center text-gray-500 dark:text-gray-400">
|
| 142 |
+
<p>© 2025 TrueEye. All rights reserved.</p>
|
| 143 |
</footer>
|
| 144 |
</div>
|
| 145 |
|
| 146 |
<script>
|
| 147 |
+
// Global variables
|
| 148 |
+
let analysisStartTime = null;
|
| 149 |
+
let timerInterval = null;
|
| 150 |
+
|
| 151 |
// Theme toggle
|
| 152 |
const themeToggle = document.getElementById('theme-toggle');
|
| 153 |
const themeIconDark = document.getElementById('theme-icon-dark');
|
|
|
|
| 184 |
const resultDiv = document.getElementById('result');
|
| 185 |
const loadingDiv = document.getElementById('loading');
|
| 186 |
const errorMessage = document.getElementById('error-message');
|
| 187 |
+
const progressTimer = document.getElementById('progress-timer');
|
| 188 |
|
| 189 |
analyzeBtn.addEventListener('click', async () => {
|
| 190 |
const url = inputUrl.value.trim();
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
clearError();
|
| 203 |
+
startAnalysis();
|
|
|
|
| 204 |
|
| 205 |
try {
|
| 206 |
const response = await fetch(window.location.origin + '/analyze', {
|
|
|
|
| 212 |
});
|
| 213 |
|
| 214 |
if (!response.ok) {
|
| 215 |
+
throw new Error(`Server returned ${response.status}`);
|
| 216 |
}
|
| 217 |
|
| 218 |
const data = await response.json();
|
| 219 |
+
|
| 220 |
+
if (!data.success && data.error) {
|
| 221 |
+
// Handle specific error types
|
| 222 |
+
if (data.error === 'timeout') {
|
| 223 |
+
showError('The analysis took too long. Please try again with a simpler article or try again later.');
|
| 224 |
+
} else if (data.error === 'connection') {
|
| 225 |
+
showError('Could not connect to the analysis service. Please check your connection and try again.');
|
| 226 |
+
} else {
|
| 227 |
+
showError(data.result || 'An error occurred during analysis.');
|
| 228 |
+
}
|
| 229 |
+
stopAnalysis();
|
| 230 |
+
return;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
// Show results
|
| 234 |
resultDiv.innerHTML = marked.parse(data.result);
|
| 235 |
resultContainer.classList.remove('hidden');
|
| 236 |
+
stopAnalysis();
|
| 237 |
+
|
| 238 |
+
// Scroll to results
|
| 239 |
+
resultContainer.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 240 |
+
|
| 241 |
} catch (error) {
|
| 242 |
showError('Failed to analyze URL. Please try again later.');
|
| 243 |
console.error('Error:', error);
|
| 244 |
+
stopAnalysis();
|
|
|
|
| 245 |
}
|
| 246 |
});
|
| 247 |
|
| 248 |
+
function startAnalysis() {
|
| 249 |
+
loadingDiv.classList.remove('hidden');
|
| 250 |
+
resultContainer.classList.add('hidden');
|
| 251 |
+
analyzeBtn.disabled = true;
|
| 252 |
+
analysisStartTime = Date.now();
|
| 253 |
+
|
| 254 |
+
// Update timer every second
|
| 255 |
+
timerInterval = setInterval(() => {
|
| 256 |
+
const elapsed = Date.now() - analysisStartTime;
|
| 257 |
+
const minutes = Math.floor(elapsed / 60000);
|
| 258 |
+
const seconds = Math.floor((elapsed % 60000) / 1000);
|
| 259 |
+
progressTimer.textContent = `Time elapsed: ${minutes}:${seconds.toString().padStart(2, '0')}`;
|
| 260 |
+
}, 1000);
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
function stopAnalysis() {
|
| 264 |
+
loadingDiv.classList.add('hidden');
|
| 265 |
+
analyzeBtn.disabled = false;
|
| 266 |
+
if (timerInterval) {
|
| 267 |
+
clearInterval(timerInterval);
|
| 268 |
+
timerInterval = null;
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
function isValidUrl(string) {
|
| 273 |
try {
|
| 274 |
new URL(string);
|
|
|
|
| 290 |
|
| 291 |
// Allow pressing Enter in the input field
|
| 292 |
inputUrl.addEventListener('keypress', (e) => {
|
| 293 |
+
if (e.key === 'Enter' && !analyzeBtn.disabled) {
|
| 294 |
analyzeBtn.click();
|
| 295 |
}
|
| 296 |
});
|
| 297 |
+
|
| 298 |
+
// Example URLs for testing
|
| 299 |
+
const exampleUrls = [
|
| 300 |
+
'https://example.com/news-article',
|
| 301 |
+
'https://bbc.com/news/article-123',
|
| 302 |
+
'https://cnn.com/2025/01/article'
|
| 303 |
+
];
|
| 304 |
+
|
| 305 |
+
// Add example URL on double-click (for testing)
|
| 306 |
+
inputUrl.addEventListener('dblclick', () => {
|
| 307 |
+
inputUrl.value = exampleUrls[Math.floor(Math.random() * exampleUrls.length)];
|
| 308 |
+
});
|
| 309 |
</script>
|
| 310 |
</body>
|
| 311 |
+
</html>
|