// PyQuantFlow - Main JavaScript document.addEventListener('DOMContentLoaded', function() { // Initialize Feather Icons if (typeof feather !== 'undefined') { feather.replace(); } // Sample data for tracker table const trackerData = [ { id: 1, name: "SDK核心架构设计", status: "已完成", owner: "张明", deadline: "2024-01-15", progress: 100 }, { id: 2, name: "量化算法集成", status: "进行中", owner: "李华", deadline: "2024-02-28", progress: 75 }, { id: 3, name: "多平台兼容测试", status: "进行中", owner: "王伟", deadline: "2024-03-15", progress: 60 }, { id: 4, name: "用户界面开发", status: "待开始", owner: "刘芳", deadline: "2024-04-10", progress: 0 }, { id: 5, name: "性能优化测试", status: "进行中", owner: "陈强", deadline: "2024-03-01", progress: 40 }, { id: 6, name: "文档编写", status: "已完成", owner: "赵敏", deadline: "2024-01-31", progress: 100 }, { id: 7, name: "安全审计", status: "待开始", owner: "孙浩", deadline: "2024-04-20", progress: 0 }, { id: 8, name: "发布准备", status: "待开始", owner: "周婷", deadline: "2024-05-01", progress: 0 } ]; // Populate tracker table const trackerTable = document.getElementById('trackerTable'); if (trackerTable) { trackerData.forEach(item => { const row = document.createElement('tr'); row.className = 'table-row-hover hover:bg-red-50/30'; row.innerHTML = ` ${item.id} ${item.name} ${item.status} ${item.owner} ${item.deadline}
${item.progress}%
`; trackerTable.appendChild(row); }); } // Add new row functionality const addRowBtn = document.getElementById('addRowBtn'); if (addRowBtn && trackerTable) { addRowBtn.addEventListener('click', function() { const newId = trackerData.length + 1; const newRow = document.createElement('tr'); newRow.className = 'table-row-hover hover:bg-red-50/30 fade-in'; newRow.innerHTML = ` ${newId}
0%
`; trackerTable.appendChild(newRow); // Re-initialize icons in the new row if (typeof feather !== 'undefined') { feather.replace(); } // Show success message showNotification('成功添加新记录行!', 'success'); }); } // Notification System function showNotification(message, type = 'info') { const notification = document.createElement('div'); notification.className = `fixed top-4 right-4 z-50 p-4 rounded-lg shadow-hard transform transition-transform duration-300 translate-x-0 ${ type === 'success' ? 'bg-green-500 text-white' : type === 'error' ? 'bg-red-500 text-white' : 'bg-blue-500 text-white' }`; notification.innerHTML = `
${message}
`; document.body.appendChild(notification); // Update icons if (typeof feather !== 'undefined') { feather.replace({ selector: 'i' }); } // Auto remove after 3 seconds setTimeout(() => { notification.style.transform = 'translateX(100%)'; setTimeout(() => { if (notification.parentNode) { notification.parentNode.removeChild(notification); } }, 300); }, 3000); } // Update progress bars on page load function initializeProgressBars() { document.querySelectorAll('.progress-fill').forEach(bar => { const currentWidth = bar.style.width; bar.style.width = '0%'; setTimeout(() => { bar.style.width = currentWidth; }, 100); }); } // Initialize everything initializeProgressBars(); // Add keyboard shortcuts document.addEventListener('keydown', function(e) { // Ctrl/Cmd + N to add new row if ((e.ctrlKey || e.metaKey) && e.key === 'n') { e.preventDefault(); if (addRowBtn) addRowBtn.click(); } // Escape to clear notifications if (e.key === 'Escape') { document.querySelectorAll('.fixed.top-4.right-4').forEach(notification => { notification.remove(); }); } }); // Make table rows clickable for details if (trackerTable) { trackerTable.addEventListener('click', function(e) { const row = e.target.closest('tr'); if (row && !e.target.closest('input') && !e.target.closest('select')) { const taskId = row.cells[0].textContent; const taskName = row.cells[1].textContent; showNotification(`查看任务详情: ${taskName} (ID: ${taskId})`, 'info'); } }); } // Simulate real-time updates setInterval(() => { const stats = document.querySelectorAll('.text-3xl.font-bold'); if (stats.length > 0) { const randomIncrement = Math.floor(Math.random() * 3); const currentValue = parseInt(stats[1].textContent); stats[1].textContent = currentValue + randomIncrement; // Update random progress const randomRow = Math.floor(Math.random() * trackerData.length); const progressBars = document.querySelectorAll('.progress-fill'); if (progressBars.length > randomRow) { const newProgress = Math.min(progressBars[randomRow].style.width ? parseInt(progressBars[randomRow].style.width) + 5 : 5; progressBars[randomRow].style.width = `${newProgress}%`; progressBars[randomRow].nextElementSibling.textContent = `${newProgress}%`; } } }, 10000); });