pyquantflow / script.js
luluUCD's picture
the header (navibar) and footer are broken, try to fix them for me
e64f1fb verified
Raw History Blame Contribute Delete
8.87 kB
// 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 = `
<td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900">${item.id}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.name}</td>
<td class="px-4 py-3 whitespace-nowrap">
<span class="status-badge status-${item.status === '已完成' ? 'complete' : item.status === '进行中' ? 'in-progress' : 'pending'}">${item.status}</span>
</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.owner}</td>
<td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.deadline}</td>
<td class="px-4 py-3 whitespace-nowrap">
<div class="flex items-center">
<div class="w-full bg-gray-200 rounded-full h-2.5 mr-2">
<div class="progress-fill h-2.5 rounded-full" style="width: ${item.progress}%"></div>
</div>
<span class="text-sm text-gray-700">${item.progress}%</span>
</div>
</td>
`;
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 = `
<td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900">${newId}</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary" placeholder="输入任务名称">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<select class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary">
<option value="待开始">待开始</option>
<option value="进行中">进行中</option>
<option value="已完成">已完成</option>
</select>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary" placeholder="负责人">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="date" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<div class="flex items-center">
<div class="w-full bg-gray-200 rounded-full h-2.5 mr-2">
<div class="progress-fill h-2.5 rounded-full" style="width: 0%"></div>
</div>
<span class="text-sm text-gray-700">0%</span>
</div>
</td>
`;
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 = `
<div class="flex items-center">
<i data-feather="${type === 'success' ? 'check-circle' : type === 'error' ? 'alert-circle' : 'info'}" class="mr-2"></i>
<span>${message}</span>
</div>
`;
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);
});