Add mobile-first web UI
Compare (duel with row-by-row comparison and thumb-reach pick bar), Ranking, Triage (keep/drop pass, problem schools first), school detail with sources and notes, Settings. Picks go to a localStorage outbox first and sync in the background, so nothing is lost on a flaky connection. Light/dark themes, installable to the home screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gXkMmmRRKLSnY6vQN3
This commit is contained in:
parent
67f9b199ec
commit
0951f34a9d
15 changed files with 1531 additions and 0 deletions
110
public/js/views/settings.js
Normal file
110
public/js/views/settings.js
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
// Preferences (synced to the server), per-device display options, data export/import, about.
|
||||
|
||||
import { html, extLink, local } from '../ui.js';
|
||||
import { LANG_NAMES } from '../metrics.js';
|
||||
|
||||
const LEVELS = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2'];
|
||||
|
||||
export function render(root, app) {
|
||||
const s = app.settings;
|
||||
const theme = local.get('theme', 'system');
|
||||
const researched = app.data.schools.filter((x) => x.research).length;
|
||||
const f = app.data.funding;
|
||||
root.innerHTML = String(html`
|
||||
<section class="settings">
|
||||
<h2>Your situation</h2>
|
||||
<label class="field">Stay length (months)
|
||||
<input type="number" name="stayMonths" min="1" max="12" step="0.5" value="${s.stayMonths}" inputmode="decimal">
|
||||
</label>
|
||||
<fieldset class="field"><legend>Currency</legend>
|
||||
<div class="seg">
|
||||
${['EUR', 'CZK'].map((c) => html`<label><input type="radio" name="currency" value="${c}" ${s.currency === c ? 'checked' : ''}> ${c}</label>`)}
|
||||
</div>
|
||||
</fieldset>
|
||||
<label class="check"><input type="checkbox" name="fewerOpportunities" ${s.fewerOpportunities ? 'checked' : ''}>
|
||||
I qualify for the Erasmus+ fewer-opportunities top-up (+${f.erasmus.fewerOpportunitiesTopUpEUR ?? 250} €/month)</label>
|
||||
<label class="check"><input type="checkbox" name="countHostFunding" ${s.countHostFunding ? 'checked' : ''}>
|
||||
Count host scholarships (e.g. JASSO) in the money totals. They're competitive, so it's off by default.</label>
|
||||
|
||||
<fieldset class="field"><legend>Your languages</legend>
|
||||
<ul class="langs">${s.languages.map((l, i) => html`
|
||||
<li><span>${LANG_NAMES[l.lang] ?? l.lang}</span>
|
||||
<select name="level" data-i="${i}" aria-label="Level">${LEVELS.map((lv) => html`<option ${lv === l.level ? 'selected' : ''}>${lv}</option>`)}</select>
|
||||
<button type="button" class="link" data-action="rmlang" data-i="${i}">Remove</button></li>`)}
|
||||
</ul>
|
||||
<div class="addlang">
|
||||
<select name="newlang" aria-label="Add language">
|
||||
${Object.entries(LANG_NAMES).filter(([k]) => !s.languages.some((l) => l.lang === k))
|
||||
.map(([k, v]) => html`<option value="${k}">${v}</option>`)}
|
||||
</select>
|
||||
<button type="button" class="btn ghost" data-action="addlang">Add</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="field"><legend>Next pair</legend>
|
||||
<div class="seg">
|
||||
<label><input type="radio" name="pairing" value="smart" ${s.pairing === 'smart' ? 'checked' : ''}> Smart</label>
|
||||
<label><input type="radio" name="pairing" value="random" ${s.pairing === 'random' ? 'checked' : ''}> Random</label>
|
||||
</div>
|
||||
<p class="muted small">Smart shows rarely compared schools first, then close contests: fewer picks for the same ranking quality.</p>
|
||||
</fieldset>
|
||||
|
||||
<h2>This device</h2>
|
||||
<fieldset class="field"><legend>Theme</legend>
|
||||
<div class="seg">
|
||||
${['system', 'light', 'dark'].map((t) => html`<label><input type="radio" name="theme" value="${t}" ${theme === t ? 'checked' : ''}> ${t}</label>`)}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h2>Your data</h2>
|
||||
<p class="small">Picks, notes and settings live on your server (DATA_DIR). Export a backup now and then.</p>
|
||||
<div class="row">
|
||||
<a class="btn ghost" href="api/export" download>Export backup</a>
|
||||
<label class="btn ghost file">Import backup<input type="file" name="import" accept="application/json,.json"></label>
|
||||
${app.config.authRequired ? html`<button type="button" class="btn ghost" data-action="logout">Log out</button>` : ''}
|
||||
</div>
|
||||
|
||||
<h2>About the data</h2>
|
||||
<ul class="small about">
|
||||
<li>Catalog: CTU Mobility, FEL, Master, ${app.data.catalog.academicYear}, saved ${app.data.catalog.savedAt?.slice(4, 15) ?? '?'}.</li>
|
||||
<li>Research: ${researched} of ${app.data.schools.length} schools so far. Data built ${app.data.generatedAt.slice(0, 10)}.</li>
|
||||
<li>Erasmus+ rates: ${f.erasmus.status}.</li>
|
||||
<li>Selection round: ${f.selection.deadline}</li>
|
||||
<li>Exchange rate: 1 € = ${app.data.fx.EURCZK} Kč (${app.data.fx.date}).</li>
|
||||
<li>Everything here was gathered from public web sources and can be wrong or outdated.
|
||||
Check money, language rules and deadlines with the FEL international office before you apply.</li>
|
||||
<li>Selection info sources: ${f.selection.sources.slice(0, 3).map((x) => html`${extLink(x.url, x.label)}; `)}</li>
|
||||
</ul>
|
||||
<p class="muted small">Elorasmus ${app.config.version}</p>
|
||||
</section>`);
|
||||
|
||||
const update = (patch) => app.updateSettings(patch);
|
||||
root.onchange = async (e) => {
|
||||
const el = e.target;
|
||||
if (el.name === 'stayMonths') {
|
||||
const v = Number(el.value);
|
||||
if (v >= 1 && v <= 12) update({ stayMonths: v });
|
||||
} else if (el.name === 'currency' || el.name === 'pairing') update({ [el.name]: el.value });
|
||||
else if (el.name === 'fewerOpportunities' || el.name === 'countHostFunding') update({ [el.name]: el.checked });
|
||||
else if (el.name === 'level') {
|
||||
const langs = s.languages.map((l, i) => (i === Number(el.dataset.i) ? { ...l, level: el.value } : l));
|
||||
update({ languages: langs });
|
||||
} else if (el.name === 'theme') {
|
||||
local.set('theme', el.value);
|
||||
app.applyTheme();
|
||||
} else if (el.name === 'import' && el.files?.[0]) {
|
||||
app.importBackup(el.files[0]);
|
||||
el.value = '';
|
||||
}
|
||||
};
|
||||
root.onclick = (e) => {
|
||||
const t = e.target.closest('[data-action]');
|
||||
if (!t) return;
|
||||
if (t.dataset.action === 'rmlang') update({ languages: s.languages.filter((_, i) => i !== Number(t.dataset.i)) });
|
||||
if (t.dataset.action === 'addlang') {
|
||||
const lang = root.querySelector('select[name="newlang"]').value;
|
||||
if (lang) update({ languages: [...s.languages, { lang, level: 'B1' }] });
|
||||
}
|
||||
if (t.dataset.action === 'logout') app.logout();
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue