findmydevice 기록 경로 갱신과 요약 정리
This commit is contained in:
+34
-16
@@ -1811,22 +1811,23 @@ function renderHistorySummary() {
|
||||
const home = stats.home;
|
||||
const sessions = home?.sessions || [];
|
||||
const recentSessions = sessions.slice(-3).reverse();
|
||||
const rows = [
|
||||
[t.historyDistance, formatDistance(stats.distance)],
|
||||
[t.historyDuration, formatDuration(Math.round(stats.duration))],
|
||||
[t.historyPoints, formatNumber(stats.points)],
|
||||
];
|
||||
|
||||
if (stats.stops > 0) rows.push([t.historyStops, formatNumber(stats.stops)]);
|
||||
if (home?.status) rows.push([t.currentPlaceStatus, home.status]);
|
||||
if (home && home.awaySeconds > 0) rows.push([t.awayTime, formatDuration(Math.round(home.awaySeconds))]);
|
||||
if (sessions.length > 0) rows.push([t.awaySessions, formatNumber(sessions.length)]);
|
||||
if (home?.lastReturn) rows.push([t.lastReturn, formatDateTime(home.lastReturn)]);
|
||||
|
||||
panel.hidden = false;
|
||||
panel.innerHTML = `
|
||||
<div class="history-summary-title">${t.historySummary}</div>
|
||||
<div class="history-summary-grid">
|
||||
<span>${t.historyDistance}</span><strong>${formatDistance(stats.distance)}</strong>
|
||||
<span>${t.historyDuration}</span><strong>${formatDuration(Math.round(stats.duration))}</strong>
|
||||
<span>${t.historyAverageSpeed}</span><strong>${formatSpeed(stats.averageSpeed)}</strong>
|
||||
<span>${t.historyMaxGap}</span><strong>${formatDuration(Math.round(stats.maxGap))}</strong>
|
||||
<span>${t.historyPoints}</span><strong>${stats.rawPoints && stats.rawPoints !== stats.renderPoints ? `${formatNumber(stats.renderPoints)} / ${formatNumber(stats.rawPoints)}` : formatNumber(stats.points)}</strong>
|
||||
<span>${t.historyStops}</span><strong>${formatNumber(stats.stops || 0)}</strong>
|
||||
<span>${t.homeRadius}</span><strong>${mapState.filterOutliers ? `${formatNumber(homeRadiusMeters())}m + GPS 1.2km` : `${formatNumber(homeRadiusMeters())}m`}</strong>
|
||||
<span>${t.homeStay}</span><strong>${home ? formatDuration(Math.round(home.homeSeconds)) : '-'}</strong>
|
||||
<span>${t.awayTime}</span><strong>${home ? formatDuration(Math.round(home.awaySeconds)) : '-'}</strong>
|
||||
<span>${t.awaySessions}</span><strong>${home ? formatNumber(sessions.length) : '-'}</strong>
|
||||
<span>${t.lastReturn}</span><strong>${home?.lastReturn ? formatDateTime(home.lastReturn) : '-'}</strong>
|
||||
<span>${t.currentPlaceStatus}</span><strong>${home?.status || '-'}</strong>
|
||||
${rows.map(([label, value]) => `<span>${label}</span><strong>${value || '-'}</strong>`).join('')}
|
||||
</div>
|
||||
${recentSessions.length ? `
|
||||
<div class="away-session-list">
|
||||
@@ -1838,7 +1839,6 @@ function renderHistorySummary() {
|
||||
` : ''}
|
||||
`;
|
||||
}
|
||||
|
||||
function buildHistoryInfoContent(point, type, label) {
|
||||
const t = translations[langCode] || translations.ko;
|
||||
const title = label || t.historyPoint;
|
||||
@@ -2350,6 +2350,13 @@ function updateDOMWithData(data) {
|
||||
if (!mapState.map) {
|
||||
initMap(latlng, data.accuracy);
|
||||
}
|
||||
|
||||
// 라이브 모드에서도 최신 24시간 기록을 계속 반영한다.
|
||||
// 현재 위치 자동 이동은 지도 중심만 바꾸므로, 경로와 종료 마커는 여기서 별도로 갱신한다.
|
||||
if (data.history?.length > 0) {
|
||||
applyHistoryCounts(data);
|
||||
updateHistoryMarkers(data.history);
|
||||
}
|
||||
|
||||
// 메인 마커 / 정확도 원 업데이트
|
||||
mapState.marker.setPosition(latlng);
|
||||
@@ -2430,6 +2437,18 @@ function syncUpdateBtn() {
|
||||
}
|
||||
}
|
||||
|
||||
function readHistoryRangeInputs() {
|
||||
const toServerTime = value => value
|
||||
? (value.includes('T') ? value.replace('T', ' ') : value) + (value.length === 16 ? ':00' : '')
|
||||
: null;
|
||||
const start = document.getElementById('rangeStart')?.value || '';
|
||||
const end = document.getElementById('rangeEnd')?.value || '';
|
||||
return {
|
||||
startTime: toServerTime(start),
|
||||
endTime: toServerTime(end),
|
||||
};
|
||||
}
|
||||
|
||||
function fetchDeviceData(includeLang = true, range = null) {
|
||||
if (!findmydeviceAuthenticated) {
|
||||
return Promise.reject(new Error('not_authenticated'));
|
||||
@@ -2437,8 +2456,7 @@ function fetchDeviceData(includeLang = true, range = null) {
|
||||
|
||||
const params = new URLSearchParams(includeLang ? { lang: langCode } : { hashonly: 1 });
|
||||
|
||||
// 우선순위: 직접 인자(range) > 전역 오버라이드(_overrideRange)
|
||||
const eff = range || _overrideRange || {};
|
||||
const eff = range || _overrideRange || (includeLang ? readHistoryRangeInputs() : {});
|
||||
const hasHistoryRange = includeLang && !!(eff.startTime || eff.endTime);
|
||||
|
||||
const s = eff.startTime;
|
||||
@@ -2449,7 +2467,7 @@ function fetchDeviceData(includeLang = true, range = null) {
|
||||
if (hasHistoryRange) {
|
||||
params.set('history', '1');
|
||||
}
|
||||
|
||||
|
||||
const url = `https://chaegeon.com/custom/findmydevice/php/api.php?${params.toString()}`;
|
||||
|
||||
return fetch(url, {
|
||||
|
||||
Reference in New Issue
Block a user