+93
-23
@@ -366,8 +366,7 @@
|
||||
'">' +
|
||||
'<div class="cond-inst' +
|
||||
(disabled ? " is-off" : "") +
|
||||
'">' +
|
||||
'<label class="cond-inst-head" title="' +
|
||||
'" title="' +
|
||||
escapeHtml(tip) +
|
||||
'">' +
|
||||
'<input type="checkbox" name="cf-inst" value="' +
|
||||
@@ -376,15 +375,11 @@
|
||||
(disabled ? " disabled" : "") +
|
||||
(checked ? " checked" : "") +
|
||||
">" +
|
||||
'<div class="cond-inst-main">' +
|
||||
'<span class="cond-inst-name">' +
|
||||
escapeHtml(it.name || "") +
|
||||
"</span>" +
|
||||
'<span class="cond-inst-tag">' +
|
||||
escapeHtml(tip) +
|
||||
"</span>" +
|
||||
"</label>" +
|
||||
'<div class="cond-inst-body">' +
|
||||
'<span class="cond-inst-fund-line">' +
|
||||
'<span class="cond-inst-fund-line" data-xfer-toggle="1">' +
|
||||
'<span class="cond-inst-funds cond-inst-funds--trading" title="交易账户可用">交易 ' +
|
||||
escapeHtml(fmtTradingU(it.trading_usdt)) +
|
||||
"</span>" +
|
||||
@@ -392,6 +387,10 @@
|
||||
escapeHtml(fmtTradingU(it.funding_usdt)) +
|
||||
"</span>" +
|
||||
"</span>" +
|
||||
"</div>" +
|
||||
'<span class="cond-inst-tag">' +
|
||||
escapeHtml(tip) +
|
||||
"</span>" +
|
||||
'<span class="cond-inst-actions">' +
|
||||
'<button type="button" class="btn btn-secondary btn-sm cond-inst-xfer" data-inst-id="' +
|
||||
escapeHtml(id) +
|
||||
@@ -409,7 +408,6 @@
|
||||
">划入资金</button>" +
|
||||
"</span>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
);
|
||||
}
|
||||
@@ -444,8 +442,10 @@
|
||||
const list = (allCandidates || []).filter(function (it) {
|
||||
return candidateMatchesUnderlying(it, uly);
|
||||
});
|
||||
const meta = document.getElementById("cf-inst-meta");
|
||||
if (!(allCandidates || []).length) {
|
||||
box.innerHTML = '<span class="muted">暂无启用实例</span>';
|
||||
if (meta) meta.textContent = "暂无实例";
|
||||
return;
|
||||
}
|
||||
if (!list.length) {
|
||||
@@ -453,8 +453,13 @@
|
||||
'<span class="muted">当前标的 ' +
|
||||
escapeHtml(uly) +
|
||||
" 下暂无匹配客户端(请确认实例 OKX_OPTIONS_UNDERLYINGS)</span>";
|
||||
if (meta) meta.textContent = "当前 " + uly + " · 可选 0";
|
||||
return;
|
||||
}
|
||||
const selectableN = list.filter(function (it) {
|
||||
return !!it.selectable;
|
||||
}).length;
|
||||
if (meta) meta.textContent = "当前 " + uly + " · 可选 " + selectableN;
|
||||
const keep = {};
|
||||
(checkedIds || []).forEach(function (id) {
|
||||
keep[String(id)] = true;
|
||||
@@ -489,6 +494,27 @@
|
||||
);
|
||||
});
|
||||
});
|
||||
box.querySelectorAll("[data-xfer-toggle]").forEach(function (el) {
|
||||
el.addEventListener("click", function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
const card = el.closest(".cond-inst");
|
||||
if (!card || card.classList.contains("is-off")) return;
|
||||
card.classList.toggle("is-xfer-open");
|
||||
});
|
||||
});
|
||||
box.querySelectorAll(".cond-inst-name").forEach(function (el) {
|
||||
el.addEventListener("click", function (ev) {
|
||||
const card = el.closest(".cond-inst");
|
||||
if (!card || card.classList.contains("is-off")) return;
|
||||
const cb = card.querySelector('input[name="cf-inst"]');
|
||||
if (!cb || cb.disabled) return;
|
||||
// 点名称切换勾选(避免点余额误勾)
|
||||
if (ev.target === el) {
|
||||
cb.checked = !cb.checked;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function loadCandidates() {
|
||||
@@ -774,6 +800,55 @@
|
||||
};
|
||||
}
|
||||
|
||||
function syncSegButtons(segId, attr, value) {
|
||||
const seg = document.getElementById(segId);
|
||||
if (!seg) return;
|
||||
seg.querySelectorAll(".cond-seg-btn").forEach(function (btn) {
|
||||
const on = String(btn.getAttribute(attr) || "") === String(value);
|
||||
btn.classList.toggle("on", on);
|
||||
});
|
||||
}
|
||||
|
||||
function bindSegGroup(segId, attr, selectId, onChange) {
|
||||
const seg = document.getElementById(segId);
|
||||
const sel = document.getElementById(selectId);
|
||||
if (!seg || !sel) return;
|
||||
syncSegButtons(segId, attr, sel.value);
|
||||
seg.querySelectorAll(".cond-seg-btn").forEach(function (btn) {
|
||||
btn.addEventListener("click", function () {
|
||||
const v = btn.getAttribute(attr);
|
||||
if (!v || sel.value === v) {
|
||||
if (v) syncSegButtons(segId, attr, v);
|
||||
return;
|
||||
}
|
||||
sel.value = v;
|
||||
syncSegButtons(segId, attr, v);
|
||||
if (typeof onChange === "function") onChange(v);
|
||||
});
|
||||
});
|
||||
sel.addEventListener("change", function () {
|
||||
syncSegButtons(segId, attr, sel.value);
|
||||
if (typeof onChange === "function") onChange(sel.value);
|
||||
});
|
||||
}
|
||||
|
||||
function syncPeMultEnabled() {
|
||||
const pe = document.getElementById("cf-pe");
|
||||
const mult = document.getElementById("cf-pe-mult");
|
||||
if (!pe || !mult) return;
|
||||
mult.disabled = !pe.checked;
|
||||
}
|
||||
|
||||
function currentCheckedInstIds() {
|
||||
const box = document.getElementById("cf-instances");
|
||||
if (!box) return [];
|
||||
return Array.prototype.slice
|
||||
.call(box.querySelectorAll('input[name="cf-inst"]:checked'))
|
||||
.map(function (el) {
|
||||
return decodeURIComponent(el.value || "");
|
||||
});
|
||||
}
|
||||
|
||||
function boot() {
|
||||
const btn = document.getElementById("btn-cond-refresh");
|
||||
if (btn) btn.addEventListener("click", function () {
|
||||
@@ -785,20 +860,15 @@
|
||||
const pxEl = document.getElementById("cf-trigger-px");
|
||||
if (typeEl) typeEl.addEventListener("change", syncTriggerHint);
|
||||
if (pxEl) pxEl.addEventListener("input", syncTriggerHint);
|
||||
const ulyEl = document.getElementById("cf-underlying");
|
||||
if (ulyEl) {
|
||||
ulyEl.addEventListener("change", function () {
|
||||
const box = document.getElementById("cf-instances");
|
||||
const checkedIds = box
|
||||
? Array.prototype.slice
|
||||
.call(box.querySelectorAll('input[name="cf-inst"]:checked'))
|
||||
.map(function (el) {
|
||||
return decodeURIComponent(el.value || "");
|
||||
})
|
||||
: [];
|
||||
paintCandidates(checkedIds);
|
||||
});
|
||||
}
|
||||
bindSegGroup("cf-uly-seg", "data-uly", "cf-underlying", function () {
|
||||
paintCandidates(currentCheckedInstIds());
|
||||
});
|
||||
bindSegGroup("cf-side-seg", "data-side", "cf-opt-type", function () {
|
||||
syncTriggerHint();
|
||||
});
|
||||
const pe = document.getElementById("cf-pe");
|
||||
if (pe) pe.addEventListener("change", syncPeMultEnabled);
|
||||
syncPeMultEnabled();
|
||||
syncTriggerHint();
|
||||
// 读缓存秒开 + SSE;不再前端定时现场拉实例
|
||||
refresh();
|
||||
|
||||
Reference in New Issue
Block a user