From 29fc1978d56d6e5b087cf78086796c910119ee78 Mon Sep 17 00:00:00 2001 From: Tiyatrotist <179411334+Tiyatrotist@users.noreply.github.com> Date: Sun, 27 Sep 2026 08:57:07 +0300 Subject: [PATCH] feat: add shareable compare demo link --- assets/profiler-compare.js | 13 +++++++++---- assets/profiler-ui.js | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/assets/profiler-compare.js b/assets/profiler-compare.js index fe3dfd90..bd8c0357 100644 --- a/assets/profiler-compare.js +++ b/assets/profiler-compare.js @@ -707,12 +707,17 @@ } // ── Init ──────────────────────────────────────────────────────────────── - wireSlot('A', dropA, fileA, nameAEl); - wireSlot('B', dropB, fileB, nameBEl); - sampleBtn.addEventListener('click', function () { + function loadSampleComparison() { setSlot('A', E.parseCSV(buildSample('A')), 'sample-baseline.csv', dropA, nameAEl); setSlot('B', E.parseCSV(buildSample('B')), 'sample-current.csv', dropB, nameBEl); - }); + } + + wireSlot('A', dropA, fileA, nameAEl); + wireSlot('B', dropB, fileB, nameBEl); + sampleBtn.addEventListener('click', loadSampleComparison); + if (new URLSearchParams(window.location.search).get('demo') === 'compare') { + loadSampleComparison(); + } downloadHtmlBtn.addEventListener('click', downloadCompareHtmlReport); copyJsonBtn.addEventListener('click', copyCompareResultAsJSON); })(); diff --git a/assets/profiler-ui.js b/assets/profiler-ui.js index d964e6f1..18e63369 100644 --- a/assets/profiler-ui.js +++ b/assets/profiler-ui.js @@ -793,9 +793,11 @@ } } - // Shareable demo link: profiler.html?demo loads the sample automatically. + // Shareable demo link: profiler.html?demo loads the profile sample automatically. + // Reserve ?demo=compare for the two-dataset sample handled by profiler-compare.js. // Placed last so all declarations above (e.g. GRADE_COLOR) are initialized. - if (/(?:\?|&)demo\b/.test(window.location.search)) { + var demoMode = new URLSearchParams(window.location.search).get('demo'); + if (demoMode !== null && demoMode !== 'compare') { runText(buildSampleCSV(), 'sample-health-data.csv'); } })();