|
|
|
|
@ -211,10 +211,8 @@ const workoutStopBtn = document.querySelector("#workout-stop");
|
|
|
|
|
// --- Отклонение от цели ---
|
|
|
|
|
const powerMetric = document.querySelector("#power-metric");
|
|
|
|
|
const powerTarget = document.querySelector("#power-target");
|
|
|
|
|
const powerWarn = document.querySelector("#power-warn");
|
|
|
|
|
const cadenceMetric = document.querySelector("#cadence-metric");
|
|
|
|
|
const cadenceTarget = document.querySelector("#cadence-target");
|
|
|
|
|
const cadenceWarn = document.querySelector("#cadence-warn");
|
|
|
|
|
|
|
|
|
|
const POWER_TOL_PCT = 0.1;
|
|
|
|
|
const POWER_TOL_ABS = 15; // Вт
|
|
|
|
|
@ -229,11 +227,10 @@ function powerTolerance(target) {
|
|
|
|
|
return Math.max(POWER_TOL_ABS, Math.round(target * POWER_TOL_PCT));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateDeviation(metricEl, targetEl, warnEl, actual, target, tolerance, unit) {
|
|
|
|
|
function updateDeviation(metricEl, targetEl, actual, target, tolerance, unit) {
|
|
|
|
|
targetEl.textContent = target != null ? `${target} ${unit}` : "—";
|
|
|
|
|
if (actual == null || target == null) {
|
|
|
|
|
metricEl.classList.remove("metric--off");
|
|
|
|
|
warnEl.textContent = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const diff = actual - target;
|
|
|
|
|
@ -245,11 +242,11 @@ function updateDeviation(metricEl, targetEl, warnEl, actual, target, tolerance,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updatePowerDeviation() {
|
|
|
|
|
updateDeviation(powerMetric, powerTarget, powerWarn, actualWatts, targetWatts, powerTolerance(targetWatts ?? 0), "W");
|
|
|
|
|
updateDeviation(powerMetric, powerTarget, actualWatts, targetWatts, powerTolerance(targetWatts ?? 0), "W");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateCadenceDeviation() {
|
|
|
|
|
updateDeviation(cadenceMetric, cadenceTarget, cadenceWarn, actualCadence, targetCadence, CADENCE_TOL_ABS, "rpm");
|
|
|
|
|
updateDeviation(cadenceMetric, cadenceTarget, actualCadence, targetCadence, CADENCE_TOL_ABS, "rpm");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearTargets() {
|
|
|
|
|
|