/** * 策略说明:三所 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 docCard = page.querySelector(".strategy-doc-card"); const checklistCard = page.querySelector(".strategy-checklist-card"); const checklistTitle = document.getElementById("strategy-checklist-title"); const checklistBody = document.getElementById("strategy-checklist-body"); const footnotesEl = document.getElementById("strategy-checklist-footnotes"); const btnPrintDoc = document.getElementById("strategy-btn-print-doc"); const btnPrintChecklist = document.getElementById("strategy-btn-print-checklist"); const btnDownload = document.getElementById("strategy-btn-download"); let activeKey = "binance"; let tabsMeta = []; let cache = {}; let bound = false; let heightSyncRaf = 0; 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 syncDocCardHeight() { if (!docCard || !checklistCard || window.matchMedia("(max-width: 960px)").matches) { if (docCard) docCard.style.height = ""; return; } docCard.style.height = `${checklistCard.offsetHeight}px`; } function scheduleHeightSync() { if (heightSyncRaf) cancelAnimationFrame(heightSyncRaf); heightSyncRaf = requestAnimationFrame(() => { heightSyncRaf = 0; syncDocCardHeight(); }); } 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 || {}; const title = cl.title || "开仓检查清单"; if (checklistTitle) checklistTitle.textContent = 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) => `