Skip to content

Commit 263fe82

Browse files
refactor(demo): Move response preview inline with HIT/MISS log
1 parent fceb375 commit 263fe82

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

public/index.html

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,25 +328,26 @@ <h3 class="ui inverted header">
328328
const data = await res.json();
329329
const latency = performance.now() - start;
330330

331-
if (data.source === 'cache') {
332-
state.hits++;
333-
state.totalSaved += 1000;
334-
log('HIT: ' + latency.toFixed(0) + 'ms');
335-
} else {
336-
state.misses++;
337-
log('MISS: ' + latency.toFixed(0) + 'ms');
338-
}
339-
340-
// Show response preview
331+
// Build response preview
332+
let responsePreview = '';
341333
if (data.data) {
342334
try {
343335
const parsed = JSON.parse(data.data);
344-
log('<details style="margin-left:20px;"><summary style="cursor:pointer;color:#666;">📦 Response</summary><pre style="font-size:11px;max-height:150px;overflow:auto;background:#1b1c1d;color:#a9b7c6;padding:8px;border-radius:4px;margin-top:5px;">' + JSON.stringify(parsed, null, 2).substring(0, 800) + '</pre></details>');
336+
responsePreview = ' <details style="display:inline;"><summary style="cursor:pointer;color:#666;display:inline;">📦</summary><pre style="font-size:11px;max-height:150px;overflow:auto;background:#1b1c1d;color:#a9b7c6;padding:8px;border-radius:4px;margin-top:5px;">' + JSON.stringify(parsed, null, 2).substring(0, 800) + '</pre></details>';
345337
} catch {
346-
log('<details style="margin-left:20px;"><summary style="cursor:pointer;color:#666;">📦 Response</summary><pre style="font-size:11px;max-height:150px;overflow:auto;background:#1b1c1d;color:#a9b7c6;padding:8px;border-radius:4px;margin-top:5px;">' + data.data.substring(0, 300) + '</pre></details>');
338+
responsePreview = ' <details style="display:inline;"><summary style="cursor:pointer;color:#666;display:inline;">📦</summary><pre style="font-size:11px;max-height:150px;overflow:auto;background:#1b1c1d;color:#a9b7c6;padding:8px;border-radius:4px;margin-top:5px;">' + data.data.substring(0, 300) + '</pre></details>';
347339
}
348340
}
349341

342+
if (data.source === 'cache') {
343+
state.hits++;
344+
state.totalSaved += 1000;
345+
log('HIT: ' + latency.toFixed(0) + 'ms' + responsePreview);
346+
} else {
347+
state.misses++;
348+
log('MISS: ' + latency.toFixed(0) + 'ms' + responsePreview);
349+
}
350+
350351
updateStats();
351352
if (i < count - 1) await new Promise(r => setTimeout(r, delay));
352353
} catch (e) {

0 commit comments

Comments
 (0)