document.addEventListener("DOMContentLoaded", function () { // Initialize Material components mdc.autoInit(); // Initialize text field const textField = new mdc.textField.MDCTextField( document.querySelector(".mdc-text-field") ); // Initialize circular progress const circularProgress = new mdc.circularProgress.MDCCircularProgress( document.querySelector(".mdc-circular-progress") ); function formatTimestamp(timestamp) { if (!timestamp || typeof timestamp !== 'string' || timestamp.length < 15) { return 'Invalid Date'; } try { const date = new Date( timestamp.slice(0, 4), timestamp.slice(4, 6) - 1, timestamp.slice(6, 8), timestamp.slice(9, 11), timestamp.slice(11, 13), timestamp.slice(13, 15) ); return date.toLocaleString(); } catch (error) { console.error('Error formatting timestamp:', error); return 'Invalid Date'; } } // Update timestamp display function updateTimestamps() { document.querySelectorAll('.screenshot-timestamp').forEach(function(element) { const timestamp = element.dataset.timestamp; if (timestamp) { element.textContent = formatTimestamp(timestamp); } }); } // Call updateTimestamps when the DOM is loaded updateTimestamps(); // Search functionality const searchField = new mdc.textField.MDCTextField(document.getElementById('search-field')); const tagFilterSelect = new mdc.select.MDCSelect(document.getElementById('tag-filter-select')); const searchButton = document.querySelector(".mdc-text-field__icon--trailing"); const searchInput = document.getElementById("search-input"); if (searchButton && searchInput) { searchButton.addEventListener("click", performSearch); searchInput.addEventListener("keypress", function (e) { if (e.key === "Enter") { e.preventDefault(); performSearch(); } }); } else { console.warn('Search elements not found'); } function performSearch() { const query = document.getElementById('search-input').value; circularProgress.determinate = false; circularProgress.open(); $.post('/search', {query: query}, function(data) { let resultsHtml = '
${getStatusText(screenshot.ocr_status)}
${data.status}