Support Galaxy sensor fields and remove debug file
This commit is contained in:
+186
-45
@@ -15,21 +15,39 @@ const deviceLang = (navigator.language || navigator.userLanguage || "en").starts
|
||||
autoCurrentUpdate: "현재 위치 자동 이동",
|
||||
autoUpdate: "자동 업데이트",
|
||||
forceUpdate: "업데이트 하기",
|
||||
battery: "배터리",
|
||||
batteryState: "배터리 상태",
|
||||
batteryLevel: "배터리 잔량",
|
||||
watchbatteryState: "워치 배터리 상태",
|
||||
watchbatteryLevel: "워치 배터리 잔량",
|
||||
activity: "활동",
|
||||
currentActivity: "현재 활동",
|
||||
activityAccuracy: "활동 정확도",
|
||||
battery: "배터리",
|
||||
batteryState: "배터리 상태",
|
||||
batteryLevel: "배터리 잔량",
|
||||
watchbatteryState: "워치 배터리 상태",
|
||||
watchbatteryLevel: "워치 배터리 잔량",
|
||||
isCharging: "충전 여부",
|
||||
chargerType: "충전 방식",
|
||||
batteryHealth: "배터리 건강",
|
||||
batteryTemperature: "배터리 온도",
|
||||
batteryPower: "배터리 전력",
|
||||
remainingChargeTime: "충전 남은 시간",
|
||||
batteryCycleCount: "배터리 사이클",
|
||||
activity: "활동",
|
||||
currentActivity: "현재 활동",
|
||||
activityAccuracy: "활동 정확도",
|
||||
distance: "도보로 움직인 거리",
|
||||
steps: "걸음 수",
|
||||
ascended: "오른 계단",
|
||||
descended: "내려간 계단",
|
||||
etc: "기타",
|
||||
connection: "연결 방법",
|
||||
editPage: "페이지 수정",
|
||||
etc: "기타",
|
||||
connection: "연결 방법",
|
||||
wifiConnection: "Wi-Fi",
|
||||
wifiIp: "Wi-Fi IP",
|
||||
wifiLinkSpeed: "Wi-Fi 속도",
|
||||
wifiFrequency: "Wi-Fi 주파수",
|
||||
wifiSignalStrength: "Wi-Fi 신호",
|
||||
mobileData: "모바일 데이터",
|
||||
phoneState: "전화 상태",
|
||||
interactive: "화면 활성",
|
||||
dozeMode: "Doze 모드",
|
||||
powerSave: "절전 모드",
|
||||
deviceLocked: "잠금 상태",
|
||||
editPage: "페이지 수정",
|
||||
pwa: "눌러 홈 화면에 추가해 바로 보기",
|
||||
history: "기록",
|
||||
startTime: "시작",
|
||||
@@ -50,21 +68,39 @@ const deviceLang = (navigator.language || navigator.userLanguage || "en").starts
|
||||
autoCurrentUpdate: "Current Location Auto Update",
|
||||
autoUpdate: "Auto Update",
|
||||
forceUpdate: "Force Update",
|
||||
battery: "Battery",
|
||||
batteryState: "Battery State",
|
||||
batteryLevel: "Battery Level",
|
||||
watchbatteryState: "Watch Battery State",
|
||||
watchbatteryLevel: "Watch Battery Level",
|
||||
activity: "Activity",
|
||||
battery: "Battery",
|
||||
batteryState: "Battery State",
|
||||
batteryLevel: "Battery Level",
|
||||
watchbatteryState: "Watch Battery State",
|
||||
watchbatteryLevel: "Watch Battery Level",
|
||||
isCharging: "Charging",
|
||||
chargerType: "Charger Type",
|
||||
batteryHealth: "Battery Health",
|
||||
batteryTemperature: "Battery Temp",
|
||||
batteryPower: "Battery Power",
|
||||
remainingChargeTime: "Remaining Charge",
|
||||
batteryCycleCount: "Battery Cycles",
|
||||
activity: "Activity",
|
||||
currentActivity: "Current Activity",
|
||||
activityAccuracy: "Activity Confidence",
|
||||
distance: "Distance walked",
|
||||
steps: "Steps",
|
||||
ascended: "Floors Ascended",
|
||||
descended: "Floors Descended",
|
||||
etc: "Others",
|
||||
connection: "Network Type",
|
||||
editPage: "Edit Page",
|
||||
etc: "Others",
|
||||
connection: "Network Type",
|
||||
wifiConnection: "Wi-Fi",
|
||||
wifiIp: "Wi-Fi IP",
|
||||
wifiLinkSpeed: "Wi-Fi Speed",
|
||||
wifiFrequency: "Wi-Fi Frequency",
|
||||
wifiSignalStrength: "Wi-Fi Signal",
|
||||
mobileData: "Mobile Data",
|
||||
phoneState: "Phone State",
|
||||
interactive: "Interactive",
|
||||
dozeMode: "Doze Mode",
|
||||
powerSave: "Power Save",
|
||||
deviceLocked: "Device Locked",
|
||||
editPage: "Edit Page",
|
||||
pwa: "Add to Home Screen for quick access!",
|
||||
history: "History",
|
||||
startTime: "Start",
|
||||
@@ -538,29 +574,133 @@ function setCookieHours(name, value, hours) {
|
||||
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; expires=${d.toUTCString()}; path=/; SameSite=Lax`;
|
||||
}
|
||||
|
||||
function updateDOM(data) {
|
||||
const textMap = {
|
||||
currentPosition: data.address,
|
||||
function updateDOM(data) {
|
||||
const textMap = {
|
||||
currentPosition: data.address,
|
||||
lastUpdateTime: data.updated ? getRelativeTime(data.updated) : "-",
|
||||
nowActivity: data.activity,
|
||||
connectionType: data.connection,
|
||||
updateTrigger: data.trigger,
|
||||
batteryStatus: data.state,
|
||||
Battery: data.level > 0 ? `${data.level}%` : "-",
|
||||
WbatteryStatus: data.wstate,
|
||||
WBattery: data.wlevel > 0 ? `${data.wlevel}%` : "-",
|
||||
todaySteps: data.steps > 0 ? `${formatNumber(data.steps)}${langCode === "ko" ? "걸음" : "steps"}` : "-",
|
||||
batteryStatus: data.state,
|
||||
Battery: data.level > 0 ? `${data.level}%` : "-",
|
||||
WbatteryStatus: data.wstate,
|
||||
WBattery: data.wlevel > 0 ? `${data.wlevel}%` : "-",
|
||||
todaySteps: data.steps > 0 ? `${formatNumber(data.steps)}${langCode === "ko" ? "걸음" : "steps"}` : "-",
|
||||
todayAscended: data.ascended > 0 ? `${formatNumber(data.ascended)}${langCode === "ko" ? "층" : "floors"}` : "-",
|
||||
todayDescended: data.descended > 0 ? `${formatNumber(data.descended)}${langCode === "ko" ? "층" : "floors"}` : "-",
|
||||
todayDistance: data.distance > 0 ? `${formatNumber(data.distance)}m` : "-",
|
||||
accuracyValue: data.accuracy > 0 ? `${formatNumber(data.accuracy)}m` : "-"
|
||||
};
|
||||
|
||||
for (const [id, value] of Object.entries(textMap)) {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = value || "-";
|
||||
}
|
||||
}
|
||||
for (const [id, value] of Object.entries(textMap)) {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = value || "-";
|
||||
}
|
||||
|
||||
toggleOptionalRow('WbatteryStatus', data.wstate);
|
||||
toggleOptionalRow('WBattery', data.wlevel);
|
||||
updateGalaxyRows(data.galaxy || {});
|
||||
}
|
||||
|
||||
function updateGalaxyRows(galaxy) {
|
||||
const t = translations[langCode] || translations.ko;
|
||||
const rows = [
|
||||
['isCharging', t.isCharging, galaxy.isCharging],
|
||||
['chargerType', t.chargerType, galaxy.chargerType],
|
||||
['batteryHealth', t.batteryHealth, galaxy.batteryHealth],
|
||||
['batteryTemperature', t.batteryTemperature, formatWithUnit(galaxy.batteryTemperature, '°C')],
|
||||
['batteryPower', t.batteryPower, formatWithUnit(galaxy.batteryPower, 'W')],
|
||||
['remainingChargeTime', t.remainingChargeTime, formatDuration(galaxy.remainingChargeTime)],
|
||||
['batteryCycleCount', t.batteryCycleCount, galaxy.batteryCycleCount],
|
||||
['wifiConnection', t.wifiConnection, galaxy.wifiConnection],
|
||||
['wifiIp', t.wifiIp, galaxy.wifiIp],
|
||||
['wifiLinkSpeed', t.wifiLinkSpeed, formatWithUnit(galaxy.wifiLinkSpeed, 'Mbps')],
|
||||
['wifiFrequency', t.wifiFrequency, formatWithUnit(galaxy.wifiFrequency, 'MHz')],
|
||||
['wifiSignalStrength', t.wifiSignalStrength, formatWithUnit(galaxy.wifiSignalStrength, 'dBm')],
|
||||
['mobileData', t.mobileData, galaxy.mobileData],
|
||||
['phoneState', t.phoneState, galaxy.phoneState],
|
||||
['interactive', t.interactive, galaxy.interactive],
|
||||
['dozeMode', t.dozeMode, galaxy.dozeMode],
|
||||
['powerSave', t.powerSave, galaxy.powerSave],
|
||||
['deviceLocked', t.deviceLocked, galaxy.deviceLocked],
|
||||
];
|
||||
|
||||
rows.forEach(([key, label, value]) => {
|
||||
const targetSection = ['isCharging', 'chargerType', 'batteryHealth', 'batteryTemperature', 'batteryPower', 'remainingChargeTime', 'batteryCycleCount'].includes(key)
|
||||
? findSectionByTitle(langCode === 'ko' ? '배터리' : 'Battery')
|
||||
: findSectionByTitle(langCode === 'ko' ? '기타' : 'Others');
|
||||
upsertOptionalRow(targetSection, `galaxy_${key}`, label, value);
|
||||
});
|
||||
}
|
||||
|
||||
function findSectionByTitle(titleText) {
|
||||
const titles = document.querySelectorAll('.settingTitle');
|
||||
for (const title of titles) {
|
||||
if (title.textContent.trim() === titleText) {
|
||||
const section = title.nextElementSibling;
|
||||
if (section && section.classList.contains('settingSection')) return section;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function upsertOptionalRow(section, id, label, value) {
|
||||
if (!section) return;
|
||||
const displayValue = normalizeDisplayValue(value);
|
||||
let row = document.getElementById(id);
|
||||
|
||||
if (!displayValue) {
|
||||
if (row) row.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!row) {
|
||||
row = document.createElement('div');
|
||||
row.className = 'settingRow';
|
||||
row.id = id;
|
||||
row.innerHTML = `<span></span><span></span>`;
|
||||
section.appendChild(row);
|
||||
}
|
||||
|
||||
row.children[0].textContent = label;
|
||||
row.children[1].textContent = displayValue;
|
||||
}
|
||||
|
||||
function toggleOptionalRow(valueId, value) {
|
||||
const el = document.getElementById(valueId);
|
||||
const row = el?.closest('.settingRow');
|
||||
if (!row) return;
|
||||
row.style.display = normalizeDisplayValue(value) ? '' : 'none';
|
||||
}
|
||||
|
||||
function normalizeDisplayValue(value) {
|
||||
if (value === null || typeof value === 'undefined' || value === '' || value === '-' || value === 'unknown' || value === 'unavailable') {
|
||||
return '';
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function formatWithUnit(value, unit) {
|
||||
const normalized = normalizeDisplayValue(value);
|
||||
if (!normalized) return '';
|
||||
return /[a-zA-Z%°]/.test(normalized) ? normalized : `${normalized}${unit}`;
|
||||
}
|
||||
|
||||
function formatDuration(value) {
|
||||
const normalized = normalizeDisplayValue(value);
|
||||
if (!normalized) return '';
|
||||
const seconds = Number(normalized);
|
||||
if (!Number.isFinite(seconds)) return normalized;
|
||||
if (seconds <= 0) return '0s';
|
||||
const h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = Math.floor(seconds % 60);
|
||||
return [
|
||||
h ? `${h}h` : '',
|
||||
m ? `${m}m` : '',
|
||||
s && !h ? `${s}s` : '',
|
||||
].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
function updateActivitySection(data) {
|
||||
const validActivities = ["Stationary", "Walking", "Running", "In Vehicle", "Cycling", "가만히 있음", "걷는 중", "달리는 중", "차량 이동 중", "자전거 이동 중"];
|
||||
@@ -1006,18 +1146,19 @@ function debounce(fn, delay = 400) {
|
||||
};
|
||||
}
|
||||
|
||||
function resetDisplayValues() {
|
||||
const ids = [
|
||||
'currentPosition', 'accuracyValue', 'lastUpdateTime', 'updateTrigger',
|
||||
'batteryStatus', 'Battery', 'WbatteryStatus', 'WBattery',
|
||||
'nowActivity', 'nowactivityAccuracy', 'todayDistance',
|
||||
'todaySteps', 'todayAscended', 'todayDescended', 'connectionType'
|
||||
];
|
||||
ids.forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = '-';
|
||||
});
|
||||
}
|
||||
function resetDisplayValues() {
|
||||
const ids = [
|
||||
'currentPosition', 'accuracyValue', 'lastUpdateTime', 'updateTrigger',
|
||||
'batteryStatus', 'Battery', 'WbatteryStatus', 'WBattery',
|
||||
'nowActivity', 'nowactivityAccuracy', 'todayDistance',
|
||||
'todaySteps', 'todayAscended', 'todayDescended', 'connectionType'
|
||||
];
|
||||
ids.forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.textContent = '-';
|
||||
});
|
||||
document.querySelectorAll('[id^="galaxy_"]').forEach(row => row.remove());
|
||||
}
|
||||
|
||||
function triggerForceUpdate() {
|
||||
callDeviceWebhook('force_update');
|
||||
|
||||
Reference in New Issue
Block a user