Interfaccia, parte 2: Attività, Impostazioni, collegamento, Importa, doppioni, primo avvio ed errori di configurazione
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
90 files changed
+7825
-49
No files matched your search
@@ -0,0 +1,413 @@
|
||||
// Impostazioni, Limiti e comportamento (mockup 07, spec §7.2, §7.5, §7.7): the honest note on the values, the profile
|
||||
// cards (Prudente, Equilibrato, Rapido with confirmation and «Più rischio», Su misura when Alberto changes a value),
|
||||
// the active window with its daily shift and the active days as initials, session and pause ranges, the gesture
|
||||
// pace, every budget of §7.5, the gradual start, the fixed stops (informative), and the fixed save bar. The limits
|
||||
// of §7.5 are checked here with Italian messages and again by the server.
|
||||
|
||||
import { api } from '../core/api.js';
|
||||
import { h, icon, fill } from '../core/dom.js';
|
||||
import { refreshEngine } from '../core/engine.js';
|
||||
import { t, list, number, decimal } from '../core/text.js';
|
||||
import { checkbox, confirmDialog, label, showError, toast, toggle } from '../core/ui.js';
|
||||
import { guardChanges, heading } from './settings.js';
|
||||
|
||||
const PACES = ['slow', 'natural', 'brisk'];
|
||||
const DAY_ORDER = [1, 2, 3, 4, 5, 6, 0]; // Monday first; the API counts from Sunday = 0
|
||||
|
||||
export default async function limits(page, box) {
|
||||
let data = await api('/api/settings/limits', { signal: page.signal });
|
||||
const snapshot = () => JSON.stringify({ profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays].sort() });
|
||||
let form = fromData(data);
|
||||
let original = snapshot();
|
||||
const dirty = () => snapshot() !== original;
|
||||
guardChanges(page, dirty);
|
||||
const rules = data.rules;
|
||||
let errors = {};
|
||||
|
||||
function fromData(d) {
|
||||
return {
|
||||
profile: d.profile,
|
||||
values: structuredClone(d.current),
|
||||
pace: d.pace,
|
||||
gradualStart: d.gradualStart,
|
||||
activeDays: new Set(d.activeDays),
|
||||
jitterOn: d.current.jitterMinutes > 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** Any edit turns the profile into «Su misura» (spec §7.5). */
|
||||
function edited() {
|
||||
form.profile = 'custom';
|
||||
form.values.kind = 'custom';
|
||||
validate();
|
||||
drawCards();
|
||||
drawWindow();
|
||||
drawSaveBar();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- profile cards
|
||||
const cards = h('div.profili', { role: 'radiogroup', 'aria-label': t('impostazioni.limiti.profilo') });
|
||||
const customCard = h('div');
|
||||
function drawCards() {
|
||||
fill(cards, data.presets.map((p) => {
|
||||
const input = h('input.vh', { type: 'radio', name: 'profilo', value: p.kind, checked: form.profile === p.kind });
|
||||
input.addEventListener('change', () => choose(p));
|
||||
const budget = (kind) => p.budgets.find((b) => b.kind === kind)?.perDay ?? 0;
|
||||
return h(`label.profilo${form.profile === p.kind ? '.scelto' : ''}`,
|
||||
input,
|
||||
h('div.testa-profilo', h('span.tondo', { 'aria-hidden': 'true' }), h('b', p.name),
|
||||
p.kind === 'prudent' ? label(t('impostazioni.limiti.consigliato'), 'accento') : null,
|
||||
p.kind === 'fast' ? label(t('impostazioni.limiti.piuRischio'), 'ambra') : null),
|
||||
h('p', t(`impostazioni.limiti.profili.${p.kind}`)),
|
||||
h('p.riassunto', riassunto(budget('ProfileOpen'), budget('StoryView'), budget('BackfillPage'))));
|
||||
}));
|
||||
fill(customCard, form.profile === 'custom'
|
||||
? h('div.profilo.scelto.su-misura', h('div.testa-profilo', h('span.tondo.si', { 'aria-hidden': 'true' }), h('b', t('impostazioni.limiti.suMisura'))),
|
||||
h('p', t('impostazioni.limiti.suMisuraTesto')))
|
||||
: null);
|
||||
}
|
||||
|
||||
function riassunto(profiles, stories, history) {
|
||||
const text = t('impostazioni.limiti.riassunto', { profili: '\u0001', storie: '\u0002', storico: '\u0003' });
|
||||
return text.split(/([\u0001-\u0003])/).map((part) => part === '\u0001' ? h('b', number(profiles)) : part === '\u0002' ? h('b', number(stories)) : part === '\u0003' ? h('b', number(history)) : part);
|
||||
}
|
||||
|
||||
async function choose(preset) {
|
||||
if (preset.kind === 'fast' && form.profile !== 'fast') {
|
||||
const ok = await confirmDialog({
|
||||
title: t('impostazioni.limiti.rapidoTitolo'),
|
||||
text: t('impostazioni.limiti.rapidoTesto'),
|
||||
buttons: [
|
||||
{ label: t('comune.annulla'), value: false, kind: 'nudo', autofocus: true },
|
||||
{ label: t('impostazioni.limiti.rapidoConferma'), value: true, kind: 'primo' },
|
||||
],
|
||||
});
|
||||
if (!ok) {
|
||||
drawCards();
|
||||
return;
|
||||
}
|
||||
}
|
||||
form.profile = preset.kind;
|
||||
form.values = structuredClone(preset);
|
||||
form.jitterOn = preset.jitterMinutes > 0;
|
||||
drawAll();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- window and days
|
||||
const windowBar = h('div.fascia-barra');
|
||||
// Text fields with 24-hour times (a time input would follow the browser's locale, possibly with AM/PM).
|
||||
const timeField = (id) => h('input.dati', { type: 'text', id, inputmode: 'numeric', maxlength: '5', placeholder: '07:30', autocomplete: 'off', spellcheck: 'false' });
|
||||
const startInput = timeField('fascia-inizio');
|
||||
const endInput = timeField('fascia-fine');
|
||||
const readTime = (input, key) => {
|
||||
const value = input.value.trim().replace('.', ':');
|
||||
const m = /^(\d{1,2}):?(\d{2})$/.exec(value);
|
||||
form.values[key] = m && Number(m[1]) <= 24 && Number(m[2]) < 60 ? `${m[1].padStart(2, '0')}:${m[2]}` : value;
|
||||
edited();
|
||||
};
|
||||
startInput.addEventListener('change', () => readTime(startInput, 'windowStart'));
|
||||
endInput.addEventListener('change', () => readTime(endInput, 'windowEnd'));
|
||||
const days = h('div.giorni', { role: 'group', 'aria-label': t('impostazioni.limiti.giorni') });
|
||||
const jitterInput = h('input.dati', { type: 'number', min: '0', max: String(rules.maxJitterMinutes), step: '5', id: 'sposta', inputmode: 'numeric' });
|
||||
jitterInput.addEventListener('input', () => { form.values.jitterMinutes = toInt(jitterInput.value); edited(); });
|
||||
const jitterBox = checkbox({
|
||||
checked: form.jitterOn,
|
||||
labelNode: h('span', t('impostazioni.limiti.sposta')),
|
||||
onchange: (v) => {
|
||||
form.jitterOn = v;
|
||||
form.values.jitterMinutes = v ? Math.max(5, toInt(jitterInput.value) || 30) : 0;
|
||||
jitterInput.value = form.values.jitterMinutes;
|
||||
jitterInput.disabled = !v;
|
||||
edited();
|
||||
},
|
||||
});
|
||||
const windowError = h('p.errore-testo', { hidden: true });
|
||||
|
||||
function minutesOf(text) {
|
||||
const m = /^(\d{1,2}):(\d{2})$/.exec(String(text || ''));
|
||||
if (!m || Number(m[1]) > 24 || Number(m[2]) > 59) return null;
|
||||
return (Number(m[1]) * 60 + Number(m[2])) % 1440;
|
||||
}
|
||||
function textOf(minutes) {
|
||||
const v = ((Math.round(minutes) % 1440) + 1440) % 1440;
|
||||
return `${String(Math.floor(v / 60)).padStart(2, '0')}:${String(v % 60).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function drawWindow() {
|
||||
const start = minutesOf(form.values.windowStart) ?? 0;
|
||||
let end = minutesOf(form.values.windowEnd) ?? start;
|
||||
if (end === 0) end = 1440;
|
||||
const bands = end > start ? [[start, end]] : [[start, 1440], [0, end]];
|
||||
const pct = (m) => `${(m / 1440) * 100}%`;
|
||||
fill(windowBar,
|
||||
[3, 6, 9, 12, 15, 18, 21].map((hour) => h('span.tacca', { style: { left: pct(hour * 60) } })),
|
||||
bands.map(([a, b]) => h('span.banda', { style: { left: pct(a), width: pct(b - a) } })),
|
||||
handle('inizio', start), handle('fine', end % 1440 === 0 && end === 1440 ? 1440 : end));
|
||||
if (document.activeElement !== startInput) startInput.value = minutesOf(form.values.windowStart) == null ? form.values.windowStart : textOf(start);
|
||||
if (document.activeElement !== endInput) endInput.value = minutesOf(form.values.windowEnd) == null ? form.values.windowEnd : textOf(end);
|
||||
jitterInput.value = form.values.jitterMinutes;
|
||||
jitterInput.disabled = !form.jitterOn;
|
||||
jitterBox.input.checked = form.jitterOn;
|
||||
fill(days, DAY_ORDER.map((day, i) => {
|
||||
const on = form.activeDays.has(day);
|
||||
return h(`button.cerchio-giorno${on ? '.si' : ''}`, {
|
||||
type: 'button', 'aria-pressed': String(on), 'aria-label': list('impostazioni.limiti.nomiGiorni')[i], title: list('impostazioni.limiti.nomiGiorni')[i],
|
||||
onclick: () => {
|
||||
if (on) form.activeDays.delete(day);
|
||||
else form.activeDays.add(day);
|
||||
edited();
|
||||
},
|
||||
}, list('impostazioni.limiti.iniziali')[i]);
|
||||
}));
|
||||
const message = errors.window || errors.days || errors.jitter;
|
||||
windowError.hidden = !message;
|
||||
windowError.textContent = message || '';
|
||||
startInput.parentElement?.classList.toggle('errore', Boolean(errors.window));
|
||||
endInput.parentElement?.classList.toggle('errore', Boolean(errors.window));
|
||||
}
|
||||
|
||||
/** A draggable handle of the window bar (15-minute steps); the time fields stay the precise way. */
|
||||
function handle(which, minutes) {
|
||||
const el = h('span.maniglia', { style: { left: `${(minutes / 1440) * 100}%` }, 'aria-hidden': 'true' });
|
||||
el.addEventListener('pointerdown', (e) => {
|
||||
e.preventDefault();
|
||||
el.setPointerCapture(e.pointerId);
|
||||
const rect = windowBar.getBoundingClientRect();
|
||||
const move = (ev) => {
|
||||
const ratio = Math.min(1, Math.max(0, (ev.clientX - rect.left) / rect.width));
|
||||
const value = Math.round((ratio * 1440) / 15) * 15;
|
||||
if (which === 'inizio') form.values.windowStart = textOf(value);
|
||||
else form.values.windowEnd = textOf(value);
|
||||
edited();
|
||||
};
|
||||
const up = () => {
|
||||
el.removeEventListener('pointermove', move);
|
||||
el.removeEventListener('pointerup', up);
|
||||
};
|
||||
el.addEventListener('pointermove', move);
|
||||
el.addEventListener('pointerup', up);
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- sessions, pauses, pace
|
||||
const sessionRange = rangePair('sessione', 1, rules.maxSessionMinutes, () => [form.values.sessionMinMinutes, form.values.sessionMaxMinutes], (a, b) => {
|
||||
form.values.sessionMinMinutes = a;
|
||||
form.values.sessionMaxMinutes = b;
|
||||
edited();
|
||||
});
|
||||
const pauseRange = rangePair('pausa', rules.minPauseMinutes, 180, () => [form.values.pauseMinMinutes, form.values.pauseMaxMinutes], (a, b) => {
|
||||
form.values.pauseMinMinutes = a;
|
||||
form.values.pauseMaxMinutes = b;
|
||||
edited();
|
||||
});
|
||||
const paceInput = h('input.cursore.lungo', { type: 'range', min: '0', max: '2', step: '1', id: 'ritmo', 'aria-valuetext': '' });
|
||||
const paceText = h('span.valore-cursore');
|
||||
paceInput.addEventListener('input', () => {
|
||||
form.pace = PACES[Number(paceInput.value)];
|
||||
validate();
|
||||
drawPace();
|
||||
drawSaveBar();
|
||||
});
|
||||
function drawPace() {
|
||||
paceInput.value = String(PACES.indexOf(form.pace));
|
||||
paceText.textContent = t(`impostazioni.limiti.ritmi.${form.pace}`);
|
||||
paceInput.setAttribute('aria-valuetext', paceText.textContent);
|
||||
paceInput.style.setProperty('--pieno', `${(PACES.indexOf(form.pace) / 2) * 100}%`);
|
||||
}
|
||||
|
||||
/** Two thumbs on one track (minimum and maximum), with the text «da 2 a 10 minuti». */
|
||||
function rangePair(name, min, max, get, set) {
|
||||
const low = h('input.cursore', { type: 'range', min: String(min), max: String(max), step: '1', 'aria-label': `${t(`impostazioni.limiti.${name === 'sessione' ? 'durata' : 'pausa'}`)}, ${t('impostazioni.limiti.minimo')}` });
|
||||
const high = h('input.cursore', { type: 'range', min: String(min), max: String(max), step: '1', 'aria-label': `${t(`impostazioni.limiti.${name === 'sessione' ? 'durata' : 'pausa'}`)}, ${t('impostazioni.limiti.massimo')}` });
|
||||
const fillBar = h('span.tratto');
|
||||
const text = h('span.valore-cursore');
|
||||
const error = h('p.errore-testo', { hidden: true });
|
||||
const track = h('div.doppio', h('span.binario'), fillBar, low, high);
|
||||
const sync = () => {
|
||||
const [a, b] = get();
|
||||
low.value = String(Math.max(min, Math.min(max, a)));
|
||||
high.value = String(Math.max(min, Math.min(max, b)));
|
||||
const left = ((Number(low.value) - min) / (max - min)) * 100;
|
||||
const right = ((Number(high.value) - min) / (max - min)) * 100;
|
||||
fillBar.style.left = `${left}%`;
|
||||
fillBar.style.width = `${Math.max(0, right - left)}%`;
|
||||
text.textContent = t('impostazioni.limiti.daA', { a, b });
|
||||
low.setAttribute('aria-valuetext', `${a} ${t('impostazioni.limiti.minuti')}`);
|
||||
high.setAttribute('aria-valuetext', `${b} ${t('impostazioni.limiti.minuti')}`);
|
||||
const message = errors[name];
|
||||
error.hidden = !message;
|
||||
error.textContent = message || '';
|
||||
};
|
||||
low.addEventListener('input', () => {
|
||||
const a = Number(low.value);
|
||||
const [, b] = get();
|
||||
set(a, Math.max(a, b));
|
||||
});
|
||||
high.addEventListener('input', () => {
|
||||
const b = Number(high.value);
|
||||
const [a] = get();
|
||||
set(Math.min(a, b), b);
|
||||
});
|
||||
return { track, text, error, sync };
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- budgets table
|
||||
const table = h('tbody');
|
||||
const cells = new Map();
|
||||
function paintErrors() {
|
||||
for (const [key, ref] of cells) {
|
||||
ref.field.classList.toggle('errore', Boolean(errors[key]));
|
||||
ref.message.hidden = !errors[key];
|
||||
ref.message.textContent = errors[key] || '';
|
||||
}
|
||||
}
|
||||
function drawTable() {
|
||||
cells.clear();
|
||||
const v = form.values;
|
||||
const numberCell = (value, max, onInput, key, unit) => {
|
||||
const input = h('input.dati', { type: 'number', min: '0', max: String(max), step: unit === 'gb' ? '0.5' : '1', value: String(value), inputmode: unit === 'gb' ? 'decimal' : 'numeric', 'aria-label': key });
|
||||
input.addEventListener('input', () => onInput(input.value));
|
||||
const field = h('label.campo.numero', input, unit ? h('span.unita', t(`impostazioni.limiti.${unit}`)) : null);
|
||||
const message = h('div.errore-testo', { hidden: true });
|
||||
cells.set(key, { field, message });
|
||||
return h('td', field, message);
|
||||
};
|
||||
const rows = v.budgets.map((b) => h('tr',
|
||||
h('td', b.label),
|
||||
numberCell(b.perHour, b.maxPerHour, (x) => { b.perHour = toInt(x); edited(); }, `${b.kind}-ora`),
|
||||
numberCell(b.perDay, b.maxPerDay, (x) => { b.perDay = toInt(x); edited(); }, `${b.kind}-giorno`)));
|
||||
rows.push(h('tr',
|
||||
h('td', t('impostazioni.limiti.dati')),
|
||||
h('td.muto', '—'),
|
||||
numberCell(decimal(v.dataPerDayGb, 2).replace(',', '.'), rules.maxDataPerDayGb, (x) => { v.dataPerDayGb = String(x).trim() === '' ? NaN : Number(String(x).replace(',', '.')); edited(); }, 'dati', 'gb')));
|
||||
rows.push(h('tr',
|
||||
h('td', t('impostazioni.limiti.storico'), h('div.muto.piccolo', t('impostazioni.limiti.storicoNota'))),
|
||||
h('td.muto', '—'),
|
||||
numberCell(v.backfillPerAccount, rules.maxBackfillPerAccount, (x) => { v.backfillPerAccount = toInt(x); edited(); }, 'storico', 'post')));
|
||||
const gradual = toggle({ checked: form.gradualStart, label: t('impostazioni.limiti.graduale'), onchange: (on) => { form.gradualStart = on; validate(); drawTable(); drawSaveBar(); } });
|
||||
rows.push(h('tr.riga-graduale',
|
||||
h('td', gradual, h('div.muto.piccolo', t('impostazioni.limiti.gradualeAiuto'))),
|
||||
h('td.muto', '—'),
|
||||
form.gradualStart ? numberCell(v.rampUpDays, rules.maxRampUpDays, (x) => { v.rampUpDays = toInt(x); edited(); }, 'graduale', 'giorniGraduale') : h('td.muto', '—')));
|
||||
rows.push(h('tr.informativa',
|
||||
h('td', h('span', icon('lock', 'xs'), ' ', t('impostazioni.limiti.arresti')), h('div.muto.piccolo', t('impostazioni.limiti.arrestiTesto'))),
|
||||
h('td.muto', data.stops.join(' · ')),
|
||||
h('td.muto', t('impostazioni.limiti.arrestiFissi'))));
|
||||
fill(table, rows);
|
||||
paintErrors();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- validation
|
||||
function validate() {
|
||||
const v = form.values;
|
||||
const e = {};
|
||||
const start = minutesOf(v.windowStart);
|
||||
const end = minutesOf(v.windowEnd);
|
||||
if (start == null || end == null) e.window = t('impostazioni.limiti.errori.ora');
|
||||
else {
|
||||
let length = end - start;
|
||||
if (length <= 0) length += 1440;
|
||||
if (length > rules.maxWindowHours * 60) e.window = t('impostazioni.limiti.errori.fascia', { n: rules.maxWindowHours });
|
||||
}
|
||||
if (form.activeDays.size === 0) e.days = t('impostazioni.limiti.errori.giorni');
|
||||
if (!(v.jitterMinutes >= 0 && v.jitterMinutes <= rules.maxJitterMinutes)) e.jitter = t('impostazioni.limiti.errori.sposta', { n: rules.maxJitterMinutes });
|
||||
if (v.sessionMaxMinutes > rules.maxSessionMinutes) e.sessione = t('impostazioni.limiti.errori.sessione', { n: rules.maxSessionMinutes });
|
||||
else if (v.sessionMinMinutes < 1) e.sessione = t('impostazioni.limiti.errori.sessioneMin');
|
||||
else if (v.sessionMinMinutes > v.sessionMaxMinutes) e.sessione = t('impostazioni.limiti.errori.minMax');
|
||||
if (v.pauseMinMinutes < rules.minPauseMinutes) e.pausa = t('impostazioni.limiti.errori.pausa', { n: rules.minPauseMinutes });
|
||||
else if (v.pauseMinMinutes > v.pauseMaxMinutes) e.pausa = t('impostazioni.limiti.errori.minMax');
|
||||
for (const b of v.budgets) {
|
||||
if (!Number.isInteger(b.perHour) || b.perHour < 0) e[`${b.kind}-ora`] = t('impostazioni.limiti.errori.numero');
|
||||
else if (b.perHour > b.maxPerHour) e[`${b.kind}-ora`] = t('impostazioni.limiti.errori.tetto', { max: number(b.maxPerHour) });
|
||||
if (!Number.isInteger(b.perDay) || b.perDay < 0) e[`${b.kind}-giorno`] = t('impostazioni.limiti.errori.numero');
|
||||
else if (b.perDay > b.maxPerDay) e[`${b.kind}-giorno`] = t('impostazioni.limiti.errori.tetto', { max: number(b.maxPerDay) });
|
||||
}
|
||||
if (!(v.dataPerDayGb >= 0)) e.dati = t('impostazioni.limiti.errori.numero');
|
||||
else if (v.dataPerDayGb > rules.maxDataPerDayGb) e.dati = t('impostazioni.limiti.errori.tetto', { max: `${decimal(rules.maxDataPerDayGb, 1)} GB` });
|
||||
if (!Number.isInteger(v.backfillPerAccount) || v.backfillPerAccount < 0) e.storico = t('impostazioni.limiti.errori.numero');
|
||||
else if (v.backfillPerAccount > rules.maxBackfillPerAccount) e.storico = t('impostazioni.limiti.errori.tetto', { max: `${number(rules.maxBackfillPerAccount)} post` });
|
||||
if (form.gradualStart && !(Number.isInteger(v.rampUpDays) && v.rampUpDays >= 0 && v.rampUpDays <= rules.maxRampUpDays)) e.graduale = t('impostazioni.limiti.errori.graduale', { n: rules.maxRampUpDays });
|
||||
errors = e;
|
||||
sessionRange.sync();
|
||||
pauseRange.sync();
|
||||
paintErrors();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- save bar
|
||||
function drawSaveBar() {
|
||||
const changed = dirty();
|
||||
const invalid = Object.keys(errors).length > 0;
|
||||
page.saveBar(h('div', { style: { display: 'contents' } },
|
||||
h('span.nota', invalid ? h('span.errore-testo', icon('octagon-alert', 'xs'), ' ', t('impostazioni.limiti.errori.correggi')) : t(changed ? 'impostazioni.modifiche' : 'impostazioni.nessunaModifica')),
|
||||
h('div.destra',
|
||||
h('button.btn', { type: 'button', disabled: !changed, onclick: discard }, t('impostazioni.annulla')),
|
||||
h('button.btn.primo', { type: 'button', disabled: !changed || invalid, onclick: save }, icon('check'), t('impostazioni.salva')))));
|
||||
}
|
||||
|
||||
function discard() {
|
||||
form = fromData(data);
|
||||
drawAll();
|
||||
}
|
||||
|
||||
async function save() {
|
||||
try {
|
||||
data = await api('/api/settings/limits', {
|
||||
method: 'PUT',
|
||||
body: { profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays] },
|
||||
});
|
||||
form = fromData(data);
|
||||
original = snapshot();
|
||||
drawAll();
|
||||
toast(t('impostazioni.limiti.salvati'));
|
||||
refreshEngine();
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
}
|
||||
}
|
||||
|
||||
function drawAll() {
|
||||
validate();
|
||||
drawCards();
|
||||
drawWindow();
|
||||
drawPace();
|
||||
drawTable();
|
||||
drawSaveBar();
|
||||
}
|
||||
|
||||
drawAll();
|
||||
original = snapshot();
|
||||
drawSaveBar();
|
||||
|
||||
fill(box,
|
||||
h('div.avviso.ambra.avviso-limiti', icon('triangle-alert', 's'), h('span', t('impostazioni.limiti.avviso'))),
|
||||
h('div.sezione', heading(t('impostazioni.limiti.profilo'), t('impostazioni.limiti.profiloAiuto')), cards, customCard),
|
||||
h('div.sezione',
|
||||
heading(t('impostazioni.limiti.orari'), t('impostazioni.limiti.orariAiuto')),
|
||||
windowBar,
|
||||
h('div.ore', { 'aria-hidden': 'true' }, [0, 3, 6, 9, 12, 15, 18, 21, 24].map((hour) => h('span', { style: { left: `${(hour / 24) * 100}%` } }, String(hour)))),
|
||||
h('div.riga-fascia',
|
||||
h('label.etichetta-riga', { for: 'fascia-inizio' }, t('impostazioni.limiti.dalle')), h('span.campo.ora', startInput),
|
||||
h('label.etichetta-riga', { for: 'fascia-fine' }, t('impostazioni.limiti.alle')), h('span.campo.ora', endInput),
|
||||
h('span.etichetta-riga.giorni-etichetta', t('impostazioni.limiti.giorni')), days),
|
||||
h('div.riga-sposta', jitterBox, h('span.campo.numero.corto', jitterInput), h('span.muto', t('impostazioni.limiti.minuti'))),
|
||||
windowError),
|
||||
h('div.sezione',
|
||||
heading(t('impostazioni.limiti.sessioni'), t('impostazioni.limiti.sessioniAiuto')),
|
||||
h('div.cursori',
|
||||
h('span.etichetta-riga', t('impostazioni.limiti.durata')), sessionRange.track, sessionRange.text, sessionRange.error,
|
||||
h('span.etichetta-riga', t('impostazioni.limiti.pausa')), pauseRange.track, pauseRange.text, pauseRange.error,
|
||||
h('label.etichetta-riga', { for: 'ritmo' }, t('impostazioni.limiti.ritmo')), h('div.singolo', paceInput), paceText)),
|
||||
h('div.sezione',
|
||||
heading(t('impostazioni.limiti.tetti'), t('impostazioni.limiti.tettiAiuto')),
|
||||
h('div.pannello.tabella-tetti', h('table.tab',
|
||||
h('thead', h('tr', h('th', t('impostazioni.limiti.colonne.attivita')), h('th', t('impostazioni.limiti.colonne.ora')), h('th', t('impostazioni.limiti.colonne.giorno')))),
|
||||
table))));
|
||||
}
|
||||
|
||||
function toInt(text) {
|
||||
const trimmed = String(text).trim();
|
||||
if (trimmed === '') return NaN;
|
||||
const n = Number(trimmed);
|
||||
return Number.isFinite(n) ? Math.round(n) : NaN;
|
||||
}
|
||||
Reference in new issue
Block a user