Update index.html

ignore CSV summary rows in analyzer
improve mobile layout
This commit is contained in:
ai-bot committed 2026-09-25 11:04:02 +00:00
1 parent 653a5e3e79
commit 5bf31efd28
1 file changed
+56 -10
+56 -10
View File
@@ -77,6 +77,7 @@
margin: 20px 0;
border: 1px solid #eee;
border-radius: 8px;
-webkit-overflow-scrolling: touch;
}
table {
width: 100%;
@@ -94,7 +95,6 @@
color: #6d4aff;
font-weight: 600;
}
th:last-child, td:last-child { border-right: none; }
tbody tr:hover { background: #faf9fc; }
.sort-button {
width: 100%;
@@ -125,14 +125,17 @@
}
.sort-button[aria-sort="ascending"] .sort-indicator,
.sort-button[aria-sort="descending"] .sort-indicator { opacity: 1; }
#summaryMetrics {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 14px;
}
.metric-card {
display: inline-block;
background: linear-gradient(135deg, #6d4aff 0%, #8b5cf6 100%);
color: white;
padding: 20px 30px;
padding: 20px 24px;
border-radius: 8px;
margin: 10px;
min-width: 180px;
min-width: 0;
box-shadow: 0 4px 15px rgba(109,74,255,0.3);
}
.metric-value { font-size: 1.8rem; font-weight: bold; margin-bottom: 5px; }
@@ -175,6 +178,33 @@
}
.status-error { background: #f8d7da; color: #721c24; }
.status-success { background: #d4edda; color: #155724; }
@media (max-width: 700px) {
body { padding: 10px; }
header { margin-bottom: 18px; }
header h1 { font-size: 1.55rem; }
header p { font-size: 0.95rem; }
.upload-section, .report-section { padding: 18px; border-radius: 10px; }
.upload-area { padding: 36px 14px; }
.upload-area > div:first-child { font-size: 2.4rem !important; }
button.analyze-btn { width: 100%; padding: 13px 18px; }
h2 { font-size: 1.25rem; margin: 24px 0 14px; }
.table-wrapper { margin: 14px 0; }
table { min-width: 560px; font-size: 0.88rem; }
th, td { padding: 10px 9px; }
.sort-button { gap: 6px; }
.metric-card { padding: 16px 18px; }
.metric-value { font-size: 1.45rem; }
.finding-box, .warning-box, .success-box { padding: 12px 14px; }
.privacy-note { font-size: 0.82rem; padding: 12px; }
}
@media (max-width: 420px) {
#summaryMetrics { grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-card { padding: 13px 12px; }
.metric-value { font-size: 1.2rem; }
.metric-label { font-size: 0.78rem; }
}
</style>
</head>
<body>
@@ -298,12 +328,27 @@
const headers = parseCSVLine(lines[0]);
const data = [];
let errors = 0;
let summaryRowsSkipped = 0;
for (let i = 1; i < lines.length; i++) {
const line = lines[i];
if (line.includes('Total Records') || line.trim() === '') continue;
const line = lines[i].trim();
if (!line) continue;
const values = parseCSVLine(line);
const firstValue = (values[0] || '').trim();
// PPQ exports append summary rows such as:
// Total Records,1057,,,,,,
// Total Input Tokens,100746995,,,,,,
// Total Output Tokens,1469460,,,,,,
// Total Cost (USD),6.02,,,,,,
// Ignore those rows so only request data reaches the report.
if (firstValue.toLowerCase().startsWith('total ')) {
summaryRowsSkipped++;
continue;
}
if (values.every(value => !value.trim())) continue;
if (values.length !== headers.length) {
errors++;
continue;
@@ -320,7 +365,7 @@
data.push(row);
}
log(`Parsed ${data.length} rows${errors ? `, ${errors} rows skipped` : ''}`);
log(`Parsed ${data.length} request rows${errors ? `, ${errors} malformed rows skipped` : ''}${summaryRowsSkipped ? `, ${summaryRowsSkipped} summary rows ignored` : ''}.`);
return data;
}
@@ -377,7 +422,7 @@
csvData = parseCSV(rawData);
if (csvData.length === 0) {
showStatus('Could not read any data from the file.', true);
showStatus('Could not read any request data from the file.', true);
return;
}
@@ -465,7 +510,8 @@
let sortDirection = defaultSort.direction;
function render() {
const sortedRows = sortRows(rows, sortKey, columns.find(c => c.key === sortKey).type, sortDirection);
const activeColumn = columns.find(c => c.key === sortKey) || columns[0];
const sortedRows = sortRows(rows, sortKey, activeColumn.type, sortDirection);
let html = `<div class="table-wrapper"><table id="${tableId}"><thead><tr>`;
columns.forEach(column => {