加载默认日志按钮
Browse files- index.html +1 -1
- script.js +59 -32
index.html
CHANGED
|
@@ -119,7 +119,7 @@
|
|
| 119 |
<i data-feather="download" class="mr-2"></i> Export
|
| 120 |
</button>
|
| 121 |
<button id="sampleButton" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-md flex items-center">
|
| 122 |
-
<i data-feather="
|
| 123 |
</button>
|
| 124 |
</div>
|
| 125 |
|
|
|
|
| 119 |
<i data-feather="download" class="mr-2"></i> Export
|
| 120 |
</button>
|
| 121 |
<button id="sampleButton" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-md flex items-center">
|
| 122 |
+
<i data-feather="download" class="mr-2"></i> Load Sample Log
|
| 123 |
</button>
|
| 124 |
</div>
|
| 125 |
|
script.js
CHANGED
|
@@ -441,42 +441,69 @@ function exportAnnotations() {
|
|
| 441 |
link.click();
|
| 442 |
document.body.removeChild(link);
|
| 443 |
}
|
| 444 |
-
function generateSampleLog() {
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
}
|
| 457 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
}
|
| 459 |
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
}
|
| 465 |
-
|
| 466 |
-
// Update UI
|
| 467 |
-
updateLogInfo();
|
| 468 |
-
renderHeatmap();
|
| 469 |
-
updateTimeline();
|
| 470 |
-
currentFrameIndex = 0;
|
| 471 |
-
updateFrameDisplay();
|
| 472 |
-
|
| 473 |
-
// Create some sample annotations
|
| 474 |
-
annotations = [
|
| 475 |
-
{ id: 1, timestamp: 0.5, text: "Initialization complete", frameIndex: 5 },
|
| 476 |
-
{ id: 2, timestamp: 3.2, text: "First peak detected", frameIndex: 32 },
|
| 477 |
-
{ id: 3, timestamp: 7.8, text: "System warning", frameIndex: 78 }
|
| 478 |
-
];
|
| 479 |
-
updateAnnotationsDisplay();
|
| 480 |
}
|
| 481 |
function updateAnnotationsDisplay() {
|
| 482 |
const annotationPanel = document.querySelector('custom-annotation-panel');
|
|
|
|
| 441 |
link.click();
|
| 442 |
document.body.removeChild(link);
|
| 443 |
}
|
| 444 |
+
async function generateSampleLog() {
|
| 445 |
+
try {
|
| 446 |
+
// Show loading state
|
| 447 |
+
const sampleBtn = document.getElementById('sampleButton');
|
| 448 |
+
const originalText = sampleBtn.innerHTML;
|
| 449 |
+
sampleBtn.innerHTML = '<i data-feather="loader" class="animate-spin mr-2"></i> Loading Sample...';
|
| 450 |
+
feather.replace();
|
| 451 |
+
|
| 452 |
+
// Fetch sample log data from public API
|
| 453 |
+
const response = await fetch('https://raw.githubusercontent.com/loglens/sample-logs/main/frame_analysis_sample.log');
|
| 454 |
+
const content = await response.text();
|
| 455 |
+
|
| 456 |
+
// Process the sample log
|
| 457 |
+
processLogContent(content);
|
| 458 |
+
|
| 459 |
+
// Create some sample annotations
|
| 460 |
+
annotations = [
|
| 461 |
+
{ id: 1, timestamp: 0.5, text: "Initialization complete", frameIndex: 5 },
|
| 462 |
+
{ id: 2, timestamp: 3.2, text: "First peak detected", frameIndex: 32 },
|
| 463 |
+
{ id: 3, timestamp: 7.8, text: "System warning", frameIndex: 78 }
|
| 464 |
+
];
|
| 465 |
+
updateAnnotationsDisplay();
|
| 466 |
+
|
| 467 |
+
// Update file name display
|
| 468 |
+
document.getElementById('fileName').textContent = 'sample_frame_analysis.log';
|
| 469 |
+
|
| 470 |
+
} catch (error) {
|
| 471 |
+
console.error('Error loading sample log:', error);
|
| 472 |
+
alert('Failed to load sample log. Using generated data instead.');
|
| 473 |
+
|
| 474 |
+
// Fallback to generated data
|
| 475 |
+
const frames = 100;
|
| 476 |
+
const rows = 40;
|
| 477 |
+
const cols = 70;
|
| 478 |
+
logData = [];
|
| 479 |
+
|
| 480 |
+
for (let i = 0; i < frames; i++) {
|
| 481 |
+
const matrix = [];
|
| 482 |
+
for (let r = 0; r < rows; r++) {
|
| 483 |
+
const row = [];
|
| 484 |
+
for (let c = 0; c < cols; c++) {
|
| 485 |
+
row.push(Math.random() * 100);
|
| 486 |
+
}
|
| 487 |
+
matrix.push(row);
|
| 488 |
}
|
| 489 |
+
|
| 490 |
+
logData.push({
|
| 491 |
+
timestamp: i * 0.1,
|
| 492 |
+
matrix: matrix
|
| 493 |
+
});
|
| 494 |
}
|
| 495 |
|
| 496 |
+
updateLogInfo();
|
| 497 |
+
renderHeatmap();
|
| 498 |
+
updateTimeline();
|
| 499 |
+
currentFrameIndex = 0;
|
| 500 |
+
updateFrameDisplay();
|
| 501 |
+
} finally {
|
| 502 |
+
// Restore button state
|
| 503 |
+
const sampleBtn = document.getElementById('sampleButton');
|
| 504 |
+
sampleBtn.innerHTML = '<i data-feather="download" class="mr-2"></i> Load Sample Log';
|
| 505 |
+
feather.replace();
|
| 506 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
}
|
| 508 |
function updateAnnotationsDisplay() {
|
| 509 |
const annotationPanel = document.querySelector('custom-annotation-panel');
|