/** * 策略说明:三所 MD + 开仓检查清单 JSON。 */ (function () { const page = document.getElementById("page-strategy"); if (!page) return; const tabsEl = document.getElementById("strategy-tabs"); const statusEl = document.getElementById("strategy-load-status"); const docBody = document.getElementById("strategy-doc-body"); const docSource = document.getElementById("strategy-doc-source"); const checklistTitle = document.getElementById("strategy-checklist-title"); const checklistBody = document.getElementById("strategy-checklist-body"); const footnotesEl = document.getElementById("strategy-checklist-footnotes"); const printTitle = document.getElementById("strategy-print-title"); const printMeta = document.getElementById("strategy-print-meta"); const printHeader = document.getElementById("strategy-print-header"); const btnPrint = document.getElementById("strategy-btn-print"); const btnDownload = document.getElementById("strategy-btn-download"); let activeKey = "binance"; let tabsMeta = []; let cache = {}; let bound = false; async function apiFetch(url, opts) { const r = await fetch(url, { credentials: "same-origin", ...(opts || {}) }); const ct = (r.headers.get("content-type") || "").toLowerCase(); if (ct.includes("application/json")) { const data = await r.json(); if (!r.ok) throw new Error((data && data.msg) || r.statusText || "请求失败"); return data; } if (!r.ok) throw new Error(r.statusText || "请求失败"); return r; } function esc(s) { return String(s ?? "") .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); } function renderTabs() { if (!tabsEl) return; tabsEl.innerHTML = tabsMeta .map( (t) => `` ) .join(""); tabsEl.querySelectorAll(".strategy-tab").forEach((btn) => { btn.addEventListener("click", () => { const key = btn.getAttribute("data-key"); if (!key || key === activeKey) return; activeKey = key; renderTabs(); void loadExchange(key); }); }); } function renderChecklist(checklist) { const cl = checklist || {}; if (checklistTitle) { checklistTitle.textContent = cl.title || "开仓检查清单"; } if (!checklistBody) return; const groups = cl.groups || []; if (!groups.length) { checklistBody.innerHTML = '
暂无检查清单
'; } else { checklistBody.innerHTML = groups .map((grp) => { const items = (grp.items || []) .map((item) => `