Sam Cole Claude Opus 4.7 (1M context) commited on
Commit
bfb7ae2
·
1 Parent(s): df8c263

Fix simulator: restore Affected Indicators panel, description, Explain button

Browse files

The May 8 flatten/rewrite of static/index.html dropped three elements from
the Simulator tab — the Affected Indicators panel (#simResults +
#simAffectedCount), the description copy, and the Explain button on
Projected Impact. app_v30.js still referenced #simAffectedCount unguarded,
so runSimulation crashed. A pair of try/catch shims (inline + shim_simulator.js)
were added later to silence the errors instead of fixing the DOM.

Restore the missing markup and drop the inline guards.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. static/index.html +1 -21
static/index.html CHANGED
@@ -30,7 +30,7 @@
30
 
31
  <div id="tab-explorer" class="tab-content max-w-[1920px] mx-auto flex flex-col lg:flex-row"><aside class="w-full lg:w-80 xl:w-96 flex-shrink-0 glass border-r border-slate-800/50 lg:h-[calc(100vh-120px)] lg:overflow-y-auto lg:sticky lg:top-28"><div class="p-4"><div class="flex items-center justify-between mb-3"><h2 class="text-sm font-semibold text-white">Variables</h2><span class="text-[0.65rem] text-slate-500" id="varCount">Loading...</span></div><div class="relative mb-5"><i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"></i><input type="text" id="varSearch" placeholder="Search variables..." class="w-full pl-9 pr-4 py-2.5 rounded-lg bg-slate-800/50 border border-slate-700/50 text-sm text-white placeholder-slate-500 focus:outline-none focus:border-brand-500/50 focus:ring-1 focus:ring-brand-500/20 transition-all" oninput="filterVariables()"></div><div class="mb-2"><div class="text-[0.65rem] text-slate-500 mb-2 uppercase tracking-wider font-medium">Browse by Category</div></div><div id="categoryGrid" class="grid grid-cols-2 gap-2 mb-2"></div><div id="clearCatWrap" class="hidden"><div class="clear-cat" onclick="clearCategoryFilter()">Clear selection</div></div><div id="variableList" class="space-y-1.5 mt-4 hidden"></div></div></aside><main class="flex-1 p-4 sm:p-6 space-y-6 min-w-0"><div id="emptyState" class="flex flex-col items-center justify-center py-20 text-center"><div class="w-20 h-20 rounded-2xl bg-gradient-to-br from-brand-400/20 to-brand-600/20 flex items-center justify-center mb-6"><i data-lucide="mouse-pointer-click" class="w-10 h-10 text-brand-400"></i></div><h2 class="text-2xl font-bold text-white mb-2">Select a Variable to Begin</h2><p class="text-slate-400 max-w-md">Search or browse categories to discover hidden relationships, spot outliers, and get actionable insights.</p></div><div id="resultsArea" class="hidden space-y-6"><div class="glass rounded-2xl p-6 fade-in"><div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4"><div><div class="flex items-center gap-2 mb-2"><span id="heroCategory" class="text-[0.65rem] px-2 py-0.5 rounded-full bg-brand-500/20 text-brand-300 uppercase font-semibold tracking-wider"></span><span id="heroType" class="text-[0.65rem] px-2 py-0.5 rounded-full bg-slate-700/50 text-slate-400 uppercase font-semibold tracking-wider"></span></div><h2 id="heroName" class="text-2xl sm:text-3xl font-bold text-white mb-1"></h2><p id="heroDesc" class="text-sm text-slate-400 max-w-xl"></p></div><div class="flex gap-3"><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroMean" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Mean</div></div><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroStd" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Std Dev</div></div><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroRange" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Range</div></div></div></div></div><div id="narrativePanel" class="narrative-panel rounded-xl p-5 hidden fade-in"><div class="flex items-center gap-2 mb-3"><i data-lucide="message-square-plus" class="w-4 h-4 text-brand-400"></i><span class="text-xs font-semibold text-brand-300 uppercase tracking-wider">Narrative Insight</span></div><p id="narrativeText" class="text-sm text-slate-300 leading-relaxed"></p></div><div class="flex items-center justify-between"><div class="flex items-center gap-2" id="peerToggleContainer" style="display:none"><button onclick="setPeerMode('global')" id="peerGlobal" class="peer-toggle active">Global</button><button onclick="setPeerMode('regional')" id="peerRegional" class="peer-toggle">By Region</button></div></div><div id="riskOpportunityBanner" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div><div id="insightBanners" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div><div class="grid grid-cols-1 xl:grid-cols-2 gap-6"><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="bar-chart-3" class="w-4 h-4 text-brand-400"></i>Distribution</h3><button onclick="openChatbotFor('distribution')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="h-64"><canvas id="distributionChart"></canvas></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="network" class="w-4 h-4 text-brand-400"></i>Network</h3><button onclick="openChatbotFor('network')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="h-64 relative"><canvas id="networkCanvas" class="w-full h-full"></canvas></div></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-5"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="link" class="w-4 h-4 text-brand-400"></i>Correlations</h3><div class="flex gap-2"><button onclick="setCorrFilter('all')" id="filterAll" class="px-3 py-1 rounded-md text-xs bg-brand-500/20 text-brand-300 border border-brand-500/30">All</button><button onclick="setCorrFilter('positive')" id="filterPos" class="px-3 py-1 rounded-md text-xs bg-slate-800/50 text-slate-400 border border-slate-700/50 hover:border-slate-600">Positive</button><button onclick="setCorrFilter('negative')" id="filterNeg" class="px-3 py-1 rounded-md text-xs bg-slate-800/50 text-slate-400 border border-slate-700/50 hover:border-slate-600">Negative</button></div></div><div id="correlationBars" class="space-y-3"></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="scatter-chart" class="w-4 h-4 text-brand-400"></i>Explore</h3><div class="flex items-center gap-2"><select id="scatterVarSelect" onchange="updateScatterPlot()" class="px-3 py-1.5 rounded-lg bg-slate-800/80 border border-slate-700/50 text-sm text-white focus:outline-none focus:border-brand-500/50"></select><button onclick="openChatbotFor('scatter')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div></div><div class="h-80"><canvas id="scatterChart"></canvas></div></div><div class="glass rounded-2xl p-5"><h3 class="text-sm font-semibold text-white mb-4 flex items-center gap-2"><i data-lucide="lightbulb" class="w-4 h-4 text-brand-400"></i>Insights</h3><div id="insightCards" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="grid-3x3" class="w-4 h-4 text-brand-400"></i>Heatmap</h3><button onclick="openChatbotFor('heatmap')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="overflow-x-auto"><canvas id="heatmapCanvas"></canvas></div></div></div></main></div>
32
 
33
- <div id="tab-simulator" class="tab-content hidden max-w-[1920px] mx-auto p-4 sm:p-6"><div class="glass rounded-2xl p-6"><h2 class="text-xl font-bold text-white mb-2 flex items-center gap-2"><i data-lucide="git-branch" class="w-5 h-5 text-brand-400"></i>Scenario Builder</h2><div class="grid grid-cols-1 lg:grid-cols-3 gap-6"><div class="lg:col-span-1 space-y-4"><div class="sim-scenario"><label class="block text-xs font-semibold text-white mb-2">Select Scenario Variable</label><select id="simVariable" onchange="initSimulator()" class="w-full px-3 py-2 rounded-lg bg-slate-800/80 border border-slate-700/50 text-sm text-white focus:outline-none focus:border-brand-500/50"></select></div><div class="sim-scenario"><div class="flex justify-between mb-1"><span class="text-xs text-slate-300" id="simLabel">Value</span><span class="text-xs font-mono text-brand-300" id="simValue">0</span></div><input type="range" id="simSlider" min="-50" max="50" value="0" class="slider-track w-full" oninput="runSimulation(this.value)"></div></div><div class="lg:col-span-2"><div class="glass rounded-2xl p-5"><h3 class="text-sm font-semibold text-white flex items-center gap-2 mb-4"><i data-lucide="arrow-left-right" class="w-4 h-4 text-brand-400"></i>Projected Impact</h3><div class="h-80"><canvas id="simChart"></canvas></div></div></div></div></div></div>
34
 
35
  <div id="tab-discover" class="tab-content hidden max-w-[1920px] mx-auto p-4 sm:p-6"><div class="glass rounded-2xl p-6"><h2 class="text-xl font-bold text-white mb-2 flex items-center gap-2"><i data-lucide="sparkles" class="w-5 h-5 text-brand-400"></i>Unique Insights Discovery</h2><div id="gemList" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"></div></div></div>
36
 
@@ -51,26 +51,6 @@
51
  <script src="/static/dataset_embed.js"></script>
52
  <script src="/static/app_v30.js"></script>
53
  <script>
54
- // Guard simulator functions that crash during init()
55
- (function() {
56
- var _runSim = window.runSimulation;
57
- window.runSimulation = function(val) {
58
- try { return _runSim(val); } catch(e) { console.warn('runSimulation guard:', e.message); }
59
- };
60
- var _initSim = window.initSimulator;
61
- window.initSimulator = function() {
62
- try { return _initSim(); } catch(e) { console.warn('initSimulator guard:', e.message); }
63
- };
64
- var _initSimUI = window.initSimulatorUI;
65
- if (_initSimUI) {
66
- window.initSimulatorUI = function() {
67
- try { return _initSimUI(); } catch(e) { console.warn('initSimulatorUI guard:', e.message); }
68
- };
69
- }
70
- console.log('index: guarded runSimulation/initSimulator/initSimulatorUI');
71
- })();
72
- </script>
73
- <script>
74
  // Run init() first, THEN load globe_patch.js which will override globe functions
75
  lucide.createIcons();
76
  if (typeof init === 'function') init();
 
30
 
31
  <div id="tab-explorer" class="tab-content max-w-[1920px] mx-auto flex flex-col lg:flex-row"><aside class="w-full lg:w-80 xl:w-96 flex-shrink-0 glass border-r border-slate-800/50 lg:h-[calc(100vh-120px)] lg:overflow-y-auto lg:sticky lg:top-28"><div class="p-4"><div class="flex items-center justify-between mb-3"><h2 class="text-sm font-semibold text-white">Variables</h2><span class="text-[0.65rem] text-slate-500" id="varCount">Loading...</span></div><div class="relative mb-5"><i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500 pointer-events-none"></i><input type="text" id="varSearch" placeholder="Search variables..." class="w-full pl-9 pr-4 py-2.5 rounded-lg bg-slate-800/50 border border-slate-700/50 text-sm text-white placeholder-slate-500 focus:outline-none focus:border-brand-500/50 focus:ring-1 focus:ring-brand-500/20 transition-all" oninput="filterVariables()"></div><div class="mb-2"><div class="text-[0.65rem] text-slate-500 mb-2 uppercase tracking-wider font-medium">Browse by Category</div></div><div id="categoryGrid" class="grid grid-cols-2 gap-2 mb-2"></div><div id="clearCatWrap" class="hidden"><div class="clear-cat" onclick="clearCategoryFilter()">Clear selection</div></div><div id="variableList" class="space-y-1.5 mt-4 hidden"></div></div></aside><main class="flex-1 p-4 sm:p-6 space-y-6 min-w-0"><div id="emptyState" class="flex flex-col items-center justify-center py-20 text-center"><div class="w-20 h-20 rounded-2xl bg-gradient-to-br from-brand-400/20 to-brand-600/20 flex items-center justify-center mb-6"><i data-lucide="mouse-pointer-click" class="w-10 h-10 text-brand-400"></i></div><h2 class="text-2xl font-bold text-white mb-2">Select a Variable to Begin</h2><p class="text-slate-400 max-w-md">Search or browse categories to discover hidden relationships, spot outliers, and get actionable insights.</p></div><div id="resultsArea" class="hidden space-y-6"><div class="glass rounded-2xl p-6 fade-in"><div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4"><div><div class="flex items-center gap-2 mb-2"><span id="heroCategory" class="text-[0.65rem] px-2 py-0.5 rounded-full bg-brand-500/20 text-brand-300 uppercase font-semibold tracking-wider"></span><span id="heroType" class="text-[0.65rem] px-2 py-0.5 rounded-full bg-slate-700/50 text-slate-400 uppercase font-semibold tracking-wider"></span></div><h2 id="heroName" class="text-2xl sm:text-3xl font-bold text-white mb-1"></h2><p id="heroDesc" class="text-sm text-slate-400 max-w-xl"></p></div><div class="flex gap-3"><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroMean" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Mean</div></div><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroStd" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Std Dev</div></div><div class="text-center px-4 py-2 rounded-xl glass-light"><div id="heroRange" class="text-xl font-bold stat-value font-mono"></div><div class="text-[0.6rem] text-slate-500 uppercase tracking-wider">Range</div></div></div></div></div><div id="narrativePanel" class="narrative-panel rounded-xl p-5 hidden fade-in"><div class="flex items-center gap-2 mb-3"><i data-lucide="message-square-plus" class="w-4 h-4 text-brand-400"></i><span class="text-xs font-semibold text-brand-300 uppercase tracking-wider">Narrative Insight</span></div><p id="narrativeText" class="text-sm text-slate-300 leading-relaxed"></p></div><div class="flex items-center justify-between"><div class="flex items-center gap-2" id="peerToggleContainer" style="display:none"><button onclick="setPeerMode('global')" id="peerGlobal" class="peer-toggle active">Global</button><button onclick="setPeerMode('regional')" id="peerRegional" class="peer-toggle">By Region</button></div></div><div id="riskOpportunityBanner" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div><div id="insightBanners" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div><div class="grid grid-cols-1 xl:grid-cols-2 gap-6"><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="bar-chart-3" class="w-4 h-4 text-brand-400"></i>Distribution</h3><button onclick="openChatbotFor('distribution')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="h-64"><canvas id="distributionChart"></canvas></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="network" class="w-4 h-4 text-brand-400"></i>Network</h3><button onclick="openChatbotFor('network')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="h-64 relative"><canvas id="networkCanvas" class="w-full h-full"></canvas></div></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-5"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="link" class="w-4 h-4 text-brand-400"></i>Correlations</h3><div class="flex gap-2"><button onclick="setCorrFilter('all')" id="filterAll" class="px-3 py-1 rounded-md text-xs bg-brand-500/20 text-brand-300 border border-brand-500/30">All</button><button onclick="setCorrFilter('positive')" id="filterPos" class="px-3 py-1 rounded-md text-xs bg-slate-800/50 text-slate-400 border border-slate-700/50 hover:border-slate-600">Positive</button><button onclick="setCorrFilter('negative')" id="filterNeg" class="px-3 py-1 rounded-md text-xs bg-slate-800/50 text-slate-400 border border-slate-700/50 hover:border-slate-600">Negative</button></div></div><div id="correlationBars" class="space-y-3"></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="scatter-chart" class="w-4 h-4 text-brand-400"></i>Explore</h3><div class="flex items-center gap-2"><select id="scatterVarSelect" onchange="updateScatterPlot()" class="px-3 py-1.5 rounded-lg bg-slate-800/80 border border-slate-700/50 text-sm text-white focus:outline-none focus:border-brand-500/50"></select><button onclick="openChatbotFor('scatter')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div></div><div class="h-80"><canvas id="scatterChart"></canvas></div></div><div class="glass rounded-2xl p-5"><h3 class="text-sm font-semibold text-white mb-4 flex items-center gap-2"><i data-lucide="lightbulb" class="w-4 h-4 text-brand-400"></i>Insights</h3><div id="insightCards" class="grid grid-cols-1 md:grid-cols-2 gap-4"></div></div><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="grid-3x3" class="w-4 h-4 text-brand-400"></i>Heatmap</h3><button onclick="openChatbotFor('heatmap')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="overflow-x-auto"><canvas id="heatmapCanvas"></canvas></div></div></div></main></div>
32
 
33
+ <div id="tab-simulator" class="tab-content hidden max-w-[1920px] mx-auto p-4 sm:p-6"><div class="glass rounded-2xl p-6"><h2 class="text-xl font-bold text-white mb-2 flex items-center gap-2"><i data-lucide="git-branch" class="w-5 h-5 text-brand-400"></i>Scenario Builder</h2><p class="text-xs text-slate-400 mb-6">Adjust any variable and see projected changes across all correlated indicators.</p><div class="grid grid-cols-1 lg:grid-cols-3 gap-6"><div class="lg:col-span-1 space-y-4"><div class="sim-scenario"><label class="block text-xs font-semibold text-white mb-2">Select Scenario Variable</label><select id="simVariable" onchange="initSimulator()" class="w-full px-3 py-2 rounded-lg bg-slate-800/80 border border-slate-700/50 text-sm text-white focus:outline-none focus:border-brand-500/50"></select></div><div class="sim-scenario"><div class="flex justify-between mb-1"><span class="text-xs text-slate-300" id="simLabel">Value</span><span class="text-xs font-mono text-brand-300" id="simValue">0</span></div><input type="range" id="simSlider" min="-50" max="50" value="0" class="slider-track w-full" oninput="runSimulation(this.value)"><div class="flex justify-between mt-1 text-[0.6rem] text-slate-500"><span>-50%</span><span>0%</span><span>+50%</span></div></div><div class="sim-scenario"><div class="flex justify-between mb-2"><span class="text-xs font-semibold text-white">Affected Indicators</span><span class="text-[0.65rem] text-slate-500" id="simAffectedCount">0</span></div><div id="simResults" class="space-y-2 max-h-64 overflow-y-auto"></div></div></div><div class="lg:col-span-2"><div class="glass rounded-2xl p-5"><div class="flex items-center justify-between mb-4"><h3 class="text-sm font-semibold text-white flex items-center gap-2"><i data-lucide="arrow-left-right" class="w-4 h-4 text-brand-400"></i>Projected Impact</h3><button onclick="openChatbotFor('simulator')" class="explain-chart-btn px-2 py-1 rounded-md glass-light text-[0.65rem] text-slate-400 hover:text-brand-300 hover:border-brand-500/20 border border-transparent transition-all flex items-center gap-1"><i data-lucide="message-circle" class="w-3 h-3"></i>Explain</button></div><div class="h-80"><canvas id="simChart"></canvas></div></div></div></div></div></div>
34
 
35
  <div id="tab-discover" class="tab-content hidden max-w-[1920px] mx-auto p-4 sm:p-6"><div class="glass rounded-2xl p-6"><h2 class="text-xl font-bold text-white mb-2 flex items-center gap-2"><i data-lucide="sparkles" class="w-5 h-5 text-brand-400"></i>Unique Insights Discovery</h2><div id="gemList" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"></div></div></div>
36
 
 
51
  <script src="/static/dataset_embed.js"></script>
52
  <script src="/static/app_v30.js"></script>
53
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  // Run init() first, THEN load globe_patch.js which will override globe functions
55
  lucide.createIcons();
56
  if (typeof init === 'function') init();