Add OKX env toggle to show or hide perpetual funds in the header.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1149,8 +1149,23 @@ function setFundsFieldText(field, text){
|
||||
el.innerText = text;
|
||||
});
|
||||
}
|
||||
function applyPerpFundsVisibility(show){
|
||||
const on = show !== false;
|
||||
document.querySelectorAll("[data-perp-funds='1']").forEach((el) => {
|
||||
el.style.display = on ? "" : "none";
|
||||
});
|
||||
}
|
||||
function accountSnapshotFundingMissing(data){
|
||||
if(!data || typeof data !== "object") return true;
|
||||
if(data.show_perp_funds === false){
|
||||
const hasTotal = data.total_funds != null && data.total_funds !== "";
|
||||
const hasOpt =
|
||||
data.options_funding_usdc != null ||
|
||||
data.options_funding_usdt != null ||
|
||||
data.options_trading_usdc != null ||
|
||||
data.options_trading_usdt != null;
|
||||
return !hasTotal && !hasOpt;
|
||||
}
|
||||
const hasFunding = data.funding_usdt != null && data.funding_usdt !== "";
|
||||
const hasTotal = data.total_funds != null && data.total_funds !== "";
|
||||
const hasTrading = data.current_capital != null && data.current_capital !== "";
|
||||
@@ -1159,6 +1174,9 @@ function accountSnapshotFundingMissing(data){
|
||||
let accountSnapshotRetryCount = 0;
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
applyPerpFundsVisibility(data.show_perp_funds);
|
||||
}
|
||||
if(data.funding_usdt != null && data.funding_usdt !== ""){
|
||||
setFundsFieldText("total-capital", `${Number(data.funding_usdt).toFixed(2)}U`);
|
||||
}
|
||||
|
||||
@@ -1626,8 +1626,23 @@ function setFundsFieldText(field, text){
|
||||
el.innerText = text;
|
||||
});
|
||||
}
|
||||
function applyPerpFundsVisibility(show){
|
||||
const on = show !== false;
|
||||
document.querySelectorAll("[data-perp-funds='1']").forEach((el) => {
|
||||
el.style.display = on ? "" : "none";
|
||||
});
|
||||
}
|
||||
function accountSnapshotFundingMissing(data){
|
||||
if(!data || typeof data !== "object") return true;
|
||||
if(data.show_perp_funds === false){
|
||||
const hasTotal = data.total_funds != null && data.total_funds !== "";
|
||||
const hasOpt =
|
||||
data.options_funding_usdc != null ||
|
||||
data.options_funding_usdt != null ||
|
||||
data.options_trading_usdc != null ||
|
||||
data.options_trading_usdt != null;
|
||||
return !hasTotal && !hasOpt;
|
||||
}
|
||||
const hasFunding = data.funding_usdt != null && data.funding_usdt !== "";
|
||||
const hasTotal = data.total_funds != null && data.total_funds !== "";
|
||||
const hasTrading = data.current_capital != null && data.current_capital !== "";
|
||||
@@ -1636,6 +1651,9 @@ function accountSnapshotFundingMissing(data){
|
||||
let accountSnapshotRetryCount = 0;
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
applyPerpFundsVisibility(data.show_perp_funds);
|
||||
}
|
||||
if(data.funding_usdt != null && data.funding_usdt !== ""){
|
||||
setFundsFieldText("total-capital", `${Number(data.funding_usdt).toFixed(2)}U`);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
{% include 'instance_header_stats.html' %}
|
||||
</div>
|
||||
<div class="instance-header-phone-strip instance-phone-only" aria-label="手机资金摘要">
|
||||
<span class="inst-phone-chip">
|
||||
<span class="inst-phone-chip"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<em>交易</em>
|
||||
<b data-funds-field="current-capital">{{ funds_fmt(current_capital) }}U</b>
|
||||
</span>
|
||||
<span class="inst-phone-chip">
|
||||
<span class="inst-phone-chip"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<em>资金</em>
|
||||
<b data-funds-field="total-capital">{% if funding_usdt is not none %}{{ funds_fmt(funding_usdt) }}U{% else %}—{% endif %}</b>
|
||||
</span>
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
<div class="label">总资金</div>
|
||||
<div class="value" id="total-funds" data-funds-field="total-funds">{% if total_funds is not none %}{{ funds_fmt(total_funds) }}U{% else %}—{% endif %}</div>
|
||||
</div>
|
||||
<div class="stat-strip-item">
|
||||
<div class="stat-strip-item"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="label">资金账户</div>
|
||||
<div class="value" id="total-capital" data-funds-field="total-capital">{% if funding_usdt is not none %}{{ funds_fmt(funding_usdt) }}U{% else %}—{% endif %}</div>
|
||||
</div>
|
||||
<div class="stat-strip-item">
|
||||
<div class="stat-strip-item"{% if not (show_perp_funds|default(true)) %} style="display:none"{% endif %} data-perp-funds="1">
|
||||
<div class="label">交易账户</div>
|
||||
<div class="value" id="current-capital" data-funds-field="current-capital">{{ funds_fmt(current_capital) }}U</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user