Are you finished? Check for errors and malfunctions
Browse files- index.html +34 -10
index.html
CHANGED
|
@@ -300,9 +300,16 @@
|
|
| 300 |
<p class="text-red-500">Error: Could not fetch transcript. Please try again.</p>
|
| 301 |
`;
|
| 302 |
});
|
| 303 |
-
document.getElementById('transcript-content').innerHTML =
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
// Copy functionality
|
| 308 |
document.getElementById('copy-btn').addEventListener('click', () => {
|
|
@@ -333,14 +340,18 @@ document.getElementById('transcript-content').innerHTML = sampleTranscript;
|
|
| 333 |
document.body.removeChild(a);
|
| 334 |
URL.revokeObjectURL(url);
|
| 335 |
});
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
darkModeToggle.innerHTML = '<i data-feather="moon" class="w-5 h-5"></i>';
|
| 341 |
-
document.body.appendChild(darkModeToggle);
|
| 342 |
|
| 343 |
-
darkModeToggle.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
document.documentElement.classList.toggle('dark');
|
| 345 |
const icon = darkModeToggle.querySelector('i');
|
| 346 |
if (document.documentElement.classList.contains('dark')) {
|
|
@@ -350,6 +361,19 @@ document.getElementById('transcript-content').innerHTML = sampleTranscript;
|
|
| 350 |
}
|
| 351 |
feather.replace();
|
| 352 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
feather.replace();
|
| 354 |
</script>
|
| 355 |
</body>
|
|
|
|
| 300 |
<p class="text-red-500">Error: Could not fetch transcript. Please try again.</p>
|
| 301 |
`;
|
| 302 |
});
|
| 303 |
+
document.getElementById('transcript-content').innerHTML = fullTranscript;
|
| 304 |
+
document.getElementById('word-count').textContent = fullTranscript.split(/\s+/).length;
|
| 305 |
+
})
|
| 306 |
+
.catch(error => {
|
| 307 |
+
console.error('Error fetching video info:', error);
|
| 308 |
+
document.getElementById('status-container').classList.add('hidden');
|
| 309 |
+
document.getElementById('empty-state').classList.remove('hidden');
|
| 310 |
+
alert('Error processing video. Please try again.');
|
| 311 |
+
});
|
| 312 |
+
});
|
| 313 |
|
| 314 |
// Copy functionality
|
| 315 |
document.getElementById('copy-btn').addEventListener('click', () => {
|
|
|
|
| 340 |
document.body.removeChild(a);
|
| 341 |
URL.revokeObjectURL(url);
|
| 342 |
});
|
| 343 |
+
// Dark mode detection and toggle
|
| 344 |
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
| 345 |
+
document.documentElement.classList.add('dark');
|
| 346 |
+
}
|
|
|
|
|
|
|
| 347 |
|
| 348 |
+
const darkModeToggle = document.createElement('button');
|
| 349 |
+
darkModeToggle.className = 'fixed top-4 right-4 bg-gray-200 dark:bg-gray-700 p-2 rounded-full z-50';
|
| 350 |
+
darkModeToggle.innerHTML = document.documentElement.classList.contains('dark')
|
| 351 |
+
? '<i data-feather="sun" class="w-5 h-5"></i>'
|
| 352 |
+
: '<i data-feather="moon" class="w-5 h-5"></i>';
|
| 353 |
+
document.body.insertBefore(darkModeToggle, document.body.firstChild);
|
| 354 |
+
darkModeToggle.addEventListener('click', () => {
|
| 355 |
document.documentElement.classList.toggle('dark');
|
| 356 |
const icon = darkModeToggle.querySelector('i');
|
| 357 |
if (document.documentElement.classList.contains('dark')) {
|
|
|
|
| 361 |
}
|
| 362 |
feather.replace();
|
| 363 |
});
|
| 364 |
+
// Error handling for API calls
|
| 365 |
+
window.addEventListener('error', function(e) {
|
| 366 |
+
console.error('Script error:', e.message, 'in', e.filename, 'line', e.lineno);
|
| 367 |
+
document.getElementById('status-container').classList.add('hidden');
|
| 368 |
+
const errorDiv = document.createElement('div');
|
| 369 |
+
errorDiv.className = 'bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4';
|
| 370 |
+
errorDiv.innerHTML = `
|
| 371 |
+
<strong class="font-bold">Error!</strong>
|
| 372 |
+
<span class="block sm:inline">Something went wrong. Please refresh the page and try again.</span>
|
| 373 |
+
`;
|
| 374 |
+
document.querySelector('.container').prepend(errorDiv);
|
| 375 |
+
});
|
| 376 |
+
|
| 377 |
feather.replace();
|
| 378 |
</script>
|
| 379 |
</body>
|