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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>MarketAPI2 — Endpoint Console</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root{
|
| 9 |
+
--bg:#ffffff; --bg-2:#f7f8fa; --bg-3:#eef0f4;
|
| 10 |
+
--line: #e4e7ee;
|
| 11 |
+
--text:#1a1d24; --muted:#6b7280;
|
| 12 |
+
--accent:#0d9488; --accent-dim: rgba(13,148,136,0.10); --accent-text:#ffffff;
|
| 13 |
+
--danger:#dc2626; --danger-dim: rgba(220,38,38,0.08);
|
| 14 |
+
--paper-alt:#f6f8fb;
|
| 15 |
+
--mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
| 16 |
+
--sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 17 |
+
}
|
| 18 |
+
* { margin:0; padding:0; box-sizing:border-box; }
|
| 19 |
+
html,body{ height:100%; }
|
| 20 |
+
body{
|
| 21 |
+
font-family: var(--sans);
|
| 22 |
+
background: var(--bg);
|
| 23 |
+
color: var(--text);
|
| 24 |
+
display:flex; flex-direction:column;
|
| 25 |
+
min-height:100vh;
|
| 26 |
+
}
|
| 27 |
+
::selection{ background: var(--accent-dim); }
|
| 28 |
+
|
| 29 |
+
header.chrome{
|
| 30 |
+
background: var(--bg);
|
| 31 |
+
border-bottom: 1px solid var(--line);
|
| 32 |
+
padding: 10px 18px;
|
| 33 |
+
flex-shrink:0;
|
| 34 |
+
}
|
| 35 |
+
.chrome-row{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
|
| 36 |
+
.brand{
|
| 37 |
+
display:flex; align-items:center; gap:8px;
|
| 38 |
+
font-family: var(--mono); font-size: 0.82em; letter-spacing:0.03em;
|
| 39 |
+
color: var(--accent); font-weight:700; white-space:nowrap;
|
| 40 |
+
}
|
| 41 |
+
.brand .dot{ width:7px; height:7px; border-radius:50%; background: var(--accent); }
|
| 42 |
+
.brand .sep{ color: var(--muted); font-weight:400; }
|
| 43 |
+
.brand .count{ color: var(--muted); font-weight:400; }
|
| 44 |
+
|
| 45 |
+
select, input[type=text]{
|
| 46 |
+
background: var(--bg); border: 1px solid var(--line); color: var(--text);
|
| 47 |
+
border-radius: 7px; padding: 7px 10px; font-size: 0.85em; font-family: var(--sans);
|
| 48 |
+
outline:none; transition: border-color .15s, box-shadow .15s;
|
| 49 |
+
}
|
| 50 |
+
select:focus, input[type=text]:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
|
| 51 |
+
optgroup{ font-weight:700; color: var(--accent); }
|
| 52 |
+
|
| 53 |
+
#endpoint-select{ min-width: 260px; flex:1 1 260px; font-family: var(--mono); }
|
| 54 |
+
|
| 55 |
+
.seg{ display:flex; border:1px solid var(--line); border-radius:7px; overflow:hidden; flex-shrink:0; }
|
| 56 |
+
.seg button{
|
| 57 |
+
background: var(--bg); color: var(--muted); border:none; padding:7px 14px;
|
| 58 |
+
font-size:0.8em; font-weight:700; cursor:pointer; font-family: var(--mono);
|
| 59 |
+
transition: all .15s;
|
| 60 |
+
}
|
| 61 |
+
.seg button + button{ border-left:1px solid var(--line); }
|
| 62 |
+
.seg button.active{ background: var(--accent); color: var(--accent-text); }
|
| 63 |
+
.seg button:hover:not(.active){ background: var(--bg-2); color: var(--text); }
|
| 64 |
+
|
| 65 |
+
.btn{
|
| 66 |
+
border:none; border-radius:7px; padding:7px 16px; font-size:0.85em; font-weight:700;
|
| 67 |
+
cursor:pointer; transition: all .15s; white-space:nowrap; font-family: var(--sans);
|
| 68 |
+
}
|
| 69 |
+
.btn-run{ background: var(--accent); color: var(--accent-text); }
|
| 70 |
+
.btn-run:hover{ filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(13,148,136,0.28); }
|
| 71 |
+
.btn-ghost{ background: var(--bg); border:1px solid var(--line); color: var(--muted); }
|
| 72 |
+
.btn-ghost:hover{ color: var(--text); border-color: var(--accent); }
|
| 73 |
+
.btn-ghost.on{ color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
|
| 74 |
+
|
| 75 |
+
.param-row{
|
| 76 |
+
display:flex; align-items:center; gap:10px; flex-wrap:wrap;
|
| 77 |
+
padding: 9px 18px;
|
| 78 |
+
background: var(--bg-2);
|
| 79 |
+
border-bottom: 1px solid var(--line);
|
| 80 |
+
flex-shrink:0;
|
| 81 |
+
}
|
| 82 |
+
.param-row .none{ color: var(--muted); font-size:0.8em; font-style:italic; }
|
| 83 |
+
.pfield{ display:flex; align-items:center; gap:6px; }
|
| 84 |
+
.pfield label{ font-family: var(--mono); font-size:0.72em; color: var(--muted); text-transform:uppercase; letter-spacing:0.04em; white-space:nowrap; }
|
| 85 |
+
.pfield input, .pfield select{ width:auto; min-width:110px; padding:6px 8px; font-size:0.82em; }
|
| 86 |
+
.pfield.path label{ color: var(--accent); }
|
| 87 |
+
|
| 88 |
+
#info-panel{
|
| 89 |
+
max-height:0; overflow:hidden; transition: max-height .22s ease;
|
| 90 |
+
background: var(--bg-3); border-bottom: 1px solid var(--line);
|
| 91 |
+
}
|
| 92 |
+
#info-panel.open{ max-height: 440px; overflow-y:auto; }
|
| 93 |
+
.info-inner{ padding: 16px 18px; display:grid; gap:14px; }
|
| 94 |
+
.info-block .k{ font-family: var(--mono); font-size:0.7em; color: var(--accent); text-transform:uppercase; letter-spacing:0.06em; margin-bottom:6px; font-weight:700; }
|
| 95 |
+
.info-desc{ color: var(--text); font-size:0.88em; line-height:1.5; }
|
| 96 |
+
.url-box, .curl-box{
|
| 97 |
+
font-family: var(--mono); font-size:0.78em; color:#0f172a;
|
| 98 |
+
background:#ffffff; border:1px solid var(--line); border-radius:8px;
|
| 99 |
+
padding:10px 12px; word-break:break-all; line-height:1.6;
|
| 100 |
+
}
|
| 101 |
+
.curl-box{ color:#0d5b52; }
|
| 102 |
+
.copy-mini{
|
| 103 |
+
background: var(--bg); color: var(--muted); border:1px solid var(--line);
|
| 104 |
+
border-radius:5px; padding:3px 9px; font-size:0.72em; cursor:pointer; margin-top:6px;
|
| 105 |
+
}
|
| 106 |
+
.copy-mini:hover{ color: var(--accent); border-color: var(--accent); }
|
| 107 |
+
.tips-grid{ display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:8px; font-size:0.78em; color: var(--muted); }
|
| 108 |
+
.tips-grid code{ background:#ffffff; border:1px solid var(--line); color:#0d5b52; padding:1px 5px; border-radius:4px; }
|
| 109 |
+
|
| 110 |
+
main{ flex:1; display:flex; flex-direction:column; min-height:0; }
|
| 111 |
+
.status-strip{
|
| 112 |
+
display:flex; align-items:center; gap:14px; flex-wrap:wrap;
|
| 113 |
+
padding: 8px 18px; background: var(--bg); border-bottom:1px solid var(--line);
|
| 114 |
+
font-family: var(--mono); font-size:0.78em; color: var(--muted); flex-shrink:0;
|
| 115 |
+
}
|
| 116 |
+
.status-strip .pill{ padding:3px 10px; border-radius:20px; font-weight:700; }
|
| 117 |
+
.pill.ok{ background: var(--accent-dim); color: var(--accent); }
|
| 118 |
+
.pill.err{ background: var(--danger-dim); color: var(--danger); }
|
| 119 |
+
.pill.idle{ background: var(--bg-3); color: var(--muted); }
|
| 120 |
+
.status-strip .search-box{ margin-left:auto; display:flex; align-items:center; gap:6px; }
|
| 121 |
+
.status-strip .search-box input{ width:200px; }
|
| 122 |
+
|
| 123 |
+
.response-wrap{ flex:1; overflow:auto; background: var(--bg); }
|
| 124 |
+
.empty-state{
|
| 125 |
+
height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center;
|
| 126 |
+
color:#9aa1b0; gap:8px; font-family: var(--mono); font-size:0.9em;
|
| 127 |
+
}
|
| 128 |
+
.empty-state .big{ font-size:2.4em; opacity:0.3; }
|
| 129 |
+
|
| 130 |
+
table.data-grid{ width:100%; border-collapse:collapse; font-size:0.85em; color: var(--text); }
|
| 131 |
+
table.data-grid thead th{
|
| 132 |
+
position:sticky; top:0; z-index:2;
|
| 133 |
+
background: var(--bg-3); color:#48506a;
|
| 134 |
+
text-align:left; padding:9px 14px; font-size:0.78em; text-transform:uppercase;
|
| 135 |
+
letter-spacing:0.03em; border-bottom:2px solid var(--line); white-space:nowrap;
|
| 136 |
+
font-family: var(--mono); font-weight:700;
|
| 137 |
+
}
|
| 138 |
+
table.data-grid tbody td{
|
| 139 |
+
padding:8px 14px; border-bottom:1px solid var(--line); white-space:nowrap;
|
| 140 |
+
font-family: var(--mono); font-variant-numeric: tabular-nums;
|
| 141 |
+
}
|
| 142 |
+
table.data-grid tbody tr:nth-child(even){ background: var(--paper-alt); }
|
| 143 |
+
table.data-grid tbody tr:hover{ background: var(--accent-dim); }
|
| 144 |
+
table.data-grid td.num{ text-align:right; }
|
| 145 |
+
td.pos{ color:#0a9d67; font-weight:600; } td.neg{ color:#d6412f; font-weight:600; }
|
| 146 |
+
|
| 147 |
+
.kv-table{ max-width:900px; margin:20px; border-collapse:collapse; font-size:0.88em; }
|
| 148 |
+
.kv-table tr td{ padding:9px 16px; border-bottom:1px solid var(--line); vertical-align:top; }
|
| 149 |
+
.kv-table tr td:first-child{ font-family: var(--mono); color:#0d5b52; font-weight:700; white-space:nowrap; width:260px; }
|
| 150 |
+
.kv-table tr:nth-child(even){ background: var(--paper-alt); }
|
| 151 |
+
|
| 152 |
+
pre.raw-json{
|
| 153 |
+
margin:0; padding:20px; color: var(--text); font-family: var(--mono);
|
| 154 |
+
font-size:0.82em; white-space:pre-wrap; word-break:break-word;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
::-webkit-scrollbar{ width:9px; height:9px; }
|
| 158 |
+
::-webkit-scrollbar-track{ background: transparent; }
|
| 159 |
+
::-webkit-scrollbar-thumb{ background: #d3d8e2; border-radius:5px; }
|
| 160 |
+
::-webkit-scrollbar-thumb:hover{ background: #b7bdcb; }
|
| 161 |
+
|
| 162 |
+
@media (max-width: 720px){
|
| 163 |
+
#endpoint-select{ min-width: 100%; }
|
| 164 |
+
.param-row{ gap:8px; }
|
| 165 |
+
.status-strip .search-box{ margin-left:0; width:100%; }
|
| 166 |
+
.status-strip .search-box input{ width:100%; }
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/* ── View tabs (switch between Overview / Console) ── */
|
| 170 |
+
.view-tabs{
|
| 171 |
+
position:sticky; top:0; z-index:300;
|
| 172 |
+
display:flex; background:#0f172a; border-bottom:1px solid #1e293b; flex-shrink:0;
|
| 173 |
+
}
|
| 174 |
+
.view-tab{
|
| 175 |
+
flex:0 0 auto; padding:11px 22px; background:transparent; border:none;
|
| 176 |
+
color:#64748b; font-size:13px; font-weight:600; cursor:pointer;
|
| 177 |
+
font-family:'Segoe UI', system-ui, -apple-system, sans-serif;
|
| 178 |
+
border-bottom:2px solid transparent; transition:all .15s;
|
| 179 |
+
}
|
| 180 |
+
.view-tab:hover{ color:#cbd5e1; }
|
| 181 |
+
.view-tab.active{ color:#f8fafc; border-bottom-color:#3b82f6; background:#111827; }
|
| 182 |
+
|
| 183 |
+
/* ── FastInfo (Overview) view — scoped under #fi-view so it never collides
|
| 184 |
+
with the console's own styling. Light theme, matching the console's
|
| 185 |
+
own --bg/--text/--accent palette so the two tabs feel like one app. ── */
|
| 186 |
+
#fi-view{
|
| 187 |
+
display:none;
|
| 188 |
+
font-family: var(--sans);
|
| 189 |
+
background: var(--bg); color: var(--text); min-height:calc(100vh - 43px);
|
| 190 |
+
}
|
| 191 |
+
#fi-view.active{ display:block; }
|
| 192 |
+
#fi-view .header{
|
| 193 |
+
background: var(--bg);
|
| 194 |
+
padding: 18px 30px; border-bottom: 1px solid var(--line);
|
| 195 |
+
position: sticky; top: 43px; z-index: 100;
|
| 196 |
+
display: flex; justify-content: space-between; align-items: center;
|
| 197 |
+
}
|
| 198 |
+
#fi-view .header h1{ font-size: 20px; color: var(--text); display: flex; align-items: center; gap: 10px; font-weight:700; }
|
| 199 |
+
#fi-view .header .subtitle{ font-size: 12px; color: var(--muted); margin-top: 4px; }
|
| 200 |
+
#fi-view .header .live-dot{
|
| 201 |
+
width: 8px; height: 8px; background: #16a34a; border-radius: 50%;
|
| 202 |
+
display: inline-block; animation: fiPulse 2s infinite;
|
| 203 |
+
}
|
| 204 |
+
@keyframes fiPulse{
|
| 205 |
+
0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(22,163,74,0.5); }
|
| 206 |
+
50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(22,163,74,0); }
|
| 207 |
+
}
|
| 208 |
+
#fi-view .header-actions{ display: flex; gap: 10px; align-items: center; }
|
| 209 |
+
|
| 210 |
+
#fi-view .timestamp-bar{
|
| 211 |
+
background: var(--bg-2); padding: 8px 30px; font-size: 11px; color: var(--muted);
|
| 212 |
+
text-align: center; border-bottom: 1px solid var(--line);
|
| 213 |
+
display: flex; justify-content: center; gap: 20px;
|
| 214 |
+
}
|
| 215 |
+
#fi-view .timestamp-bar span{ color: #48506a; }
|
| 216 |
+
|
| 217 |
+
#fi-view .container{ max-width: 1400px; margin: 0 auto; padding: 20px; }
|
| 218 |
+
|
| 219 |
+
/* Group selector — pill buttons, one per section, default active = Indian Indices */
|
| 220 |
+
#fi-view .fi-group-tabs{
|
| 221 |
+
display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px 0;
|
| 222 |
+
max-width: 1400px; margin: 0 auto;
|
| 223 |
+
}
|
| 224 |
+
#fi-view .fi-group-tab{
|
| 225 |
+
display: inline-flex; align-items: center; gap: 6px;
|
| 226 |
+
padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
|
| 227 |
+
background: var(--bg); color: var(--muted); font-size: 12.5px; font-weight: 600;
|
| 228 |
+
cursor: pointer; transition: all 0.15s; font-family: var(--sans);
|
| 229 |
+
}
|
| 230 |
+
#fi-view .fi-group-tab:hover{ border-color: var(--accent); color: var(--accent); }
|
| 231 |
+
#fi-view .fi-group-tab.active{
|
| 232 |
+
background: var(--accent); border-color: var(--accent); color: #fff;
|
| 233 |
+
}
|
| 234 |
+
#fi-view .fi-group-tab .count{
|
| 235 |
+
font-size: 10px; opacity: 0.75; font-weight: 700;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/* Segment Cards */
|
| 239 |
+
#fi-view .segment{
|
| 240 |
+
background: var(--bg); border-radius: 12px; margin-bottom: 16px; overflow: hidden;
|
| 241 |
+
border: 1px solid var(--line); transition: border-color 0.2s, box-shadow 0.2s;
|
| 242 |
+
box-shadow: 0 1px 2px rgba(15,23,42,0.03);
|
| 243 |
+
}
|
| 244 |
+
#fi-view .segment:hover{ border-color: #cbd2e0; box-shadow: 0 2px 8px rgba(15,23,42,0.06); }
|
| 245 |
+
#fi-view .segment-header{
|
| 246 |
+
display: flex; justify-content: space-between; align-items: center;
|
| 247 |
+
padding: 14px 20px; background: var(--bg-2); cursor: pointer; user-select: none;
|
| 248 |
+
transition: background 0.2s;
|
| 249 |
+
}
|
| 250 |
+
#fi-view .segment-header:hover{ background: var(--bg-3); }
|
| 251 |
+
#fi-view .segment-title{ display: flex; align-items: center; gap: 10px; }
|
| 252 |
+
#fi-view .segment-title .icon{ font-size: 18px; }
|
| 253 |
+
#fi-view .segment-title h2{ font-size: 15px; font-weight: 700; color: var(--text); }
|
| 254 |
+
#fi-view .segment-title .badge{
|
| 255 |
+
font-size: 10px; padding: 2px 8px; border-radius: 10px;
|
| 256 |
+
background: var(--bg-3); color: var(--muted); border: 1px solid var(--line);
|
| 257 |
+
font-weight:600;
|
| 258 |
+
}
|
| 259 |
+
#fi-view .segment-title .badge.live{ background: rgba(22,163,74,0.10); color: #15803d; border-color: rgba(22,163,74,0.35); }
|
| 260 |
+
#fi-view .segment-title .badge.cached{ background: rgba(217,119,6,0.10); color: #b45309; border-color: rgba(217,119,6,0.35); }
|
| 261 |
+
#fi-view .segment-actions{ display: flex; align-items: center; gap: 12px; }
|
| 262 |
+
#fi-view .last-updated{ font-size: 11px; color: #94a0b5; }
|
| 263 |
+
#fi-view .count-badge{
|
| 264 |
+
font-size: 11px; color: var(--muted); background: var(--bg-3); padding: 2px 8px; border-radius: 6px; font-weight:600;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/* Segment collapse toggle indicator — sections start expanded, this just
|
| 268 |
+
tells you they're still collapsible if you want to tidy the page up. */
|
| 269 |
+
#fi-view .segment-header .chevron{
|
| 270 |
+
font-size: 11px; color: var(--muted); transition: transform 0.2s; margin-right: 2px;
|
| 271 |
+
}
|
| 272 |
+
#fi-view .segment-header.is-open .chevron{ transform: rotate(90deg); }
|
| 273 |
+
|
| 274 |
+
/* Buttons (fi- prefixed to avoid clashing with the console's .btn) */
|
| 275 |
+
#fi-view .fi-btn{
|
| 276 |
+
padding: 6px 14px; border: none; border-radius: 6px; font-size: 12px;
|
| 277 |
+
cursor: pointer; transition: all 0.2s; font-weight: 600;
|
| 278 |
+
display: inline-flex; align-items: center; gap: 4px;
|
| 279 |
+
font-family: var(--sans);
|
| 280 |
+
}
|
| 281 |
+
#fi-view .fi-btn-refresh{ background: var(--accent-dim); color: var(--accent); border:1px solid rgba(13,148,136,0.3); }
|
| 282 |
+
#fi-view .fi-btn-refresh:hover{ background: var(--accent); color:#fff; }
|
| 283 |
+
#fi-view .fi-btn-refresh:disabled{ opacity: 0.5; cursor: not-allowed; }
|
| 284 |
+
#fi-view .fi-btn-refresh.spinning::after{
|
| 285 |
+
content: ""; width: 12px; height: 12px; border: 2px solid transparent;
|
| 286 |
+
border-top-color: currentColor; border-radius: 50%;
|
| 287 |
+
animation: fiSpin 0.8s linear infinite; display: inline-block;
|
| 288 |
+
}
|
| 289 |
+
@keyframes fiSpin{ to { transform: rotate(360deg); } }
|
| 290 |
+
|
| 291 |
+
#fi-view .fi-btn-all{ background: var(--accent); color: #fff; padding: 8px 18px; font-size: 13px; }
|
| 292 |
+
#fi-view .fi-btn-all:hover{ filter: brightness(1.08); box-shadow: 0 4px 14px rgba(13,148,136,0.28); }
|
| 293 |
+
|
| 294 |
+
/* Segment Body — sections render expanded by default (no collapse-in
|
| 295 |
+
animation needed on load; toggling still animates via max-height) */
|
| 296 |
+
#fi-view .segment-body{ max-height: 0; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease; }
|
| 297 |
+
#fi-view .segment-body.open{ max-height: 4000px; padding: 16px 20px; }
|
| 298 |
+
|
| 299 |
+
/* Grid */
|
| 300 |
+
#fi-view .grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
|
| 301 |
+
#fi-view .card{
|
| 302 |
+
background: var(--bg); border-radius: 8px; padding: 12px 14px;
|
| 303 |
+
border: 1px solid var(--line); transition: all 0.2s; position: relative;
|
| 304 |
+
}
|
| 305 |
+
#fi-view .card:hover{ border-color: var(--accent); box-shadow: 0 2px 8px rgba(15,23,42,0.06); }
|
| 306 |
+
#fi-view .card .symbol{ font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; letter-spacing: 0.3px; }
|
| 307 |
+
#fi-view .card .price{ font-size: 20px; font-weight: 700; color: var(--text); font-family: var(--mono); }
|
| 308 |
+
#fi-view .card .change{ font-size: 12px; font-weight: 700; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
|
| 309 |
+
#fi-view .card .change.up{ color: #16a34a; }
|
| 310 |
+
#fi-view .card .change.down{ color: #dc2626; }
|
| 311 |
+
#fi-view .card .change.neutral{ color: var(--muted); }
|
| 312 |
+
#fi-view .card .currency{ font-size: 9px; color: #9aa1b0; margin-top: 4px; text-transform: uppercase; letter-spacing:0.04em; }
|
| 313 |
+
#fi-view .card.failed{ opacity: 0.5; border-color: rgba(220,38,38,0.25); background: rgba(220,38,38,0.03); }
|
| 314 |
+
#fi-view .card.failed::after{
|
| 315 |
+
content: "N/A"; position: absolute; top: 8px; right: 8px; font-size: 9px;
|
| 316 |
+
color: #b91c1c; background: rgba(220,38,38,0.10); padding: 1px 5px; border-radius: 4px; font-weight:700;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
/* States */
|
| 320 |
+
#fi-view .fi-loading{ text-align: center; padding: 60px 20px; color: var(--muted); }
|
| 321 |
+
#fi-view .fi-loading-spinner{
|
| 322 |
+
width: 32px; height: 32px; border: 3px solid var(--bg-3); border-top-color: var(--accent);
|
| 323 |
+
border-radius: 50%; animation: fiSpin 1s linear infinite; margin: 0 auto 16px;
|
| 324 |
+
}
|
| 325 |
+
#fi-view .fi-error{
|
| 326 |
+
background: var(--danger-dim); color: #991b1b; padding: 12px 16px; border-radius: 8px;
|
| 327 |
+
margin: 10px 0; font-size: 13px; border: 1px solid rgba(220,38,38,0.25);
|
| 328 |
+
}
|
| 329 |
+
#fi-view .fi-empty{ text-align: center; padding: 40px; color: var(--muted); font-size: 13px; }
|
| 330 |
+
|
| 331 |
+
/* Symbol cards are now clickable (except failed/no-data ones) */
|
| 332 |
+
#fi-view .card{ cursor: pointer; }
|
| 333 |
+
#fi-view .card.failed{ cursor: default; }
|
| 334 |
+
|
| 335 |
+
/* ── Symbol detail modal — not scoped to #fi-view since it overlays the
|
| 336 |
+
whole page, but uses the same light palette for visual consistency ── */
|
| 337 |
+
.symbol-modal-overlay{
|
| 338 |
+
display: none; position: fixed; inset: 0; z-index: 1000;
|
| 339 |
+
background: rgba(15,23,42,0.45); backdrop-filter: blur(2px);
|
| 340 |
+
align-items: center; justify-content: center; padding: 20px;
|
| 341 |
+
}
|
| 342 |
+
.symbol-modal-overlay.active{ display: flex; }
|
| 343 |
+
.symbol-modal{
|
| 344 |
+
background: var(--bg); border-radius: 14px; width: 100%; max-width: 520px;
|
| 345 |
+
max-height: 88vh; overflow-y: auto; position: relative;
|
| 346 |
+
box-shadow: 0 20px 60px rgba(15,23,42,0.25);
|
| 347 |
+
padding: 24px; font-family: var(--sans);
|
| 348 |
+
}
|
| 349 |
+
.symbol-modal-close{
|
| 350 |
+
position: absolute; top: 16px; right: 16px; width: 28px; height: 28px;
|
| 351 |
+
border: none; background: var(--bg-3); color: var(--muted); border-radius: 50%;
|
| 352 |
+
font-size: 14px; cursor: pointer; transition: all 0.15s;
|
| 353 |
+
display: flex; align-items: center; justify-content: center;
|
| 354 |
+
}
|
| 355 |
+
.symbol-modal-close:hover{ background: var(--danger-dim); color: #b91c1c; }
|
| 356 |
+
|
| 357 |
+
.sm-header{ margin-bottom: 14px; padding-right: 30px; }
|
| 358 |
+
.sm-symbol{ font-size: 20px; font-weight: 700; color: var(--text); }
|
| 359 |
+
.sm-name{ font-size: 12.5px; color: var(--muted); margin-top: 2px; }
|
| 360 |
+
.sm-price-row{ display: flex; align-items: baseline; gap: 10px; margin-top: 10px; }
|
| 361 |
+
.sm-price{ font-size: 30px; font-weight: 700; color: var(--text); font-family: var(--mono); }
|
| 362 |
+
.sm-change{ font-size: 14px; font-weight: 700; }
|
| 363 |
+
.sm-change.up{ color: #16a34a; } .sm-change.down{ color: #dc2626; } .sm-change.neutral{ color: var(--muted); }
|
| 364 |
+
|
| 365 |
+
.sm-chart-wrap{ margin: 16px 0; }
|
| 366 |
+
.sm-chart-label{ font-size: 11px; color: var(--muted); margin-bottom: 6px; display:flex; justify-content:space-between; }
|
| 367 |
+
.sm-chart-svg{ width: 100%; height: 140px; display: block; }
|
| 368 |
+
.sm-chart-empty{ text-align: center; padding: 30px; color: var(--muted); font-size: 12px; }
|
| 369 |
+
|
| 370 |
+
.sm-stats-grid{
|
| 371 |
+
display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px;
|
| 372 |
+
margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
|
| 373 |
+
}
|
| 374 |
+
.sm-stat{ display: flex; flex-direction: column; gap: 2px; }
|
| 375 |
+
.sm-stat .label{ font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
|
| 376 |
+
.sm-stat .value{ font-size: 13.5px; font-weight: 600; color: var(--text); font-family: var(--mono); }
|
| 377 |
+
|
| 378 |
+
.sm-footer{ margin-top: 16px; font-size: 10.5px; color: #9aa1b0; text-align: center; }
|
| 379 |
+
|
| 380 |
+
@media (max-width: 600px){
|
| 381 |
+
.symbol-modal{ max-width: 100%; padding: 20px; }
|
| 382 |
+
.sm-stats-grid{ grid-template-columns: 1fr 1fr; }
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
@media (max-width: 768px){
|
| 386 |
+
#fi-view .header{ flex-direction: column; gap: 10px; align-items: flex-start; }
|
| 387 |
+
#fi-view .grid{ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
|
| 388 |
+
#fi-view .segment-actions{ gap: 6px; }
|
| 389 |
+
#fi-view .last-updated{ display: none; }
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
#console-view{ display:none; flex-direction:column; min-height:calc(100vh - 43px); }
|
| 393 |
+
#console-view.active{ display:flex; }
|
| 394 |
+
</style>
|
| 395 |
+
<base target="_blank">
|
| 396 |
+
</head>
|
| 397 |
+
<body>
|
| 398 |
+
|
| 399 |
+
<div class="view-tabs">
|
| 400 |
+
<button class="view-tab active" id="tab-overview" onclick="switchView('overview')">📊 Market Overview</button>
|
| 401 |
+
<button class="view-tab" id="tab-console" onclick="switchView('console')">🔌 API Console</button>
|
| 402 |
+
</div>
|
| 403 |
+
|
| 404 |
+
<div id="fi-view" class="active">
|
| 405 |
+
<div class="header">
|
| 406 |
+
<div>
|
| 407 |
+
<h1>📊 FastInfo Market Overview</h1>
|
| 408 |
+
<div class="subtitle">
|
| 409 |
+
<span class="live-dot"></span> Background refresh every 1h
|
| 410 |
+
• Pick a section below • Hit refresh for a live pull (max once/min)
|
| 411 |
+
</div>
|
| 412 |
+
</div>
|
| 413 |
+
<div class="header-actions">
|
| 414 |
+
<button class="fi-btn fi-btn-all" onclick="refreshAll()" id="btn-all">
|
| 415 |
+
🔄 Refresh All
|
| 416 |
+
</button>
|
| 417 |
+
</div>
|
| 418 |
+
</div>
|
| 419 |
+
|
| 420 |
+
<div class="timestamp-bar">
|
| 421 |
+
<span id="ts-snapshot">Snapshot: loading...</span>
|
| 422 |
+
<span id="ts-groups">Groups: loading...</span>
|
| 423 |
+
</div>
|
| 424 |
+
|
| 425 |
+
<div class="fi-group-tabs" id="fi-group-tabs"></div>
|
| 426 |
+
|
| 427 |
+
<div class="container" id="fi-container">
|
| 428 |
+
<div class="fi-loading">
|
| 429 |
+
<div class="fi-loading-spinner"></div>
|
| 430 |
+
Loading market snapshot...
|
| 431 |
+
</div>
|
| 432 |
+
</div>
|
| 433 |
+
</div>
|
| 434 |
+
|
| 435 |
+
<div id="console-view">
|
| 436 |
+
|
| 437 |
+
<header class="chrome">
|
| 438 |
+
<div class="chrome-row">
|
| 439 |
+
<div class="brand"><span class="dot"></span>MarketAPI2<span class="sep">/</span><span class="count" id="ep-count">— endpoints</span></div>
|
| 440 |
+
|
| 441 |
+
<select id="endpoint-select" onchange="onEndpointChange()"></select>
|
| 442 |
+
|
| 443 |
+
<div class="seg" id="format-seg">
|
| 444 |
+
<button data-fmt="json" class="active" onclick="setFormat('json')">JSON</button>
|
| 445 |
+
<button data-fmt="csv" onclick="setFormat('csv')">CSV</button>
|
| 446 |
+
</div>
|
| 447 |
+
|
| 448 |
+
<button class="btn btn-run" onclick="testAPI()">▶ Run</button>
|
| 449 |
+
<button class="btn btn-ghost" id="info-toggle" onclick="toggleInfo()">ⓘ Info</button>
|
| 450 |
+
</div>
|
| 451 |
+
</header>
|
| 452 |
+
|
| 453 |
+
<div class="param-row" id="param-row">
|
| 454 |
+
</div>
|
| 455 |
+
|
| 456 |
+
<div id="info-panel">
|
| 457 |
+
<div class="info-inner">
|
| 458 |
+
<div class="info-block">
|
| 459 |
+
<div class="k">Description</div>
|
| 460 |
+
<div class="info-desc" id="info-desc">—</div>
|
| 461 |
+
</div>
|
| 462 |
+
<div class="info-block">
|
| 463 |
+
<div class="k">Full URL</div>
|
| 464 |
+
<div class="url-box" id="url-text">—</div>
|
| 465 |
+
<button class="copy-mini" onclick="copyURL()">Copy URL</button>
|
| 466 |
+
</div>
|
| 467 |
+
<div class="info-block">
|
| 468 |
+
<div class="k">cURL</div>
|
| 469 |
+
<div class="curl-box" id="curl-display">—</div>
|
| 470 |
+
<button class="copy-mini" onclick="copyCurl()">Copy cURL</button>
|
| 471 |
+
</div>
|
| 472 |
+
<div class="info-block">
|
| 473 |
+
<div class="k">Quick tips</div>
|
| 474 |
+
<div class="tips-grid">
|
| 475 |
+
<div>NSE dates → <code>DD-MM-YYYY</code></div>
|
| 476 |
+
<div>Yahoo dates → <code>YYYY-MM-DD</code></div>
|
| 477 |
+
<div>Indian stocks → add <code>.NS</code> (e.g. <code>ITC.NS</code>)</div>
|
| 478 |
+
<div>US stocks → direct symbol (e.g. <code>AAPL</code>)</div>
|
| 479 |
+
<div>Intraday intervals only cover the last 60 days</div>
|
| 480 |
+
<div>JSON renders a table here · CSV downloads to disk</div>
|
| 481 |
+
</div>
|
| 482 |
+
</div>
|
| 483 |
+
</div>
|
| 484 |
+
</div>
|
| 485 |
+
|
| 486 |
+
<main>
|
| 487 |
+
<div class="status-strip">
|
| 488 |
+
<span class="pill idle" id="status-pill">idle</span>
|
| 489 |
+
<span id="status-meta"></span>
|
| 490 |
+
<div class="search-box" id="search-wrap" style="display:none;">
|
| 491 |
+
<span style="color:var(--muted)">filter</span>
|
| 492 |
+
<input type="text" id="table-filter" placeholder="type to filter rows…" oninput="filterTable()">
|
| 493 |
+
</div>
|
| 494 |
+
</div>
|
| 495 |
+
<div class="response-wrap" id="response-wrap">
|
| 496 |
+
<div class="empty-state">
|
| 497 |
+
<div class="big">◌</div>
|
| 498 |
+
<div>Pick an endpoint above and hit <b style="color:var(--accent)">Run</b></div>
|
| 499 |
+
</div>
|
| 500 |
+
</div>
|
| 501 |
+
</main>
|
| 502 |
+
</div>
|
| 503 |
+
<!-- /#console-view -->
|
| 504 |
+
|
| 505 |
+
<div id="symbol-modal-overlay" class="symbol-modal-overlay" onclick="closeSymbolModal(event)">
|
| 506 |
+
<div class="symbol-modal" onclick="event.stopPropagation()">
|
| 507 |
+
<button class="symbol-modal-close" onclick="closeSymbolModal()" aria-label="Close">✕</button>
|
| 508 |
+
<div id="symbol-modal-body">
|
| 509 |
+
<div class="fi-loading"><div class="fi-loading-spinner"></div>Loading...</div>
|
| 510 |
+
</div>
|
| 511 |
+
</div>
|
| 512 |
+
</div>
|
| 513 |
+
|
| 514 |
+
<script>
|
| 515 |
+
// ═══════════════════════════════════════════════════════════════════════
|
| 516 |
+
// VIEW SWITCHING (Overview ⇄ Console)
|
| 517 |
+
// ═══════════════════════════════════════════════════════════════════════
|
| 518 |
+
function switchView(name){
|
| 519 |
+
document.getElementById('fi-view').classList.toggle('active', name === 'overview');
|
| 520 |
+
document.getElementById('console-view').classList.toggle('active', name === 'console');
|
| 521 |
+
document.getElementById('tab-overview').classList.toggle('active', name === 'overview');
|
| 522 |
+
document.getElementById('tab-console').classList.toggle('active', name === 'console');
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
// ═══════════════════════════════════════════════════════════════════════
|
| 526 |
+
// FASTINFO — MARKET OVERVIEW
|
| 527 |
+
// ═══════════════════════════════════════════════════════��═══════════════
|
| 528 |
+
const FI_API_BASE = window.location.origin;
|
| 529 |
+
|
| 530 |
+
const GROUP_CONFIG = {
|
| 531 |
+
indian_indices: { icon: "🇮🇳", label: "Indian Indices", desc: "NSE/BSE sectoral indices" },
|
| 532 |
+
global_indices: { icon: "🌍", label: "Global Indices", desc: "Major world indices" },
|
| 533 |
+
crypto: { icon: "🪙", label: "Crypto", desc: "Top cryptocurrencies, by market cap" },
|
| 534 |
+
nifty50_stocks: { icon: "📈", label: "Nifty 50 Stocks", desc: "Nifty 50 constituents" },
|
| 535 |
+
commodities: { icon: "🛢️", label: "Commodities", desc: "Metals, energy, agri" },
|
| 536 |
+
forex_major: { icon: "💱", label: "Forex Major", desc: "Major currency pairs" },
|
| 537 |
+
forex_emerging: { icon: "💰", label: "Forex Emerging", desc: "Emerging market FX" },
|
| 538 |
+
bonds: { icon: "📉", label: "Bonds & Yields", desc: "Treasury yields" },
|
| 539 |
+
};
|
| 540 |
+
|
| 541 |
+
let snapshotData = {};
|
| 542 |
+
let activeGroup = "indian_indices"; // default section shown on load
|
| 543 |
+
let isRefreshingAll = false;
|
| 544 |
+
|
| 545 |
+
async function loadSnapshot() {
|
| 546 |
+
try {
|
| 547 |
+
const res = await fetch(`${FI_API_BASE}/fastinfo/snapshot`);
|
| 548 |
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
| 549 |
+
snapshotData = await res.json();
|
| 550 |
+
renderFiTabs();
|
| 551 |
+
renderFi();
|
| 552 |
+
updateTimestamp();
|
| 553 |
+
} catch (e) {
|
| 554 |
+
document.getElementById("fi-container").innerHTML =
|
| 555 |
+
`<div class="fi-error">Failed to load snapshot: ${e.message}<br>Try refreshing.</div>`;
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
function updateTimestamp() {
|
| 560 |
+
const meta = snapshotData._meta;
|
| 561 |
+
const elSnap = document.getElementById("ts-snapshot");
|
| 562 |
+
const elGroups = document.getElementById("ts-groups");
|
| 563 |
+
|
| 564 |
+
if (meta && meta.updated_at) {
|
| 565 |
+
const d = new Date(meta.updated_at);
|
| 566 |
+
elSnap.textContent = `Snapshot: ${d.toLocaleString()}`;
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
const groups = Object.keys(GROUP_CONFIG).filter(g => snapshotData[g]);
|
| 570 |
+
elGroups.textContent = `Groups: ${groups.length} loaded`;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
// Strip the Yahoo ".NS" suffix for display only — API calls elsewhere still
|
| 574 |
+
// use the real symbol; this is purely cosmetic for the card grid.
|
| 575 |
+
function displaySymbol(sym) {
|
| 576 |
+
return sym.replace(/\.NS$/i, "");
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
function renderFiTabs() {
|
| 580 |
+
const tabs = document.getElementById("fi-group-tabs");
|
| 581 |
+
tabs.innerHTML = Object.entries(GROUP_CONFIG).map(([group, config]) => {
|
| 582 |
+
const groupData = snapshotData[group];
|
| 583 |
+
const count = groupData ? `${groupData.fetched || 0}/${groupData.count || 0}` : "";
|
| 584 |
+
return `
|
| 585 |
+
<button class="fi-group-tab ${group === activeGroup ? 'active' : ''}"
|
| 586 |
+
onclick="setActiveGroup('${group}')">
|
| 587 |
+
<span>${config.icon}</span> ${config.label}
|
| 588 |
+
${count ? `<span class="count">${count}</span>` : ''}
|
| 589 |
+
</button>
|
| 590 |
+
`;
|
| 591 |
+
}).join("");
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
function setActiveGroup(group) {
|
| 595 |
+
activeGroup = group;
|
| 596 |
+
renderFiTabs();
|
| 597 |
+
renderFi();
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
function renderFi() {
|
| 601 |
+
const container = document.getElementById("fi-container");
|
| 602 |
+
const config = GROUP_CONFIG[activeGroup];
|
| 603 |
+
const groupData = snapshotData[activeGroup];
|
| 604 |
+
|
| 605 |
+
if (!groupData) {
|
| 606 |
+
container.innerHTML = `<div class="fi-empty">No data yet for ${config?.label || activeGroup}. Try Refresh All.</div>`;
|
| 607 |
+
return;
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
const isLive = !!groupData.refreshed_at;
|
| 611 |
+
const lastUpdated = groupData.refreshed_at || snapshotData._meta?.updated_at;
|
| 612 |
+
const okCount = groupData.fetched || 0;
|
| 613 |
+
const totalCount = groupData.count || 0;
|
| 614 |
+
|
| 615 |
+
container.innerHTML = `
|
| 616 |
+
<div class="segment">
|
| 617 |
+
<div class="segment-header is-open">
|
| 618 |
+
<div class="segment-title">
|
| 619 |
+
<span class="icon">${config.icon}</span>
|
| 620 |
+
<h2>${config.label}</h2>
|
| 621 |
+
<span class="badge ${isLive ? 'live' : 'cached'}">
|
| 622 |
+
${isLive ? '● LIVE' : '○ Cached'}
|
| 623 |
+
</span>
|
| 624 |
+
</div>
|
| 625 |
+
<div class="segment-actions">
|
| 626 |
+
<span class="count-badge">${okCount}/${totalCount}</span>
|
| 627 |
+
<span class="last-updated">${lastUpdated ? timeAgo(lastUpdated) : ''}</span>
|
| 628 |
+
<button class="fi-btn fi-btn-refresh" id="btn-${activeGroup}"
|
| 629 |
+
onclick="refreshGroup('${activeGroup}')">
|
| 630 |
+
🔄 Refresh
|
| 631 |
+
</button>
|
| 632 |
+
</div>
|
| 633 |
+
</div>
|
| 634 |
+
<div class="segment-body open" id="body-${activeGroup}">
|
| 635 |
+
${renderGrid(groupData.data, groupData.failed, activeGroup)}
|
| 636 |
+
</div>
|
| 637 |
+
</div>
|
| 638 |
+
`;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
function renderGrid(data, failed = [], group = null) {
|
| 642 |
+
if (!data) return '<div class="fi-empty">No data available</div>';
|
| 643 |
+
const failedSet = new Set(failed);
|
| 644 |
+
|
| 645 |
+
let html = '<div class="grid">';
|
| 646 |
+
for (const [sym, info] of Object.entries(data)) {
|
| 647 |
+
const isFailed = failedSet.has(sym);
|
| 648 |
+
const changeClass = info.change_pct > 0 ? 'up' : info.change_pct < 0 ? 'down' : 'neutral';
|
| 649 |
+
const sign = info.change_pct > 0 ? '+' : '';
|
| 650 |
+
const arrow = info.change_pct > 0 ? '▲' : info.change_pct < 0 ? '▼' : '−';
|
| 651 |
+
// data-* attributes (not inline onclick) so symbols with &, ", etc.
|
| 652 |
+
// (e.g. "M&M.NS") can't break out of the HTML attribute — a single
|
| 653 |
+
// delegated click listener on #fi-container reads these instead.
|
| 654 |
+
const dataAttrs = isFailed ? '' : `data-symbol="${escapeHtml(sym)}" data-group="${escapeHtml(group)}"`;
|
| 655 |
+
|
| 656 |
+
html += `
|
| 657 |
+
<div class="card ${isFailed ? 'failed' : ''}" ${dataAttrs}>
|
| 658 |
+
<div class="symbol">${displaySymbol(sym)}</div>
|
| 659 |
+
<div class="price">${isFailed ? '—' : info.price.toLocaleString()}</div>
|
| 660 |
+
<div class="change ${changeClass}">
|
| 661 |
+
${arrow} ${sign}${info.change_pct}%
|
| 662 |
+
</div>
|
| 663 |
+
<div class="currency">${info.currency || 'USD'}</div>
|
| 664 |
+
</div>
|
| 665 |
+
`;
|
| 666 |
+
}
|
| 667 |
+
html += '</div>';
|
| 668 |
+
return html;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
// Delegated click handler — attached once, works for every re-render.
|
| 672 |
+
document.getElementById("fi-container").addEventListener("click", (e) => {
|
| 673 |
+
const card = e.target.closest(".card[data-symbol]");
|
| 674 |
+
if (card) openSymbolModal(card.dataset.group, card.dataset.symbol);
|
| 675 |
+
});
|
| 676 |
+
|
| 677 |
+
function changeMeta(pct) {
|
| 678 |
+
if (pct > 0) return { cls: "up", arrow: "▲", sign: "+" };
|
| 679 |
+
if (pct < 0) return { cls: "down", arrow: "▼", sign: "" };
|
| 680 |
+
return { cls: "neutral", arrow: "−", sign: "" };
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
function formatDate(d) {
|
| 684 |
+
if (!d) return "";
|
| 685 |
+
const dt = new Date(d);
|
| 686 |
+
if (isNaN(dt)) return String(d).slice(0, 10);
|
| 687 |
+
return dt.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
function bigNumFmt(v) {
|
| 691 |
+
if (typeof v !== "number") return v;
|
| 692 |
+
if (Math.abs(v) >= 1e12) return (v / 1e12).toFixed(2) + "T";
|
| 693 |
+
if (Math.abs(v) >= 1e9) return (v / 1e9).toFixed(2) + "B";
|
| 694 |
+
if (Math.abs(v) >= 1e6) return (v / 1e6).toFixed(2) + "M";
|
| 695 |
+
return v.toLocaleString();
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
function numFmt(v) {
|
| 699 |
+
return typeof v === "number" ? v.toLocaleString(undefined, { maximumFractionDigits: 2 }) : v;
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
// Minimal dependency-free line chart — an inline SVG polyline. Avoids
|
| 703 |
+
// pulling in a charting library just for a 1-month sparkline-style view.
|
| 704 |
+
function renderLineChart(records) {
|
| 705 |
+
const width = 600, height = 140, pad = 8;
|
| 706 |
+
const points = records
|
| 707 |
+
.map(r => ({ date: r.date || r.datetime, close: r.close }))
|
| 708 |
+
.filter(r => typeof r.close === "number");
|
| 709 |
+
|
| 710 |
+
if (points.length < 2) {
|
| 711 |
+
return '<div class="sm-chart-empty">Not enough price history for a chart</div>';
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
const closes = points.map(p => p.close);
|
| 715 |
+
const min = Math.min(...closes), max = Math.max(...closes);
|
| 716 |
+
const range = (max - min) || 1;
|
| 717 |
+
const stepX = (width - pad * 2) / (points.length - 1);
|
| 718 |
+
|
| 719 |
+
const coords = points.map((p, i) => {
|
| 720 |
+
const x = pad + i * stepX;
|
| 721 |
+
const y = pad + (height - pad * 2) * (1 - (p.close - min) / range);
|
| 722 |
+
return `${x.toFixed(1)},${y.toFixed(1)}`;
|
| 723 |
+
});
|
| 724 |
+
|
| 725 |
+
const up = closes[closes.length - 1] >= closes[0];
|
| 726 |
+
const color = up ? "#16a34a" : "#dc2626";
|
| 727 |
+
const area = `${pad},${height - pad} ${coords.join(" ")} ${width - pad},${height - pad}`;
|
| 728 |
+
|
| 729 |
+
return `
|
| 730 |
+
<svg class="sm-chart-svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none">
|
| 731 |
+
<polygon points="${area}" fill="${color}" opacity="0.08"></polygon>
|
| 732 |
+
<polyline points="${coords.join(" ")}" fill="none" stroke="${color}"
|
| 733 |
+
stroke-width="2" stroke-linejoin="round" stroke-linecap="round"></polyline>
|
| 734 |
+
</svg>
|
| 735 |
+
<div style="display:flex;justify-content:space-between;font-size:10.5px;color:var(--muted);margin-top:4px;">
|
| 736 |
+
<span>Low ${numFmt(min)}</span>
|
| 737 |
+
<span>High ${numFmt(max)}</span>
|
| 738 |
+
</div>
|
| 739 |
+
`;
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
function buildStatsGrid(info) {
|
| 743 |
+
const rows = [];
|
| 744 |
+
const push = (label, val, fmt) => {
|
| 745 |
+
if (val === undefined || val === null || val === "") return;
|
| 746 |
+
rows.push(`<div class="sm-stat"><span class="label">${label}</span><span class="value">${fmt ? fmt(val) : val}</span></div>`);
|
| 747 |
+
};
|
| 748 |
+
|
| 749 |
+
push("Previous Close", info.previousClose ?? info.regularMarketPreviousClose, numFmt);
|
| 750 |
+
push("Open", info.open ?? info.regularMarketOpen, numFmt);
|
| 751 |
+
push("Day High", info.dayHigh ?? info.regularMarketDayHigh, numFmt);
|
| 752 |
+
push("Day Low", info.dayLow ?? info.regularMarketDayLow, numFmt);
|
| 753 |
+
push("52W High", info.fiftyTwoWeekHigh, numFmt);
|
| 754 |
+
push("52W Low", info.fiftyTwoWeekLow, numFmt);
|
| 755 |
+
push("Volume", info.volume ?? info.regularMarketVolume, bigNumFmt);
|
| 756 |
+
push("Avg Volume", info.averageVolume, bigNumFmt);
|
| 757 |
+
push("Market Cap", info.marketCap, bigNumFmt);
|
| 758 |
+
push("Exchange", info.exchange);
|
| 759 |
+
|
| 760 |
+
if (!rows.length) {
|
| 761 |
+
return '<div class="fi-empty" style="grid-column:1/-1;padding:10px 0;">No extended stats available for this symbol</div>';
|
| 762 |
+
}
|
| 763 |
+
return rows.join("");
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
async function openSymbolModal(group, sym) {
|
| 767 |
+
const overlay = document.getElementById("symbol-modal-overlay");
|
| 768 |
+
const body = document.getElementById("symbol-modal-body");
|
| 769 |
+
overlay.classList.add("active");
|
| 770 |
+
document.body.style.overflow = "hidden";
|
| 771 |
+
|
| 772 |
+
const known = snapshotData[group]?.data?.[sym];
|
| 773 |
+
const label = displaySymbol(sym);
|
| 774 |
+
const meta = known ? changeMeta(known.change_pct) : null;
|
| 775 |
+
|
| 776 |
+
body.innerHTML = `
|
| 777 |
+
<div class="sm-header">
|
| 778 |
+
<div class="sm-symbol">${escapeHtml(label)}</div>
|
| 779 |
+
<div class="sm-name" id="sm-name">Loading details...</div>
|
| 780 |
+
${known ? `
|
| 781 |
+
<div class="sm-price-row">
|
| 782 |
+
<span class="sm-price">${known.price.toLocaleString()}</span>
|
| 783 |
+
<span class="sm-change ${meta.cls}">${meta.arrow} ${meta.sign}${known.change_pct}%</span>
|
| 784 |
+
<span style="color:var(--muted);font-size:12px">${escapeHtml(known.currency || "USD")}</span>
|
| 785 |
+
</div>` : ""}
|
| 786 |
+
</div>
|
| 787 |
+
<div class="sm-chart-wrap">
|
| 788 |
+
<div class="sm-chart-label"><span>1-Month Price</span><span id="sm-chart-range"></span></div>
|
| 789 |
+
<div id="sm-chart-container"><div class="fi-loading-spinner" style="margin:30px auto"></div></div>
|
| 790 |
+
</div>
|
| 791 |
+
<div class="sm-stats-grid" id="sm-stats-grid">
|
| 792 |
+
<div class="fi-loading" style="grid-column:1/-1;padding:10px 0;">Loading stats...</div>
|
| 793 |
+
</div>
|
| 794 |
+
<div class="sm-footer">Data via Yahoo Finance • may lag live NSE/exchange prices slightly</div>
|
| 795 |
+
`;
|
| 796 |
+
|
| 797 |
+
const [historyRes, infoRes] = await Promise.allSettled([
|
| 798 |
+
fetch(`${FI_API_BASE}/api/yf_history/${encodeURIComponent(sym)}?period=1mo&interval=1d`)
|
| 799 |
+
.then(r => r.ok ? r.json() : Promise.reject(r.status)),
|
| 800 |
+
fetch(`${FI_API_BASE}/api/yf_info/${encodeURIComponent(sym)}`)
|
| 801 |
+
.then(r => r.ok ? r.json() : Promise.reject(r.status)),
|
| 802 |
+
]);
|
| 803 |
+
|
| 804 |
+
// Guard against the modal having been closed/reopened for a different
|
| 805 |
+
// symbol while these were in flight.
|
| 806 |
+
if (!overlay.classList.contains("active") || document.getElementById("sm-name") === null) return;
|
| 807 |
+
|
| 808 |
+
const chartContainer = document.getElementById("sm-chart-container");
|
| 809 |
+
if (historyRes.status === "fulfilled" && Array.isArray(historyRes.value) && historyRes.value.length > 1) {
|
| 810 |
+
const records = historyRes.value;
|
| 811 |
+
chartContainer.innerHTML = renderLineChart(records);
|
| 812 |
+
const first = records[0], last = records[records.length - 1];
|
| 813 |
+
document.getElementById("sm-chart-range").textContent =
|
| 814 |
+
`${formatDate(first.date || first.datetime)} → ${formatDate(last.date || last.datetime)}`;
|
| 815 |
+
} else {
|
| 816 |
+
chartContainer.innerHTML = '<div class="sm-chart-empty">No chart data available for this symbol</div>';
|
| 817 |
+
}
|
| 818 |
+
|
| 819 |
+
const nameEl = document.getElementById("sm-name");
|
| 820 |
+
const statsGrid = document.getElementById("sm-stats-grid");
|
| 821 |
+
if (infoRes.status === "fulfilled" && infoRes.value && !infoRes.value.error) {
|
| 822 |
+
const info = infoRes.value;
|
| 823 |
+
nameEl.textContent = info.longName || info.shortName || label;
|
| 824 |
+
statsGrid.innerHTML = buildStatsGrid(info);
|
| 825 |
+
} else {
|
| 826 |
+
nameEl.textContent = label;
|
| 827 |
+
statsGrid.innerHTML = buildStatsGrid({});
|
| 828 |
+
}
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
function closeSymbolModal() {
|
| 832 |
+
document.getElementById("symbol-modal-overlay").classList.remove("active");
|
| 833 |
+
document.body.style.overflow = "";
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
document.addEventListener("keydown", (e) => {
|
| 837 |
+
if (e.key === "Escape") closeSymbolModal();
|
| 838 |
+
});
|
| 839 |
+
|
| 840 |
+
async function refreshGroup(group) {
|
| 841 |
+
const btn = document.getElementById(`btn-${group}`);
|
| 842 |
+
if (btn.disabled) return;
|
| 843 |
+
|
| 844 |
+
btn.disabled = true;
|
| 845 |
+
btn.classList.add("spinning");
|
| 846 |
+
btn.textContent = "Refreshing...";
|
| 847 |
+
|
| 848 |
+
try {
|
| 849 |
+
const res = await fetch(`${FI_API_BASE}/fastinfo/refresh/${group}`, { method: "POST" });
|
| 850 |
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
| 851 |
+
const data = await res.json();
|
| 852 |
+
|
| 853 |
+
snapshotData[group] = {
|
| 854 |
+
data: data.data,
|
| 855 |
+
failed: data.failed,
|
| 856 |
+
count: data.total,
|
| 857 |
+
fetched: data.fetched,
|
| 858 |
+
refreshed_at: new Date().toISOString(),
|
| 859 |
+
};
|
| 860 |
+
|
| 861 |
+
renderFiTabs();
|
| 862 |
+
renderFi();
|
| 863 |
+
updateTimestamp();
|
| 864 |
+
|
| 865 |
+
} catch (e) {
|
| 866 |
+
alert(`Refresh failed for ${group}: ${e.message}`);
|
| 867 |
+
} finally {
|
| 868 |
+
const freshBtn = document.getElementById(`btn-${group}`);
|
| 869 |
+
if (freshBtn) {
|
| 870 |
+
freshBtn.disabled = false;
|
| 871 |
+
freshBtn.classList.remove("spinning");
|
| 872 |
+
freshBtn.textContent = "🔄 Refresh";
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
async function refreshAll() {
|
| 878 |
+
const btn = document.getElementById("btn-all");
|
| 879 |
+
if (isRefreshingAll) return;
|
| 880 |
+
isRefreshingAll = true;
|
| 881 |
+
btn.disabled = true;
|
| 882 |
+
btn.textContent = "⟳ Refreshing All...";
|
| 883 |
+
|
| 884 |
+
try {
|
| 885 |
+
const res = await fetch(`${FI_API_BASE}/fastinfo/refresh-all`, { method: "POST" });
|
| 886 |
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
| 887 |
+
await loadSnapshot();
|
| 888 |
+
} catch (e) {
|
| 889 |
+
alert(`Refresh all failed: ${e.message}`);
|
| 890 |
+
} finally {
|
| 891 |
+
isRefreshingAll = false;
|
| 892 |
+
btn.disabled = false;
|
| 893 |
+
btn.textContent = "🔄 Refresh All";
|
| 894 |
+
}
|
| 895 |
+
}
|
| 896 |
+
|
| 897 |
+
function timeAgo(isoString) {
|
| 898 |
+
const then = new Date(isoString);
|
| 899 |
+
const now = new Date();
|
| 900 |
+
const sec = Math.floor((now - then) / 1000);
|
| 901 |
+
if (sec < 60) return "just now";
|
| 902 |
+
if (sec < 3600) return `${Math.floor(sec/60)}m ago`;
|
| 903 |
+
if (sec < 86400) return `${Math.floor(sec/3600)}h ago`;
|
| 904 |
+
return `${Math.floor(sec/86400)}d ago`;
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
loadSnapshot();
|
| 908 |
+
setInterval(loadSnapshot, 5 * 60 * 1000);
|
| 909 |
+
|
| 910 |
+
// ═══════════════════════════════════════════════════════════════════════
|
| 911 |
+
// API CONSOLE
|
| 912 |
+
// ═══════════════════════════════════════════════════════════════════════
|
| 913 |
+
const BASE_URL = "https://eshan6704-marketapi2.hf.space";
|
| 914 |
+
let currentEndpoint = "yf_info";
|
| 915 |
+
let currentFormat = "json";
|
| 916 |
+
let lastRows = [];
|
| 917 |
+
let lastKV = null;
|
| 918 |
+
let viewMode = 'table'; // 'table' | 'kv'
|
| 919 |
+
let baseStatusMeta = '';
|
| 920 |
+
|
| 921 |
+
const endpoints = {
|
| 922 |
+
stock_hist: { cat:"NSE", path:"/api/stock_hist/{symbol}", label:"Stock History", params:{ symbol:"TCS", start:"01-01-2024", end:"31-12-2024", series:"EQ" }, desc:"Historical OHLCV from NSE.", options:{ series:["EQ","BE"] } },
|
| 923 |
+
index_chain: { cat:"NSE", path:"/api/index_chain/{symbol}", label:"Index Option Chain", params:{ symbol:"NIFTY", expiry:"31-07-2025" }, desc:"Full raw option chain for an index (NIFTY/BANKNIFTY/FINNIFTY), by expiry. No strike filtering." },
|
| 924 |
+
stock_chain: { cat:"NSE", path:"/api/stock_chain/{symbol}", label:"Stock Option Chain", params:{ symbol:"ITC", expiry:"31-07-2025" }, desc:"Full raw option chain for an equity symbol, by expiry. No strike filtering." },
|
| 925 |
+
indices: { cat:"NSE", path:"/api/indices", label:"All Indices", params:{ filter:"true" }, desc:"All NSE indices (filter=true for curated default list).", options:{ filter:["true","false"] } },
|
| 926 |
+
index_constituents: { cat:"NSE", path:"/api/index_constituents", label:"Index Constituents", params:{ index:"NIFTY 50", noofrecords:"0" }, desc:"Live index constituents + weightage from NSE. noofrecords=0 returns all, or set a number for top N.", options:{ index:["NIFTY 50","NIFTY BANK","NIFTY IT","NIFTY AUTO","NIFTY FMCG","NIFTY PHARMA","NIFTY METAL","NIFTY ENERGY","NIFTY REALTY","NIFTY MEDIA","NIFTY NEXT 50","NIFTY 100","NIFTY 500","NIFTY MIDCAP 150","NIFTY SMALLCAP 250"], noofrecords:["0","10","20","50","100"] } },
|
| 927 |
+
index_pe_pb: { cat:"NSE", path:"/api/index_pe_pb", label:"Index PE/PB", params:{ index_name:"NIFTY 50" }, desc:"Index PE, PB, and dividend yield.", options:{ index_name:["NIFTY 50","NIFTY 500","NIFTY BANK","NIFTY IT"] } },
|
| 928 |
+
index_hist: { cat:"NSE", path:"/api/index_hist", label:"Index History", params:{ index_name:"NIFTY 50", start:"01-01-2024", end:"31-12-2024" }, desc:"Historical index data from niftyindices.com." },
|
| 929 |
+
preopen: { cat:"NSE", path:"/api/preopen", label:"Pre-Open", params:{ key:"NIFTY" }, desc:"Pre-open market data.", options:{ key:["NIFTY","BANKNIFTY","FO","SME","ALL"] } },
|
| 930 |
+
gainers_losers: { cat:"NSE", path:"/api/gainers_losers", label:"Gainers/Losers", params:{ index:"NIFTY", category:"gainers" }, desc:"Top gainers or losers by index.", options:{ index:["NIFTY","BANKNIFTY","NIFTY IT","NIFTY BANK","NIFTY 50"], category:["gainers","losers"] } },
|
| 931 |
+
most_active: { cat:"NSE", path:"/api/most_active", label:"Most Active", params:{ type:"securities", sort:"value" }, desc:"Most active stocks by value or volume.", options:{ type:["securities","etf"], sort:["value","volume"] } },
|
| 932 |
+
sector_watch: { cat:"NSE", path:"/api/sector_watch", label:"Sector Watch", params:{}, desc:"Sector indices snapshot with LTP and % change." },
|
| 933 |
+
circuit_breakers: { cat:"NSE", path:"/api/circuit_breakers", label:"Circuit Breakers", params:{}, desc:"Combined upper+lower circuit hitters." },
|
| 934 |
+
price_band_hitters: { cat:"NSE", path:"/api/price_band_hitters", label:"Price Band Hitters", params:{ band:"both", view:"AllSec" }, desc:"Stocks hitting upper/lower price bands.", options:{ band:["both","upper","lower"], view:["AllSec"] } },
|
| 935 |
+
bhavcopy: { cat:"NSE", path:"/api/bhavcopy/{date}", label:"Bhavcopy", params:{ date:"05-07-2025" }, desc:"Daily bhavcopy with delivery data." },
|
| 936 |
+
delivery_heatmap: { cat:"NSE", path:"/api/delivery_heatmap/{date}", label:"Delivery Heatmap", params:{ date:"05-07-2025" }, desc:"Top 50 stocks by delivery %." },
|
| 937 |
+
oi_spurts: { cat:"NSE", path:"/api/oi_spurts", label:"OI Spurts", params:{ mode:"oi_spurts" }, desc:"Open interest spurts / decrease / price-volume.", options:{ mode:["oi_spurts","oi_decrease","price_volume_spurts"] } },
|
| 938 |
+
fno_lot_sizes: { cat:"NSE", path:"/api/fno_lot_sizes", label:"F&O Lot Sizes", params:{}, desc:"F&O lot sizes from NSE." },
|
| 939 |
+
largedeals: { cat:"NSE", path:"/api/largedeals", label:"Large Deals", params:{ mode:"bulk_deals" }, desc:"Bulk / Block / Short deals.", options:{ mode:["bulk_deals","block_deals","short_deals"] } },
|
| 940 |
+
bulkdeals: { cat:"NSE", path:"/api/bulkdeals", label:"Bulk Deals", params:{}, desc:"Bulk deals from NSE archives." },
|
| 941 |
+
blockdeals: { cat:"NSE", path:"/api/blockdeals", label:"Block Deals", params:{}, desc:"Block deals from NSE archives." },
|
| 942 |
+
events: { cat:"NSE", path:"/api/events", label:"Events Calendar", params:{}, desc:"Corporate events calendar." },
|
| 943 |
+
nse_results: { cat:"NSE", path:"/api/nse_results", label:"NSE Results", params:{ index:"equities", period:"Quarterly" }, desc:"Financial results.", options:{ index:["equities","debt","sme"], period:["Quarterly","Annual","Half-Yearly","Others"] } },
|
| 944 |
+
nse_holidays: { cat:"NSE", path:"/api/nse_holidays", label:"NSE Holidays", params:{ type:"trading" }, desc:"NSE trading/clearing holidays.", options:{ type:["trading","clearing"] } },
|
| 945 |
+
fiidii: { cat:"NSE", path:"/api/fiidii", label:"FII/DII", params:{}, desc:"FII/DII trading activity." },
|
| 946 |
+
market_status: { cat:"NSE", path:"/api/market_status", label:"Market Status", params:{}, desc:"Current market open/close status." },
|
| 947 |
+
eq_symbols: { cat:"NSE", path:"/api/eq_symbols", label:"All Symbols", params:{}, desc:"All NSE equity symbols." },
|
| 948 |
+
highlow: { cat:"NSE", path:"/api/highlow/{date_str}", label:"Index High/Low", params:{ date_str:"05-07-2025" }, desc:"Index high/low data." },
|
| 949 |
+
stock_highlow: { cat:"NSE", path:"/api/stock_highlow/{date_str}", label:"52W High/Low", params:{ date_str:"05-07-2025" }, desc:"52-week high/low stocks." },
|
| 950 |
+
today_str: { cat:"NSE", path:"/api/today_str", label:"Today", params:{ fmt:"%d-%m-%Y" }, desc:"Today's date." },
|
| 951 |
+
last_trading_day: { cat:"NSE", path:"/api/last_trading_day", label:"Last Trading Day", params:{}, desc:"Last trading day (handles weekends)." },
|
| 952 |
+
|
| 953 |
+
yf_info: { cat:"Yahoo", path:"/api/yf_info/{symbol}", label:"Company Info", params:{ symbol:"ITC.NS" }, desc:"Complete company info (100+ fields)." },
|
| 954 |
+
yf_history: { cat:"Yahoo", path:"/api/yf_history/{symbol}", label:"History", params:{ symbol:"ITC.NS", period:"1y", interval:"1d" }, desc:"Historical OHLCV.", options:{ period:["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"], interval:["1m","2m","5m","15m","30m","60m","90m","1h","1d","5d","1wk","1mo","3mo"] } },
|
| 955 |
+
yf_intraday: { cat:"Yahoo", path:"/api/yf_intraday/{symbol}", label:"Intraday", params:{ symbol:"ITC.NS", interval:"5m", period:"5d" }, desc:"Intraday candles (max 60 days for <1d intervals).", options:{ interval:["1m","2m","5m","15m","30m","60m","90m","1h"], period:["1d","5d","1mo","3mo"] } },
|
| 956 |
+
yf_daily_trend: { cat:"Yahoo", path:"/api/yf_daily_trend/{symbol}", label:"Daily Trend", params:{ symbol:"ITC.NS", period:"1mo" }, desc:"OHLCV + SMA(5/10/20) + trend direction.", options:{ period:["1mo","3mo","6mo","1y"] } },
|
| 957 |
+
yf_actions: { cat:"Yahoo", path:"/api/yf_actions/{symbol}", label:"Actions", params:{ symbol:"ITC.NS" }, desc:"Dividends + splits + capital gains, all combined in one table." },
|
| 958 |
+
yf_income_stmt: { cat:"Yahoo", path:"/api/yf_income_stmt/{symbol}", label:"Income Statement", params:{ symbol:"ITC.NS", quarterly:"false" }, desc:"Revenue, Gross Profit, Net Income, EBITDA, EPS.", options:{ quarterly:["false","true"] } },
|
| 959 |
+
yf_balance_sheet: { cat:"Yahoo", path:"/api/yf_balance_sheet/{symbol}", label:"Balance Sheet", params:{ symbol:"ITC.NS", quarterly:"false" }, desc:"Assets, Liabilities, Equity, Cash, Debt.", options:{ quarterly:["false","true"] } },
|
| 960 |
+
yf_cashflow: { cat:"Yahoo", path:"/api/yf_cashflow/{symbol}", label:"Cash Flow", params:{ symbol:"ITC.NS", quarterly:"false" }, desc:"Operating / Investing / Financing CF, FCF.", options:{ quarterly:["false","true"] } },
|
| 961 |
+
yf_all_financials: { cat:"Yahoo", path:"/api/yf_all_financials/{symbol}", label:"All Financials", params:{ symbol:"ITC.NS" }, desc:"All 6 statements: annual + quarterly. JSON returns them as separate tables; CSV stacks all of them with a _source column." },
|
| 962 |
+
yf_earnings: { cat:"Yahoo", path:"/api/yf_earnings/{symbol}", label:"Earnings", params:{ symbol:"ITC.NS", quarterly:"false" }, desc:"Earnings and revenue history.", options:{ quarterly:["false","true"] } },
|
| 963 |
+
yf_estimates: { cat:"Yahoo", path:"/api/yf_estimates/{symbol}", label:"Analyst Estimates", params:{ symbol:"AAPL" }, desc:"Earnings/revenue/EPS-trend/EPS-revisions/growth estimates. JSON returns them as separate tables; CSV stacks all of them with a _source column." },
|
| 964 |
+
yf_recommendations: { cat:"Yahoo", path:"/api/yf_recommendations/{symbol}", label:"Recommendations", params:{ symbol:"ITC.NS" }, desc:"Analyst recommendations history." },
|
| 965 |
+
yf_analyst: { cat:"Yahoo", path:"/api/yf_analyst/{symbol}", label:"Analyst Snapshot", params:{ symbol:"AAPL" }, desc:"Price targets, recommendation summary, and recent upgrades/downgrades. JSON returns all 3 separately; CSV stacks them with a _source column." },
|
| 966 |
+
yf_holders: { cat:"Yahoo", path:"/api/yf_holders/{symbol}", label:"Holders", params:{ symbol:"ITC.NS" }, desc:"Major/institutional/mutual-fund holders + insider transactions/purchases/roster. JSON returns all 6 as separate tables; CSV stacks all of them with a _source column." }
|
| 967 |
+
};
|
| 968 |
+
|
| 969 |
+
// ── Last valid trading day: skip Sat/Sun, skip NSE holidays, and if it's
|
| 970 |
+
// before 18:00 IST treat today's data as not-yet-settled and step back one. ──
|
| 971 |
+
|
| 972 |
+
const pad2 = n => String(n).padStart(2, '0');
|
| 973 |
+
const dateKey = d => d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate());
|
| 974 |
+
const formatNSE = d => pad2(d.getDate()) + '-' + pad2(d.getMonth() + 1) + '-' + d.getFullYear();
|
| 975 |
+
|
| 976 |
+
const MONTH_MAP = { Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11 };
|
| 977 |
+
|
| 978 |
+
function parseFlexibleDate(str){
|
| 979 |
+
if (!str) return null;
|
| 980 |
+
str = String(str).trim();
|
| 981 |
+
let m = str.match(/^(\d{1,2})-([A-Za-z]{3})-(\d{4})$/); // 26-Jan-2026
|
| 982 |
+
if (m) return new Date(+m[3], MONTH_MAP[m[2]], +m[1]);
|
| 983 |
+
m = str.match(/^(\d{1,2})-(\d{1,2})-(\d{4})$/); // 26-01-2026
|
| 984 |
+
if (m) return new Date(+m[3], +m[2] - 1, +m[1]);
|
| 985 |
+
m = str.match(/^(\d{4})-(\d{1,2})-(\d{1,2})/); // 2026-01-26
|
| 986 |
+
if (m) return new Date(+m[1], +m[2] - 1, +m[3]);
|
| 987 |
+
const d = new Date(str);
|
| 988 |
+
return isNaN(d) ? null : d;
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
// In-memory only (session cache) — no browser storage per artifact rules.
|
| 992 |
+
// Populated once per page load, reused for every default-date computation after that.
|
| 993 |
+
let holidaySet = null;
|
| 994 |
+
|
| 995 |
+
async function loadHolidaySet(){
|
| 996 |
+
if (holidaySet) return holidaySet;
|
| 997 |
+
holidaySet = new Set();
|
| 998 |
+
try {
|
| 999 |
+
const resp = await fetch(BASE_URL + '/api/nse_holidays?type=trading&format=json');
|
| 1000 |
+
if (resp.ok){
|
| 1001 |
+
const data = await resp.json();
|
| 1002 |
+
(Array.isArray(data) ? data : []).forEach(rec => {
|
| 1003 |
+
const raw = rec.tradingDate || rec.trading_date || rec.date || rec.holidayDate || rec.Date || '';
|
| 1004 |
+
const d = parseFlexibleDate(raw);
|
| 1005 |
+
if (d) holidaySet.add(dateKey(d));
|
| 1006 |
+
});
|
| 1007 |
+
}
|
| 1008 |
+
} catch (e){
|
| 1009 |
+
console.warn('NSE holiday fetch failed — falling back to weekend-only skip.', e);
|
| 1010 |
+
}
|
| 1011 |
+
return holidaySet;
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
function isWeekend(d){ const day = d.getDay(); return day === 0 || day === 6; }
|
| 1015 |
+
function isHoliday(d){ return holidaySet && holidaySet.has(dateKey(d)); }
|
| 1016 |
+
|
| 1017 |
+
function computeLastValidTradingDay(){
|
| 1018 |
+
// "now" in IST regardless of the browser's own timezone
|
| 1019 |
+
const nowIST = new Date(new Date().toLocaleString('en-US', { timeZone: 'Asia/Kolkata' }));
|
| 1020 |
+
let candidate = new Date(nowIST.getFullYear(), nowIST.getMonth(), nowIST.getDate());
|
| 1021 |
+
|
| 1022 |
+
// Before 18:00 IST → today's session data isn't settled yet, use the prior day
|
| 1023 |
+
if (nowIST.getHours() < 18) candidate.setDate(candidate.getDate() - 1);
|
| 1024 |
+
|
| 1025 |
+
// Walk back over weekends and NSE holidays
|
| 1026 |
+
let guard = 0;
|
| 1027 |
+
while ((isWeekend(candidate) || isHoliday(candidate)) && guard < 30){
|
| 1028 |
+
candidate.setDate(candidate.getDate() - 1);
|
| 1029 |
+
guard++;
|
| 1030 |
+
}
|
| 1031 |
+
return candidate;
|
| 1032 |
+
}
|
| 1033 |
+
|
| 1034 |
+
// NSE's weekly expiry weekday — edit this single line if NSE changes it again.
|
| 1035 |
+
// 0=Sun, 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri, 6=Sat. Currently Tuesday.
|
| 1036 |
+
const EXPIRY_WEEKDAY = 2;
|
| 1037 |
+
|
| 1038 |
+
function nextExpiryDay(fromDate){
|
| 1039 |
+
const d = new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate());
|
| 1040 |
+
let diff = (EXPIRY_WEEKDAY - d.getDay() + 7) % 7;
|
| 1041 |
+
if (diff === 0) diff = 7; // today is expiry day → use next week's, avoids picking an already-expired same-day contract late in the session
|
| 1042 |
+
d.setDate(d.getDate() + diff);
|
| 1043 |
+
return d;
|
| 1044 |
+
}
|
| 1045 |
+
|
| 1046 |
+
function applyDefaultDates(){
|
| 1047 |
+
const lastValid = computeLastValidTradingDay();
|
| 1048 |
+
const NSE_LAST_VALID = formatNSE(lastValid);
|
| 1049 |
+
const NSE_JAN1 = '01-01-' + new Date().getFullYear();
|
| 1050 |
+
const NSE_NEXT_EXPIRY = formatNSE(nextExpiryDay(new Date()));
|
| 1051 |
+
|
| 1052 |
+
Object.keys(endpoints).forEach(key => {
|
| 1053 |
+
const p = endpoints[key].params;
|
| 1054 |
+
if ('start' in p) p.start = NSE_JAN1;
|
| 1055 |
+
if ('end' in p) p.end = NSE_LAST_VALID;
|
| 1056 |
+
if ('date' in p) p.date = NSE_LAST_VALID;
|
| 1057 |
+
if ('date_str' in p) p.date_str = NSE_LAST_VALID;
|
| 1058 |
+
if ('expiry' in p) p.expiry = NSE_NEXT_EXPIRY;
|
| 1059 |
+
});
|
| 1060 |
+
}
|
| 1061 |
+
|
| 1062 |
+
function buildSelect(){
|
| 1063 |
+
const sel = document.getElementById('endpoint-select');
|
| 1064 |
+
const groups = {};
|
| 1065 |
+
Object.keys(endpoints).forEach(key => {
|
| 1066 |
+
const e = endpoints[key];
|
| 1067 |
+
if (!groups[e.cat]) groups[e.cat] = [];
|
| 1068 |
+
groups[e.cat].push(key);
|
| 1069 |
+
});
|
| 1070 |
+
let html = '';
|
| 1071 |
+
let total = 0;
|
| 1072 |
+
Object.keys(groups).forEach(cat => {
|
| 1073 |
+
html += `<optgroup label="${cat}">`;
|
| 1074 |
+
groups[cat].forEach(key => {
|
| 1075 |
+
html += `<option value="${key}">${endpoints[key].label}</option>`;
|
| 1076 |
+
total++;
|
| 1077 |
+
});
|
| 1078 |
+
html += `</optgroup>`;
|
| 1079 |
+
});
|
| 1080 |
+
sel.innerHTML = html;
|
| 1081 |
+
sel.value = currentEndpoint;
|
| 1082 |
+
document.getElementById('ep-count').textContent = total + ' endpoints';
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
function onEndpointChange(){
|
| 1086 |
+
currentEndpoint = document.getElementById('endpoint-select').value;
|
| 1087 |
+
renderParams();
|
| 1088 |
+
updateURL();
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
let paramsTouched = false;
|
| 1092 |
+
function markTouched(){ paramsTouched = true; updateURL(); }
|
| 1093 |
+
|
| 1094 |
+
function renderParams(){
|
| 1095 |
+
paramsTouched = false;
|
| 1096 |
+
const config = endpoints[currentEndpoint];
|
| 1097 |
+
const row = document.getElementById('param-row');
|
| 1098 |
+
document.getElementById('info-desc').textContent = config.desc;
|
| 1099 |
+
const keys = Object.keys(config.params);
|
| 1100 |
+
if (keys.length === 0){
|
| 1101 |
+
row.innerHTML = '<span class="none">No parameters required for this endpoint.</span>';
|
| 1102 |
+
return;
|
| 1103 |
+
}
|
| 1104 |
+
let html = '';
|
| 1105 |
+
keys.forEach(key => {
|
| 1106 |
+
const isPath = config.path.indexOf('{'+key+'}') !== -1;
|
| 1107 |
+
const val = config.params[key];
|
| 1108 |
+
html += `<div class="pfield ${isPath ? 'path' : ''}"><label>${key}</label>`;
|
| 1109 |
+
if (config.options && config.options[key]){
|
| 1110 |
+
html += `<select id="param-${key}" onchange="markTouched()">`;
|
| 1111 |
+
config.options[key].forEach(opt => {
|
| 1112 |
+
html += `<option value="${opt}" ${opt===val?'selected':''}>${opt}</option>`;
|
| 1113 |
+
});
|
| 1114 |
+
html += `</select>`;
|
| 1115 |
+
} else {
|
| 1116 |
+
html += `<input type="text" id="param-${key}" value="${val}" oninput="markTouched()">`;
|
| 1117 |
+
}
|
| 1118 |
+
html += `</div>`;
|
| 1119 |
+
});
|
| 1120 |
+
row.innerHTML = html;
|
| 1121 |
+
}
|
| 1122 |
+
|
| 1123 |
+
function setFormat(fmt){
|
| 1124 |
+
currentFormat = fmt;
|
| 1125 |
+
document.querySelectorAll('#format-seg button').forEach(b => b.classList.toggle('active', b.dataset.fmt === fmt));
|
| 1126 |
+
updateURL();
|
| 1127 |
+
}
|
| 1128 |
+
|
| 1129 |
+
function toggleInfo(){
|
| 1130 |
+
const panel = document.getElementById('info-panel');
|
| 1131 |
+
const btn = document.getElementById('info-toggle');
|
| 1132 |
+
const isOpen = panel.classList.toggle('open');
|
| 1133 |
+
btn.classList.toggle('on', isOpen);
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
function buildURL(){
|
| 1137 |
+
const config = endpoints[currentEndpoint];
|
| 1138 |
+
let path = config.path;
|
| 1139 |
+
const query = [];
|
| 1140 |
+
Object.keys(config.params).forEach(key => {
|
| 1141 |
+
const input = document.getElementById('param-'+key);
|
| 1142 |
+
const val = input ? input.value : config.params[key];
|
| 1143 |
+
if (path.indexOf('{'+key+'}') !== -1){
|
| 1144 |
+
path = path.replace('{'+key+'}', encodeURIComponent(val));
|
| 1145 |
+
} else if (val !== '' && val !== undefined) {
|
| 1146 |
+
query.push(key + '=' + encodeURIComponent(val));
|
| 1147 |
+
}
|
| 1148 |
+
});
|
| 1149 |
+
query.push('format=' + currentFormat);
|
| 1150 |
+
let url = BASE_URL + path;
|
| 1151 |
+
if (query.length) url += '?' + query.join('&');
|
| 1152 |
+
return url;
|
| 1153 |
+
}
|
| 1154 |
+
|
| 1155 |
+
function updateURL(){
|
| 1156 |
+
const url = buildURL();
|
| 1157 |
+
document.getElementById('url-text').textContent = url;
|
| 1158 |
+
let curl = 'curl "' + url + '"';
|
| 1159 |
+
if (currentFormat === 'csv') curl += ' -o ' + currentEndpoint + '_output.csv';
|
| 1160 |
+
document.getElementById('curl-display').textContent = curl;
|
| 1161 |
+
}
|
| 1162 |
+
|
| 1163 |
+
function copyURL(){
|
| 1164 |
+
navigator.clipboard.writeText(document.getElementById('url-text').textContent.trim()).then(()=>toast('URL copied'));
|
| 1165 |
+
}
|
| 1166 |
+
function copyCurl(){
|
| 1167 |
+
navigator.clipboard.writeText(document.getElementById('curl-display').textContent.trim()).then(()=>toast('cURL copied'));
|
| 1168 |
+
}
|
| 1169 |
+
function toast(msg){
|
| 1170 |
+
const t = document.createElement('div');
|
| 1171 |
+
t.textContent = msg;
|
| 1172 |
+
t.style.cssText = 'position:fixed;bottom:20px;right:20px;background:#0d9488;color:#fff;padding:10px 18px;border-radius:8px;font-size:0.85em;font-weight:600;z-index:1000;box-shadow:0 6px 20px rgba(13,148,136,0.35);';
|
| 1173 |
+
document.body.appendChild(t);
|
| 1174 |
+
setTimeout(()=>{ t.style.opacity='0'; t.style.transition='opacity .3s'; setTimeout(()=>t.remove(),300); }, 1800);
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
function testAPI(){
|
| 1178 |
+
const url = buildURL();
|
| 1179 |
+
setStatus('idle', 'Fetching…');
|
| 1180 |
+
document.getElementById('search-wrap').style.display = 'none';
|
| 1181 |
+
document.getElementById('response-wrap').innerHTML = '<div class="empty-state"><div class="big">◌</div><div>Loading…</div></div>';
|
| 1182 |
+
|
| 1183 |
+
const t0 = Date.now();
|
| 1184 |
+
fetch(url).then(resp => {
|
| 1185 |
+
const ms = Date.now() - t0;
|
| 1186 |
+
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' ' + resp.statusText);
|
| 1187 |
+
return (currentFormat === 'csv' ? resp.text() : resp.json()).then(data => ({ data, ms, status: resp.status }));
|
| 1188 |
+
}).then(({data, ms, status}) => {
|
| 1189 |
+
setStatus('ok', status + ' · ' + ms + 'ms');
|
| 1190 |
+
if (currentFormat === 'csv') renderCSV(data);
|
| 1191 |
+
else renderJSON(data);
|
| 1192 |
+
}).catch(err => {
|
| 1193 |
+
setStatus('err', err.message);
|
| 1194 |
+
document.getElementById('response-wrap').innerHTML = '<div class="empty-state" style="color:#dc2626"><div class="big">✕</div><div>' + escapeHtml(err.message) + '</div></div>';
|
| 1195 |
+
});
|
| 1196 |
+
}
|
| 1197 |
+
|
| 1198 |
+
function setStatus(type, meta){
|
| 1199 |
+
const pill = document.getElementById('status-pill');
|
| 1200 |
+
pill.className = 'pill ' + (type === 'ok' ? 'ok' : type === 'err' ? 'err' : 'idle');
|
| 1201 |
+
pill.textContent = type === 'ok' ? 'success' : type === 'err' ? 'error' : 'idle';
|
| 1202 |
+
baseStatusMeta = meta || '';
|
| 1203 |
+
document.getElementById('status-meta').textContent = baseStatusMeta;
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
function escapeHtml(s){
|
| 1207 |
+
return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
| 1208 |
+
}
|
| 1209 |
+
|
| 1210 |
+
function renderJSON(data){
|
| 1211 |
+
if (Array.isArray(data) && data.length && typeof data[0] === 'object' && data[0] !== null){
|
| 1212 |
+
renderTable(data);
|
| 1213 |
+
} else if (data && typeof data === 'object' && !Array.isArray(data)){
|
| 1214 |
+
const values = Object.values(data);
|
| 1215 |
+
const isMultiTable = values.length && values.every(v => Array.isArray(v));
|
| 1216 |
+
if (isMultiTable){
|
| 1217 |
+
const firstKey = Object.keys(data).find(k => Array.isArray(data[k]) && data[k].length);
|
| 1218 |
+
if (firstKey) { renderTable(data[firstKey]); return; }
|
| 1219 |
+
}
|
| 1220 |
+
renderKV(data);
|
| 1221 |
+
} else {
|
| 1222 |
+
document.getElementById('response-wrap').innerHTML = '<pre class="raw-json">' + escapeHtml(JSON.stringify(data, null, 2)) + '</pre>';
|
| 1223 |
+
}
|
| 1224 |
+
}
|
| 1225 |
+
|
| 1226 |
+
function renderKV(obj){
|
| 1227 |
+
lastKV = obj;
|
| 1228 |
+
viewMode = 'kv';
|
| 1229 |
+
drawKV(obj);
|
| 1230 |
+
const filterInput = document.getElementById('table-filter');
|
| 1231 |
+
document.getElementById('search-wrap').style.display = 'flex';
|
| 1232 |
+
filterInput.value = '';
|
| 1233 |
+
filterInput.placeholder = 'type to filter fields…';
|
| 1234 |
+
}
|
| 1235 |
+
|
| 1236 |
+
function drawKV(obj){
|
| 1237 |
+
const keys = Object.keys(obj);
|
| 1238 |
+
let html = '<table class="kv-table"><tbody>';
|
| 1239 |
+
keys.forEach(k => {
|
| 1240 |
+
let v = obj[k];
|
| 1241 |
+
if (v !== null && typeof v === 'object') v = JSON.stringify(v);
|
| 1242 |
+
html += `<tr><td>${escapeHtml(k)}</td><td>${escapeHtml(v === null || v === undefined ? '—' : v)}</td></tr>`;
|
| 1243 |
+
});
|
| 1244 |
+
html += '</tbody></table>';
|
| 1245 |
+
document.getElementById('response-wrap').innerHTML = html;
|
| 1246 |
+
document.getElementById('status-meta').textContent = baseStatusMeta + ' · ' + keys.length + ' fields';
|
| 1247 |
+
}
|
| 1248 |
+
|
| 1249 |
+
function renderTable(rows){
|
| 1250 |
+
// A single row (e.g. company info, market status) renders far better as a
|
| 1251 |
+
// vertical field:value list than as a table with 100+ columns and 1 row.
|
| 1252 |
+
if (rows.length === 1){
|
| 1253 |
+
renderKV(rows[0]);
|
| 1254 |
+
return;
|
| 1255 |
+
}
|
| 1256 |
+
lastRows = rows;
|
| 1257 |
+
viewMode = 'table';
|
| 1258 |
+
const cols = Array.from(rows.reduce((set, r) => { Object.keys(r).forEach(k => set.add(k)); return set; }, new Set()));
|
| 1259 |
+
drawTable(rows, cols);
|
| 1260 |
+
const filterInput = document.getElementById('table-filter');
|
| 1261 |
+
document.getElementById('search-wrap').style.display = 'flex';
|
| 1262 |
+
filterInput.value = '';
|
| 1263 |
+
filterInput.placeholder = 'type to filter rows…';
|
| 1264 |
+
}
|
| 1265 |
+
|
| 1266 |
+
function drawTable(rows, cols){
|
| 1267 |
+
let html = '<table class="data-grid"><thead><tr>';
|
| 1268 |
+
cols.forEach(c => html += `<th>${escapeHtml(c)}</th>`);
|
| 1269 |
+
html += '</tr></thead><tbody>';
|
| 1270 |
+
rows.forEach(r => {
|
| 1271 |
+
html += '<tr>';
|
| 1272 |
+
cols.forEach(c => {
|
| 1273 |
+
let v = r[c];
|
| 1274 |
+
const isNum = typeof v === 'number';
|
| 1275 |
+
let cls = isNum ? 'num' : '';
|
| 1276 |
+
if (isNum && c.toLowerCase().includes('change')) cls += v > 0 ? ' pos' : v < 0 ? ' neg' : '';
|
| 1277 |
+
if (v === null || v === undefined) v = '';
|
| 1278 |
+
else if (typeof v === 'object') v = JSON.stringify(v);
|
| 1279 |
+
html += `<td class="${cls}">${escapeHtml(v)}</td>`;
|
| 1280 |
+
});
|
| 1281 |
+
html += '</tr>';
|
| 1282 |
+
});
|
| 1283 |
+
html += '</tbody></table>';
|
| 1284 |
+
document.getElementById('response-wrap').innerHTML = html;
|
| 1285 |
+
document.getElementById('status-meta').textContent = baseStatusMeta + ' · ' + rows.length + ' rows';
|
| 1286 |
+
}
|
| 1287 |
+
|
| 1288 |
+
function filterTable(){
|
| 1289 |
+
const q = document.getElementById('table-filter').value.toLowerCase();
|
| 1290 |
+
if (viewMode === 'kv'){
|
| 1291 |
+
if (!q){ drawKV(lastKV); return; }
|
| 1292 |
+
const filtered = {};
|
| 1293 |
+
Object.keys(lastKV).forEach(k => {
|
| 1294 |
+
const v = lastKV[k];
|
| 1295 |
+
const vStr = v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v ?? '');
|
| 1296 |
+
if (k.toLowerCase().includes(q) || vStr.toLowerCase().includes(q)) filtered[k] = v;
|
| 1297 |
+
});
|
| 1298 |
+
drawKV(filtered);
|
| 1299 |
+
return;
|
| 1300 |
+
}
|
| 1301 |
+
if (!q){ renderTable(lastRows); return; }
|
| 1302 |
+
const cols = Array.from(lastRows.reduce((set, r) => { Object.keys(r).forEach(k => set.add(k)); return set; }, new Set()));
|
| 1303 |
+
const filtered = lastRows.filter(r => cols.some(c => String(r[c] ?? '').toLowerCase().includes(q)));
|
| 1304 |
+
drawTable(filtered, cols);
|
| 1305 |
+
}
|
| 1306 |
+
|
| 1307 |
+
function parseCSV(text){
|
| 1308 |
+
const lines = text.trim().split(/\r?\n/);
|
| 1309 |
+
if (!lines.length) return [];
|
| 1310 |
+
const splitLine = line => {
|
| 1311 |
+
const out = []; let cur=''; let inQ=false;
|
| 1312 |
+
for (let i=0;i<line.length;i++){
|
| 1313 |
+
const ch = line[i];
|
| 1314 |
+
if (ch === '"'){ inQ = !inQ; }
|
| 1315 |
+
else if (ch === ',' && !inQ){ out.push(cur); cur=''; }
|
| 1316 |
+
else cur += ch;
|
| 1317 |
+
}
|
| 1318 |
+
out.push(cur);
|
| 1319 |
+
return out;
|
| 1320 |
+
};
|
| 1321 |
+
const headers = splitLine(lines[0]);
|
| 1322 |
+
return lines.slice(1).filter(l => l.trim().length).map(line => {
|
| 1323 |
+
const vals = splitLine(line);
|
| 1324 |
+
const obj = {};
|
| 1325 |
+
headers.forEach((h,i) => obj[h] = vals[i] !== undefined ? vals[i] : '');
|
| 1326 |
+
return obj;
|
| 1327 |
+
});
|
| 1328 |
+
}
|
| 1329 |
+
|
| 1330 |
+
function renderCSV(text){
|
| 1331 |
+
if (!text || !text.trim()){
|
| 1332 |
+
document.getElementById('response-wrap').innerHTML = '<div class="empty-state"><div class="big">—</div><div>No data returned</div></div>';
|
| 1333 |
+
document.getElementById('search-wrap').style.display = 'none';
|
| 1334 |
+
return;
|
| 1335 |
+
}
|
| 1336 |
+
const rows = parseCSV(text);
|
| 1337 |
+
if (!rows.length){
|
| 1338 |
+
document.getElementById('response-wrap').innerHTML = '<pre class="raw-json">' + escapeHtml(text) + '</pre>';
|
| 1339 |
+
document.getElementById('search-wrap').style.display = 'none';
|
| 1340 |
+
return;
|
| 1341 |
+
}
|
| 1342 |
+
renderTable(rows);
|
| 1343 |
+
}
|
| 1344 |
+
|
| 1345 |
+
// ── Init ──
|
| 1346 |
+
// Paint immediately with weekend-only defaults so the UI isn't blocked on the network,
|
| 1347 |
+
// then refine to the holiday-aware last trading day once the holiday list arrives
|
| 1348 |
+
// (re-render only if the person hasn't already started editing that endpoint's fields).
|
| 1349 |
+
applyDefaultDates();
|
| 1350 |
+
buildSelect();
|
| 1351 |
+
renderParams();
|
| 1352 |
+
updateURL();
|
| 1353 |
+
|
| 1354 |
+
loadHolidaySet().then(() => {
|
| 1355 |
+
applyDefaultDates();
|
| 1356 |
+
if (!paramsTouched){
|
| 1357 |
+
renderParams();
|
| 1358 |
+
updateURL();
|
| 1359 |
+
}
|
| 1360 |
+
});
|
| 1361 |
+
</script>
|
| 1362 |
+
</body>
|
| 1363 |
+
</html>
|