fix: 四所统计日历 embed 切换后初始化与加载失败仍渲染网格
统一 initInstanceStatsCalendar,统计 tab 动态注入时重新挂载日历,API 异常时保留月历骨架。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -851,7 +851,7 @@
|
|||||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||||
<script src="/static/strategy_roll.js?v=5"></script>
|
<script src="/static/strategy_roll.js?v=5"></script>
|
||||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||||
<script>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
@@ -1510,36 +1510,7 @@ function switchStatsSegment(){
|
|||||||
q.set("stats_segment", key);
|
q.set("stats_segment", key);
|
||||||
const qs = q.toString();
|
const qs = q.toString();
|
||||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||||
}
|
|
||||||
|
|
||||||
let statsCalendarWidget = null;
|
|
||||||
|
|
||||||
function initStatsCalendarWidget(){
|
|
||||||
const grid = document.getElementById("stats-calendar");
|
|
||||||
if(!grid || !window.TradeStatsCalendar) return;
|
|
||||||
statsCalendarWidget = new TradeStatsCalendar({
|
|
||||||
gridEl: grid,
|
|
||||||
titleEl: document.getElementById("stats-cal-title"),
|
|
||||||
prevBtn: document.getElementById("stats-cal-prev"),
|
|
||||||
nextBtn: document.getElementById("stats-cal-next"),
|
|
||||||
apiUrl: "/api/stats/calendar",
|
|
||||||
showSick: false,
|
|
||||||
buildQuery: function(year, month){
|
|
||||||
const q = new URLSearchParams();
|
|
||||||
q.set("year", String(year));
|
|
||||||
q.set("month", String(month));
|
|
||||||
const sel = document.getElementById("stats-segment-select");
|
|
||||||
if(sel) q.set("segment", sel.value || "all");
|
|
||||||
return q;
|
|
||||||
},
|
|
||||||
parseResponse: function(data){
|
|
||||||
if(data && data.ok === false) return {};
|
|
||||||
return (data && data.days) || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsCalendarWidget.ensureMonth(new Date());
|
|
||||||
statsCalendarWidget.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStatsSegmentFromUrl(){
|
function initStatsSegmentFromUrl(){
|
||||||
@@ -1563,7 +1534,7 @@ function toggleStatsCard(){
|
|||||||
attachListWindowToExports();
|
attachListWindowToExports();
|
||||||
toggleListWindowCustom();
|
toggleListWindowCustom();
|
||||||
initStatsSegmentFromUrl();
|
initStatsSegmentFromUrl();
|
||||||
initStatsCalendarWidget();
|
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||||
if(document.getElementById("journal-list")) loadJournals();
|
if(document.getElementById("journal-list")) loadJournals();
|
||||||
if(document.getElementById("review-list")) loadReviews();
|
if(document.getElementById("review-list")) loadReviews();
|
||||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||||
|
|||||||
@@ -818,7 +818,7 @@
|
|||||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||||
<script src="/static/strategy_roll.js?v=5"></script>
|
<script src="/static/strategy_roll.js?v=5"></script>
|
||||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||||
<script>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
@@ -1477,36 +1477,7 @@ function switchStatsSegment(){
|
|||||||
q.set("stats_segment", key);
|
q.set("stats_segment", key);
|
||||||
const qs = q.toString();
|
const qs = q.toString();
|
||||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||||
}
|
|
||||||
|
|
||||||
let statsCalendarWidget = null;
|
|
||||||
|
|
||||||
function initStatsCalendarWidget(){
|
|
||||||
const grid = document.getElementById("stats-calendar");
|
|
||||||
if(!grid || !window.TradeStatsCalendar) return;
|
|
||||||
statsCalendarWidget = new TradeStatsCalendar({
|
|
||||||
gridEl: grid,
|
|
||||||
titleEl: document.getElementById("stats-cal-title"),
|
|
||||||
prevBtn: document.getElementById("stats-cal-prev"),
|
|
||||||
nextBtn: document.getElementById("stats-cal-next"),
|
|
||||||
apiUrl: "/api/stats/calendar",
|
|
||||||
showSick: false,
|
|
||||||
buildQuery: function(year, month){
|
|
||||||
const q = new URLSearchParams();
|
|
||||||
q.set("year", String(year));
|
|
||||||
q.set("month", String(month));
|
|
||||||
const sel = document.getElementById("stats-segment-select");
|
|
||||||
if(sel) q.set("segment", sel.value || "all");
|
|
||||||
return q;
|
|
||||||
},
|
|
||||||
parseResponse: function(data){
|
|
||||||
if(data && data.ok === false) return {};
|
|
||||||
return (data && data.days) || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsCalendarWidget.ensureMonth(new Date());
|
|
||||||
statsCalendarWidget.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStatsSegmentFromUrl(){
|
function initStatsSegmentFromUrl(){
|
||||||
@@ -1530,7 +1501,7 @@ function toggleStatsCard(){
|
|||||||
attachListWindowToExports();
|
attachListWindowToExports();
|
||||||
toggleListWindowCustom();
|
toggleListWindowCustom();
|
||||||
initStatsSegmentFromUrl();
|
initStatsSegmentFromUrl();
|
||||||
initStatsCalendarWidget();
|
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||||
if(document.getElementById("journal-list")) loadJournals();
|
if(document.getElementById("journal-list")) loadJournals();
|
||||||
if(document.getElementById("review-list")) loadReviews();
|
if(document.getElementById("review-list")) loadReviews();
|
||||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||||
|
|||||||
@@ -818,7 +818,7 @@
|
|||||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||||
<script src="/static/strategy_roll.js?v=5"></script>
|
<script src="/static/strategy_roll.js?v=5"></script>
|
||||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||||
<script>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
@@ -1477,36 +1477,7 @@ function switchStatsSegment(){
|
|||||||
q.set("stats_segment", key);
|
q.set("stats_segment", key);
|
||||||
const qs = q.toString();
|
const qs = q.toString();
|
||||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||||
}
|
|
||||||
|
|
||||||
let statsCalendarWidget = null;
|
|
||||||
|
|
||||||
function initStatsCalendarWidget(){
|
|
||||||
const grid = document.getElementById("stats-calendar");
|
|
||||||
if(!grid || !window.TradeStatsCalendar) return;
|
|
||||||
statsCalendarWidget = new TradeStatsCalendar({
|
|
||||||
gridEl: grid,
|
|
||||||
titleEl: document.getElementById("stats-cal-title"),
|
|
||||||
prevBtn: document.getElementById("stats-cal-prev"),
|
|
||||||
nextBtn: document.getElementById("stats-cal-next"),
|
|
||||||
apiUrl: "/api/stats/calendar",
|
|
||||||
showSick: false,
|
|
||||||
buildQuery: function(year, month){
|
|
||||||
const q = new URLSearchParams();
|
|
||||||
q.set("year", String(year));
|
|
||||||
q.set("month", String(month));
|
|
||||||
const sel = document.getElementById("stats-segment-select");
|
|
||||||
if(sel) q.set("segment", sel.value || "all");
|
|
||||||
return q;
|
|
||||||
},
|
|
||||||
parseResponse: function(data){
|
|
||||||
if(data && data.ok === false) return {};
|
|
||||||
return (data && data.days) || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsCalendarWidget.ensureMonth(new Date());
|
|
||||||
statsCalendarWidget.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStatsSegmentFromUrl(){
|
function initStatsSegmentFromUrl(){
|
||||||
@@ -1530,7 +1501,7 @@ function toggleStatsCard(){
|
|||||||
attachListWindowToExports();
|
attachListWindowToExports();
|
||||||
toggleListWindowCustom();
|
toggleListWindowCustom();
|
||||||
initStatsSegmentFromUrl();
|
initStatsSegmentFromUrl();
|
||||||
initStatsCalendarWidget();
|
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||||
if(document.getElementById("journal-list")) loadJournals();
|
if(document.getElementById("journal-list")) loadJournals();
|
||||||
if(document.getElementById("review-list")) loadReviews();
|
if(document.getElementById("review-list")) loadReviews();
|
||||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||||
|
|||||||
@@ -847,7 +847,7 @@
|
|||||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||||
<script src="/static/strategy_roll.js?v=5"></script>
|
<script src="/static/strategy_roll.js?v=5"></script>
|
||||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||||
<script>
|
<script>
|
||||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||||
@@ -1506,36 +1506,7 @@ function switchStatsSegment(){
|
|||||||
q.set("stats_segment", key);
|
q.set("stats_segment", key);
|
||||||
const qs = q.toString();
|
const qs = q.toString();
|
||||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||||
}
|
|
||||||
|
|
||||||
let statsCalendarWidget = null;
|
|
||||||
|
|
||||||
function initStatsCalendarWidget(){
|
|
||||||
const grid = document.getElementById("stats-calendar");
|
|
||||||
if(!grid || !window.TradeStatsCalendar) return;
|
|
||||||
statsCalendarWidget = new TradeStatsCalendar({
|
|
||||||
gridEl: grid,
|
|
||||||
titleEl: document.getElementById("stats-cal-title"),
|
|
||||||
prevBtn: document.getElementById("stats-cal-prev"),
|
|
||||||
nextBtn: document.getElementById("stats-cal-next"),
|
|
||||||
apiUrl: "/api/stats/calendar",
|
|
||||||
showSick: false,
|
|
||||||
buildQuery: function(year, month){
|
|
||||||
const q = new URLSearchParams();
|
|
||||||
q.set("year", String(year));
|
|
||||||
q.set("month", String(month));
|
|
||||||
const sel = document.getElementById("stats-segment-select");
|
|
||||||
if(sel) q.set("segment", sel.value || "all");
|
|
||||||
return q;
|
|
||||||
},
|
|
||||||
parseResponse: function(data){
|
|
||||||
if(data && data.ok === false) return {};
|
|
||||||
return (data && data.days) || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsCalendarWidget.ensureMonth(new Date());
|
|
||||||
statsCalendarWidget.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStatsSegmentFromUrl(){
|
function initStatsSegmentFromUrl(){
|
||||||
@@ -1559,7 +1530,7 @@ function toggleStatsCard(){
|
|||||||
attachListWindowToExports();
|
attachListWindowToExports();
|
||||||
toggleListWindowCustom();
|
toggleListWindowCustom();
|
||||||
initStatsSegmentFromUrl();
|
initStatsSegmentFromUrl();
|
||||||
initStatsCalendarWidget();
|
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||||
if(document.getElementById("journal-list")) loadJournals();
|
if(document.getElementById("journal-list")) loadJournals();
|
||||||
if(document.getElementById("review-list")) loadReviews();
|
if(document.getElementById("review-list")) loadReviews();
|
||||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||||
|
|||||||
@@ -664,36 +664,7 @@ function switchStatsSegment(){
|
|||||||
q.set("stats_segment", key);
|
q.set("stats_segment", key);
|
||||||
const qs = q.toString();
|
const qs = q.toString();
|
||||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||||
}
|
|
||||||
|
|
||||||
let statsCalendarWidget = null;
|
|
||||||
|
|
||||||
function initStatsCalendarWidget(){
|
|
||||||
const grid = document.getElementById("stats-calendar");
|
|
||||||
if(!grid || !window.TradeStatsCalendar) return;
|
|
||||||
statsCalendarWidget = new TradeStatsCalendar({
|
|
||||||
gridEl: grid,
|
|
||||||
titleEl: document.getElementById("stats-cal-title"),
|
|
||||||
prevBtn: document.getElementById("stats-cal-prev"),
|
|
||||||
nextBtn: document.getElementById("stats-cal-next"),
|
|
||||||
apiUrl: "/api/stats/calendar",
|
|
||||||
showSick: false,
|
|
||||||
buildQuery: function(year, month){
|
|
||||||
const q = new URLSearchParams();
|
|
||||||
q.set("year", String(year));
|
|
||||||
q.set("month", String(month));
|
|
||||||
const sel = document.getElementById("stats-segment-select");
|
|
||||||
if(sel) q.set("segment", sel.value || "all");
|
|
||||||
return q;
|
|
||||||
},
|
|
||||||
parseResponse: function(data){
|
|
||||||
if(data && data.ok === false) return {};
|
|
||||||
return (data && data.days) || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
statsCalendarWidget.ensureMonth(new Date());
|
|
||||||
statsCalendarWidget.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStatsSegmentFromUrl(){
|
function initStatsSegmentFromUrl(){
|
||||||
@@ -730,7 +701,7 @@ attachListWindowToExports();
|
|||||||
toggleListWindowCustom();
|
toggleListWindowCustom();
|
||||||
bindListWindowDateAutoCustom();
|
bindListWindowDateAutoCustom();
|
||||||
initStatsSegmentFromUrl();
|
initStatsSegmentFromUrl();
|
||||||
initStatsCalendarWidget();
|
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||||
if(document.getElementById("journal-list")) loadJournals();
|
if(document.getElementById("journal-list")) loadJournals();
|
||||||
if(document.getElementById("review-list")) loadReviews();
|
if(document.getElementById("review-list")) loadReviews();
|
||||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||||
|
|||||||
@@ -121,8 +121,8 @@
|
|||||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||||
<script src="/static/strategy_roll.js?v=5"></script>
|
<script src="/static/strategy_roll.js?v=5"></script>
|
||||||
<script src="/static/key_monitor_form.js?v=2"></script>
|
<script src="/static/key_monitor_form.js?v=2"></script>
|
||||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||||
{% include 'embed_boot_scripts.html' %}
|
{% include 'embed_boot_scripts.html' %}
|
||||||
<script src="/static/instance_embed.js?v=4"></script>
|
<script src="/static/instance_embed.js?v=5"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -76,6 +76,10 @@
|
|||||||
if (typeof global.loadReviews === "function") global.loadReviews();
|
if (typeof global.loadReviews === "function") global.loadReviews();
|
||||||
if (typeof global.toggleReviewMode === "function") global.toggleReviewMode();
|
if (typeof global.toggleReviewMode === "function") global.toggleReviewMode();
|
||||||
}
|
}
|
||||||
|
if (tab === "stats") {
|
||||||
|
if (typeof global.initStatsSegmentFromUrl === "function") global.initStatsSegmentFromUrl();
|
||||||
|
if (typeof global.initInstanceStatsCalendar === "function") global.initInstanceStatsCalendar();
|
||||||
|
}
|
||||||
if (typeof global.refreshPriceSnapshotConditional === "function") {
|
if (typeof global.refreshPriceSnapshotConditional === "function") {
|
||||||
global.refreshPriceSnapshotConditional();
|
global.refreshPriceSnapshotConditional();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
TradeStatsCalendar.prototype.render = function () {
|
TradeStatsCalendar.prototype.render = function () {
|
||||||
if (!this.gridEl || !this.titleEl) return;
|
if (!this.gridEl || !this.titleEl) return;
|
||||||
this.ensureMonth(new Date());
|
if (this.year <= 0 || this.month <= 0) this.ensureMonth(new Date());
|
||||||
this.titleEl.textContent = monthLabel(this.year, this.month);
|
this.titleEl.textContent = monthLabel(this.year, this.month);
|
||||||
var first = new Date(this.year, this.month - 1, 1);
|
var first = new Date(this.year, this.month - 1, 1);
|
||||||
var lastDay = new Date(this.year, this.month, 0).getDate();
|
var lastDay = new Date(this.year, this.month, 0).getDate();
|
||||||
@@ -149,6 +149,7 @@
|
|||||||
|
|
||||||
TradeStatsCalendar.prototype.load = async function () {
|
TradeStatsCalendar.prototype.load = async function () {
|
||||||
this.ensureMonth(new Date());
|
this.ensureMonth(new Date());
|
||||||
|
this.render();
|
||||||
var q = this.buildQuery(this.year, this.month);
|
var q = this.buildQuery(this.year, this.month);
|
||||||
if (!q.has("year")) q.set("year", String(this.year));
|
if (!q.has("year")) q.set("year", String(this.year));
|
||||||
if (!q.has("month")) q.set("month", String(this.month));
|
if (!q.has("month")) q.set("month", String(this.month));
|
||||||
@@ -160,6 +161,10 @@
|
|||||||
var resp = await fetch(this.apiUrl + "?" + q.toString(), {
|
var resp = await fetch(this.apiUrl + "?" + q.toString(), {
|
||||||
credentials: "same-origin",
|
credentials: "same-origin",
|
||||||
});
|
});
|
||||||
|
if (!resp.ok) {
|
||||||
|
console.warn("[trade calendar] api", resp.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
data = await resp.json();
|
data = await resp.json();
|
||||||
}
|
}
|
||||||
this.days = this.parseResponse(data) || {};
|
this.days = this.parseResponse(data) || {};
|
||||||
@@ -167,6 +172,7 @@
|
|||||||
if (this.onMonthChange) this.onMonthChange(this.year, this.month, this.days);
|
if (this.onMonthChange) this.onMonthChange(this.year, this.month, this.days);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("[trade calendar]", e);
|
console.warn("[trade calendar]", e);
|
||||||
|
this.render();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,4 +206,36 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.TradeStatsCalendar = TradeStatsCalendar;
|
global.TradeStatsCalendar = TradeStatsCalendar;
|
||||||
|
|
||||||
|
global.statsCalendarWidget = null;
|
||||||
|
|
||||||
|
global.initInstanceStatsCalendar = function () {
|
||||||
|
var grid = document.getElementById("stats-calendar");
|
||||||
|
if (!grid || !global.TradeStatsCalendar) return null;
|
||||||
|
global.statsCalendarWidget = new TradeStatsCalendar({
|
||||||
|
gridEl: grid,
|
||||||
|
titleEl: document.getElementById("stats-cal-title"),
|
||||||
|
prevBtn: document.getElementById("stats-cal-prev"),
|
||||||
|
nextBtn: document.getElementById("stats-cal-next"),
|
||||||
|
apiUrl: "/api/stats/calendar",
|
||||||
|
showSick: false,
|
||||||
|
buildQuery: function (year, month) {
|
||||||
|
var q = new URLSearchParams();
|
||||||
|
q.set("year", String(year));
|
||||||
|
q.set("month", String(month));
|
||||||
|
var sel = document.getElementById("stats-segment-select");
|
||||||
|
if (sel) q.set("segment", sel.value || "all");
|
||||||
|
return q;
|
||||||
|
},
|
||||||
|
parseResponse: function (data) {
|
||||||
|
if (data && data.ok === false) return {};
|
||||||
|
return (data && data.days) || {};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
global.statsCalendarWidget.render();
|
||||||
|
void global.statsCalendarWidget.load();
|
||||||
|
return global.statsCalendarWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
global.initStatsCalendarWidget = global.initInstanceStatsCalendar;
|
||||||
})(window);
|
})(window);
|
||||||
|
|||||||
Reference in New Issue
Block a user