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
125
public/js/views/duel.js
Normal file
125
public/js/views/duel.js
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
// The main screen: two schools side by side, a comparison table, and pick buttons in thumb reach.
|
||||
|
||||
import { html, bar } from '../ui.js';
|
||||
import { COMPARE_ROWS, rowWinner, shortName, place } from '../metrics.js';
|
||||
import { PROVISIONAL_GAMES } from '../elo.js';
|
||||
|
||||
function head(app, s, side) {
|
||||
const st = app.state.stats.get(s.code);
|
||||
const rank = app.rankOf(s.code);
|
||||
const provisional = st.games < PROVISIONAL_GAMES;
|
||||
return html`
|
||||
<button type="button" class="school-head side-${side}" data-action="open" data-slug="${s.slug}"
|
||||
aria-label="Details for ${shortName(s)}">
|
||||
<span class="side-tag">${side.toUpperCase()}</span>
|
||||
<span class="flag" aria-hidden="true">${s.flag}</span>
|
||||
<span class="sname">${shortName(s)}</span>
|
||||
<span class="splace">${place(s)}</span>
|
||||
<span class="srating ${provisional ? 'provisional' : ''}">
|
||||
${provisional ? '~' : ''}${Math.round(st.rating)}
|
||||
<small>${rank && st.games ? `#${rank} · ` : ''}${st.games} ${st.games === 1 ? 'game' : 'games'}</small>
|
||||
</span>
|
||||
${s.research ? '' : html`<span class="chip warn">research pending</span>`}
|
||||
</button>`;
|
||||
}
|
||||
|
||||
function table(app, a, b) {
|
||||
let section = '';
|
||||
const rows = [];
|
||||
for (const row of COMPARE_ROWS) {
|
||||
if (row.section !== section) {
|
||||
section = row.section;
|
||||
rows.push(html`<div class="cmp-section">${section}</div>`);
|
||||
}
|
||||
const va = row.get(a, app.ctx);
|
||||
const vb = row.get(b, app.ctx);
|
||||
if (!va && !vb) continue;
|
||||
const win = rowWinner(row, va, vb);
|
||||
const cell = (v, side) => {
|
||||
if (!v) return html`<div class="cmp-val muted">–</div>`;
|
||||
const content = v.bar != null ? bar(v.bar) : html`<span class="txt ${v.tone ? `tone-${v.tone}` : ''}">${v.text}</span>`;
|
||||
return html`<div class="cmp-val ${win === side ? `win win-${side}` : ''}">${content}</div>`;
|
||||
};
|
||||
rows.push(html`
|
||||
<div class="cmp-row" ${row.hint ? html`title="${row.hint}"` : ''}>
|
||||
<div class="cmp-label">${row.label}</div>${cell(va, 'a')}${cell(vb, 'b')}
|
||||
</div>`);
|
||||
}
|
||||
return html`<div class="cmp">${rows}</div>`;
|
||||
}
|
||||
|
||||
function flagsBlock(s, side) {
|
||||
const r = s.research;
|
||||
if (!r) return '';
|
||||
const items = [
|
||||
...r.highlights.slice(0, 3).map((t) => html`<li class="hl">${t}</li>`),
|
||||
...r.watchouts.slice(0, 3).map((t) => html`<li class="wo">${t}</li>`),
|
||||
];
|
||||
return html`
|
||||
<div class="flags side-${side}">
|
||||
<h3><span class="side-tag">${side.toUpperCase()}</span> ${shortName(s)}</h3>
|
||||
<p class="summary">${r.summary}</p>
|
||||
<ul>${items}</ul>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
export function render(root, app) {
|
||||
const pair = app.currentPair();
|
||||
if (!pair) {
|
||||
root.innerHTML = String(html`
|
||||
<section class="empty">
|
||||
<h2>Not enough schools left</h2>
|
||||
<p>You need at least two schools that aren't dropped. Restore some in the ranking.</p>
|
||||
<a class="btn" href="#/rank">Open the ranking</a>
|
||||
</section>`);
|
||||
return;
|
||||
}
|
||||
const [a, b] = pair.map((c) => app.byCode.get(c));
|
||||
const undoable = app.state.lastUndoable;
|
||||
root.innerHTML = String(html`
|
||||
<section class="duel" aria-label="Which school do you prefer?">
|
||||
<p class="prompt">Which would you rather go to?</p>
|
||||
<div class="duel-heads">${head(app, a, 'a')}<span class="vs" aria-hidden="true">vs</span>${head(app, b, 'b')}</div>
|
||||
${table(app, a, b)}
|
||||
<div class="duel-flags">${flagsBlock(a, 'a')}${flagsBlock(b, 'b')}</div>
|
||||
<div class="duel-drop">
|
||||
<button type="button" class="link" data-action="drop" data-code="${a.code}">Drop A from the race</button>
|
||||
<button type="button" class="link" data-action="drop" data-code="${b.code}">Drop B from the race</button>
|
||||
</div>
|
||||
</section>
|
||||
<div class="actionbar" role="group" aria-label="Pick">
|
||||
<div class="actionbar-sub">
|
||||
<button type="button" class="ghost" data-action="undo" ${undoable ? '' : 'disabled'}>Undo</button>
|
||||
<span class="muted small">${app.state.matches.length} picks</span>
|
||||
<button type="button" class="ghost" data-action="skip">Skip</button>
|
||||
</div>
|
||||
<div class="actionbar-main">
|
||||
<button type="button" class="pick pick-a" data-action="pick" data-r="a"><span>A</span> ${shortName(a)}</button>
|
||||
<button type="button" class="pick pick-draw" data-action="pick" data-r="draw" aria-label="Too close to call">=</button>
|
||||
<button type="button" class="pick pick-b" data-action="pick" data-r="b">${shortName(b)} <span>B</span></button>
|
||||
</div>
|
||||
</div>`);
|
||||
|
||||
root.onclick = (e) => {
|
||||
const t = e.target.closest('[data-action]');
|
||||
if (!t || t.disabled) return;
|
||||
const action = t.dataset.action;
|
||||
if (action === 'pick') app.pick(a.code, b.code, t.dataset.r);
|
||||
else if (action === 'skip') app.skip();
|
||||
else if (action === 'undo') app.undo();
|
||||
else if (action === 'drop') app.drop(t.dataset.code);
|
||||
else if (action === 'open') app.navigate(`#/school/${t.dataset.slug}`);
|
||||
};
|
||||
}
|
||||
|
||||
/** Desktop shortcuts: ←/→ pick, ↓ or = draw, space skip, z/backspace undo. */
|
||||
export function onKey(e, app) {
|
||||
if (e.target.closest('input, textarea, select')) return false;
|
||||
const pair = app.currentPair();
|
||||
if (!pair) return false;
|
||||
const map = { ArrowLeft: 'a', ArrowRight: 'b', ArrowDown: 'draw', '=': 'draw' };
|
||||
if (map[e.key]) { app.pick(pair[0], pair[1], map[e.key]); return true; }
|
||||
if (e.key === ' ') { app.skip(); return true; }
|
||||
if (e.key === 'z' || e.key === 'Backspace') { app.undo(); return true; }
|
||||
return false;
|
||||
}
|
||||
116
public/js/views/rank.js
Normal file
116
public/js/views/rank.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// Leaderboard: everything ordered by your Elo, with filters and alternative sort orders.
|
||||
|
||||
import { html, local } from '../ui.js';
|
||||
import { shortName, place, netCost, moneyRange, languageFit } from '../metrics.js';
|
||||
import { ranking, PROVISIONAL_GAMES } from '../elo.js';
|
||||
|
||||
const SORTS = {
|
||||
rating: { label: 'My Elo', key: (s, st) => -st.rating },
|
||||
academic: { label: 'AI/robotics research', key: (s) => -(s.research?.aiRobotics?.academic?.score ?? -1) },
|
||||
access: { label: 'Course access', key: (s) => -(s.research?.aiRobotics?.access?.score ?? -1) },
|
||||
net: { label: 'Cheapest', key: (s, st, app) => { const n = netCost(s, app.settings, app.data); return n ? (n.lo + n.hi) / 2 : 1e9; } },
|
||||
nature: { label: 'Nature (avg)', key: (s) => {
|
||||
const n = s.research?.nature;
|
||||
return n ? -(n.climbing.score + n.hiking.score + n.ocean.score) / 3 : 1;
|
||||
} },
|
||||
name: { label: 'Name', key: (s) => shortName(s).toLowerCase() },
|
||||
};
|
||||
|
||||
export function render(root, app) {
|
||||
const prefs = local.get('rank', { q: '', region: '', scope: '', sort: 'rating', dropped: false });
|
||||
const all = ranking(app.state.stats, { includeDropped: true });
|
||||
const position = new Map(ranking(app.state.stats).map((s, i) => [s.code, i + 1]));
|
||||
const q = prefs.q.trim().toLowerCase();
|
||||
const regions = [...new Set(app.data.schools.map((s) => s.region))].sort();
|
||||
|
||||
const rows = all
|
||||
.map((st) => ({ st, s: app.byCode.get(st.code) }))
|
||||
.filter(({ s, st }) => (prefs.dropped ? st.dropped : !st.dropped))
|
||||
.filter(({ s }) => !prefs.region || s.region === prefs.region)
|
||||
.filter(({ s }) => !prefs.scope || s.agreements.some((a) => a.scope === prefs.scope))
|
||||
.filter(({ s }) => !q || `${shortName(s)} ${s.research?.name ?? ''} ${s.catalogName} ${s.research?.city ?? ''} ${s.countryShort} ${s.code}`
|
||||
.toLowerCase().includes(q));
|
||||
const sort = SORTS[prefs.sort] ?? SORTS.rating;
|
||||
rows.sort((x, y) => {
|
||||
const kx = sort.key(x.s, x.st, app);
|
||||
const ky = sort.key(y.s, y.st, app);
|
||||
return kx < ky ? -1 : kx > ky ? 1 : y.st.rating - x.st.rating;
|
||||
});
|
||||
const droppedCount = all.filter((s) => s.dropped).length;
|
||||
|
||||
root.innerHTML = String(html`
|
||||
<section class="rank">
|
||||
<div class="rank-tools">
|
||||
<input type="search" name="q" value="${prefs.q}" placeholder="Search school, city, country" aria-label="Search">
|
||||
<div class="rank-filters">
|
||||
<select name="region" aria-label="Region">
|
||||
<option value="">All regions</option>
|
||||
${regions.map((r) => html`<option value="${r}" ${prefs.region === r ? 'selected' : ''}>${r}</option>`)}
|
||||
</select>
|
||||
<select name="scope" aria-label="Agreement type">
|
||||
<option value="">All types</option>
|
||||
<option value="FEL" ${prefs.scope === 'FEL' ? 'selected' : ''}>FEL agreements</option>
|
||||
<option value="CTU-wide" ${prefs.scope === 'CTU-wide' ? 'selected' : ''}>CTU-wide</option>
|
||||
</select>
|
||||
<select name="sort" aria-label="Sort by">
|
||||
${Object.entries(SORTS).map(([k, v]) => html`<option value="${k}" ${prefs.sort === k ? 'selected' : ''}>${v.label}</option>`)}
|
||||
</select>
|
||||
</div>
|
||||
<label class="check"><input type="checkbox" name="dropped" ${prefs.dropped ? 'checked' : ''}> Show dropped (${droppedCount})</label>
|
||||
</div>
|
||||
<p class="muted small">${rows.length} schools · ${app.state.matches.length} picks so far</p>
|
||||
<ol class="rank-list">
|
||||
${rows.map(({ s, st }) => {
|
||||
const n = netCost(s, app.settings, app.data);
|
||||
const lang = languageFit(s, app.settings.languages);
|
||||
const ai = s.research?.aiRobotics?.academic?.score;
|
||||
return html`
|
||||
<li>
|
||||
<button type="button" class="rank-row ${st.dropped ? 'dropped' : ''}" data-action="open" data-slug="${s.slug}">
|
||||
<span class="pos">${st.dropped ? '–' : position.get(s.code)}</span>
|
||||
<span class="flag" aria-hidden="true">${s.flag}</span>
|
||||
<span class="rmain">
|
||||
<span class="rname">${shortName(s)}</span>
|
||||
<span class="rmeta">${place(s)}${lang.status === 'fail' ? html` · <em class="tone-fail">${lang.text}</em>` : ''}</span>
|
||||
<span class="rchips">
|
||||
${ai != null ? html`<span class="chip">AI ${ai}</span>` : html`<span class="chip warn">pending</span>`}
|
||||
${n ? html`<span class="chip">${moneyRange([n.lo, n.hi], app.settings, app.data, { compact: true })}</span>` : ''}
|
||||
${s.agreements.some((a) => a.scope === 'FEL') ? html`<span class="chip">FEL</span>` : html`<span class="chip">CTU</span>`}
|
||||
</span>
|
||||
</span>
|
||||
<span class="rscore ${st.games < PROVISIONAL_GAMES ? 'provisional' : ''}">
|
||||
${Math.round(st.rating)}<small>${st.wins}–${st.losses}${st.draws ? `–${st.draws}` : ''}</small>
|
||||
</span>
|
||||
</button>
|
||||
${st.dropped ? html`<button type="button" class="link restore" data-action="restore" data-code="${s.code}">Restore</button>` : ''}
|
||||
</li>`;
|
||||
})}
|
||||
</ol>
|
||||
</section>`);
|
||||
|
||||
const save = (patch) => { local.set('rank', { ...prefs, ...patch }); render(root, app); };
|
||||
root.onclick = (e) => {
|
||||
const t = e.target.closest('[data-action]');
|
||||
if (!t) return;
|
||||
if (t.dataset.action === 'open') app.navigate(`#/school/${t.dataset.slug}`);
|
||||
if (t.dataset.action === 'restore') app.restore(t.dataset.code);
|
||||
};
|
||||
root.onchange = (e) => {
|
||||
const el = e.target;
|
||||
if (el.name === 'dropped') save({ dropped: el.checked });
|
||||
else if (['region', 'scope', 'sort'].includes(el.name)) save({ [el.name]: el.value });
|
||||
};
|
||||
let typing;
|
||||
root.oninput = (e) => {
|
||||
if (e.target.name !== 'q') return;
|
||||
clearTimeout(typing);
|
||||
const value = e.target.value;
|
||||
typing = setTimeout(() => {
|
||||
save({ q: value });
|
||||
const input = root.querySelector('input[name="q"]');
|
||||
input.focus();
|
||||
input.setSelectionRange(value.length, value.length);
|
||||
}, 250);
|
||||
};
|
||||
}
|
||||
|
||||
210
public/js/views/school.js
Normal file
210
public/js/views/school.js
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
// Everything known about one school: catalog agreements, all research sections with sources,
|
||||
// money breakdown for your stay, your notes, and your pick history for it.
|
||||
|
||||
import { html, bar, extLink, ICONS } from '../ui.js';
|
||||
import {
|
||||
shortName, fullName, place, languageFit, subjectFit, monthlyGrant, netCost, money, moneyRange, LANG_NAMES,
|
||||
} from '../metrics.js';
|
||||
|
||||
const CONF_LABEL = { high: 'high confidence', medium: 'medium confidence', low: 'low confidence' };
|
||||
const conf = (c) => (c ? html`<span class="conf conf-${c}">${CONF_LABEL[c]}</span>` : '');
|
||||
const para = (t) => (t ? html`<p>${t}</p>` : '');
|
||||
const list = (items, cls = '') => (items?.length ? html`<ul class="${cls}">${items.map((i) => html`<li>${i}</li>`)}</ul>` : '');
|
||||
|
||||
function scored(label, node, tone = '') {
|
||||
if (!node) return '';
|
||||
return html`<div class="scored"><div class="scored-head"><span>${label}</span>${bar(node.score, tone)}</div>${para(node.text)}</div>`;
|
||||
}
|
||||
|
||||
function section(title, body, confidence) {
|
||||
return html`<section class="dsec"><h2>${title} ${conf(confidence)}</h2>${body}</section>`;
|
||||
}
|
||||
|
||||
function agreementsBlock(s, app) {
|
||||
return html`
|
||||
<ul class="agreements">
|
||||
${s.agreements.map((a) => html`
|
||||
<li>
|
||||
<div><span class="chip">${a.scope === 'FEL' ? 'FEL agreement' : 'CTU-wide'}</span>
|
||||
<b>${a.places == null ? '?' : a.places >= 99 ? 'open' : a.places}</b> place${a.places === 1 ? '' : 's'} ·
|
||||
levels ${a.levels.join(' ')}</div>
|
||||
<div class="muted small">${a.isced.length ? a.iscedLabels.map((l, i) => `${a.isced[i]} ${l}`).join(' · ') : 'Any subject area'}</div>
|
||||
<div class="small">${a.languages.length
|
||||
? a.languages.map((l) => html`<span class="lang">${LANG_NAMES[l.lang] ?? l.lang} ${l.level}</span> `)
|
||||
: html`<span class="muted">No language listed</span>`}</div>
|
||||
${a.factsheet ? html`<div class="small">${extLink(a.factsheet, 'CTU factsheet (CTU login)')}</div>` : ''}
|
||||
</li>`)}
|
||||
</ul>
|
||||
<p class="small">Subject fit: <b class="tone-${subjectFit(s).level}">${subjectFit(s).text}</b> ·
|
||||
Language: <b class="tone-${languageFit(s, app.settings.languages).status}">${languageFit(s, app.settings.languages).text}</b></p>`;
|
||||
}
|
||||
|
||||
function moneyBlock(s, app) {
|
||||
const r = s.research;
|
||||
const g = monthlyGrant(s, app.settings, app.data);
|
||||
const n = netCost(s, app.settings, app.data);
|
||||
const m = app.settings.stayMonths;
|
||||
const country = app.data.countries?.[s.country];
|
||||
const range = (x) => moneyRange(x, app.settings, app.data);
|
||||
const liv = r?.living;
|
||||
return html`
|
||||
<dl class="kv">
|
||||
<dt>Money from CTU</dt><dd><b>${money(g.eur, app.settings, app.data)}</b>/month · ${s.funding?.label}
|
||||
<div class="muted small">${s.funding?.note}</div></dd>
|
||||
${r?.fees?.hostFunding?.monthlyEUR ? html`<dt>Host scholarship</dt><dd>${money(r.fees.hostFunding.monthlyEUR, app.settings, app.data)}/month (not guaranteed)
|
||||
<div class="muted small">${r.fees.hostFunding.text}</div></dd>` : ''}
|
||||
${liv ? html`
|
||||
<dt>Living /month</dt><dd><b>${range(liv.totalEUR)}</b>
|
||||
<div class="muted small">rent ${range(liv.rentEUR)} · food ${range(liv.foodEUR)} · transport ${range(liv.transportEUR)} · other ${range(liv.otherEUR)}</div></dd>
|
||||
<dt>Housing</dt><dd>${liv.housing}</dd>` : ''}
|
||||
${r?.fees ? html`<dt>Mandatory fees</dt><dd>${r.fees.mandatoryEUR != null ? money(r.fees.mandatoryEUR, app.settings, app.data) : '?'} per semester
|
||||
<div class="muted small">${r.fees.text}</div></dd>` : ''}
|
||||
${r?.travel ? html`<dt>Getting there</dt><dd>${r.travel.duration} · <b>${range(r.travel.roundTripEUR)}</b> round trip
|
||||
<div class="muted small">${r.travel.text}</div></dd>` : ''}
|
||||
${country?.visa ? html`<dt>Visa</dt><dd>${country.visa.required ? `${country.visa.type || 'Required'} · ${country.visa.costEUR != null ? money(country.visa.costEUR, app.settings, app.data) : 'cost unknown'}` : 'Not needed'}
|
||||
<div class="muted small">${country.visa.text}</div></dd>` : ''}
|
||||
${n ? html`<dt>Out of pocket (${m} months)</dt><dd><b>${range([n.lo, n.hi])}</b>
|
||||
<div class="muted small">living ${range(n.parts.living)} + travel ${range(n.parts.travel)} + visa ${money(n.parts.visa, app.settings, app.data)}
|
||||
+ fees ${money(n.parts.fees, app.settings, app.data)} − money received ${money(n.parts.grant, app.settings, app.data)}</div></dd>` : ''}
|
||||
</dl>
|
||||
${liv ? para(liv.text) : ''}`;
|
||||
}
|
||||
|
||||
function safetyBlock(s, app) {
|
||||
const r = s.research;
|
||||
const c = app.data.countries?.[s.country];
|
||||
return html`
|
||||
${r ? scored('City safety', { score: r.safety.score, text: r.safety.text }) : ''}
|
||||
${r ? html`<p class="small"><b>Hazards:</b> ${r.safety.hazards}</p>` : ''}
|
||||
${c ? html`
|
||||
${scored('Country stability', { score: c.stabilityScore, text: c.text })}
|
||||
<p class="small">World Bank political stability: ${c.wgiPoliticalStability?.percentile ?? '?'}th percentile (${c.wgiPoliticalStability?.year}) ·
|
||||
Global Peace Index #${c.gpi?.rank ?? '?'} (${c.gpi?.year})</p>
|
||||
<p class="small"><b>Czech MFA:</b> <span class="advisory adv-${c.mfaAdvisory?.level}">${c.mfaAdvisory?.level}</span> ${c.mfaAdvisory?.text}</p>
|
||||
<p class="small"><b>Health insurance:</b> ${c.health?.text}</p>` : ''}`;
|
||||
}
|
||||
|
||||
export function render(root, app, slug) {
|
||||
const s = app.bySlug.get(slug);
|
||||
if (!s) {
|
||||
root.innerHTML = String(html`<section class="empty"><h2>Unknown school</h2><a class="btn" href="#/rank">Back to the ranking</a></section>`);
|
||||
return;
|
||||
}
|
||||
const r = s.research;
|
||||
const st = app.state.stats.get(s.code);
|
||||
const rank = app.rankOf(s.code);
|
||||
const note = app.notes[s.code]?.text ?? '';
|
||||
const history = [...st.history].reverse().slice(0, 30);
|
||||
|
||||
root.innerHTML = String(html`
|
||||
<article class="detail">
|
||||
<button type="button" class="back" data-action="back">${ICONS.back} Back</button>
|
||||
<header class="dhead">
|
||||
<div class="dflag" aria-hidden="true">${s.flag}</div>
|
||||
<h1>${fullName(s)}</h1>
|
||||
<p class="muted">${shortName(s) !== fullName(s) ? `${shortName(s)} · ` : ''}${place(s)} · ${s.code}</p>
|
||||
<p class="dstats">
|
||||
<b>${Math.round(st.rating)}</b> Elo ${rank && st.games ? `· #${rank}` : ''} · ${st.games} games (${st.wins}W ${st.losses}L ${st.draws}D)
|
||||
${st.dropped ? html`<span class="chip warn">dropped</span>` : ''}
|
||||
</p>
|
||||
<div class="dactions">
|
||||
${st.dropped
|
||||
? html`<button type="button" class="btn" data-action="restore">Restore to the race</button>`
|
||||
: html`<button type="button" class="btn" data-action="duel">Compare it now</button>
|
||||
<button type="button" class="btn ghost" data-action="drop">Drop</button>`}
|
||||
${s.web ? extLink(s.web, 'Website') : ''} ${s.qs ? extLink(s.qs, 'QS') : ''}
|
||||
${extLink(`https://www.openstreetmap.org/?mlat=${s.lat}&mlon=${s.lon}#map=12/${s.lat}/${s.lon}`, 'Map')}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
${r ? html`
|
||||
<p class="dsummary">${r.summary}</p>
|
||||
<div class="hlwo">${list(r.highlights, 'hl-list')}${list(r.watchouts, 'wo-list')}</div>` : html`
|
||||
<p class="notice">Research for this school is still pending. You can still compare it using the catalog data.</p>`}
|
||||
|
||||
${section('Agreements', agreementsBlock(s, app))}
|
||||
|
||||
${r ? html`
|
||||
${section('AI & robotics', html`
|
||||
${scored('Research', r.aiRobotics.academic)}
|
||||
${scored('Hands-on', r.aiRobotics.practical)}
|
||||
${scored('Course access for you', r.aiRobotics.access)}
|
||||
<p class="small">${Object.entries(r.aiRobotics.rankings).filter(([, v]) => v).map(([k, v]) => html`<span class="chip">${({ qsWorld: 'QS', qsCS: 'QS CS', csrankings: 'CSRankings', other: '' })[k]} ${v}</span> `)}</p>
|
||||
${r.aiRobotics.labs.length ? html`<h3>Labs & groups</h3>${list(r.aiRobotics.labs)}` : ''}
|
||||
${r.aiRobotics.courses.length ? html`<h3>Relevant English courses</h3>${list(r.aiRobotics.courses)}` : ''}
|
||||
${r.aiRobotics.teams.length ? html`<h3>Student teams</h3>${list(r.aiRobotics.teams)}` : ''}`, r.confidence.aiRobotics)}
|
||||
|
||||
${section('Money', moneyBlock(s, app), r.confidence.living)}
|
||||
|
||||
${section('Language', html`
|
||||
<dl class="kv">
|
||||
<dt>Teaching</dt><dd>${r.language.teaching}</dd>
|
||||
<dt>Proof needed</dt><dd>${r.language.proof}</dd>
|
||||
<dt>Local language in daily life</dt><dd>${bar(r.language.localNeed)} <span class="muted small">(10 = essential)</span></dd>
|
||||
</dl>${para(r.language.text)}`, r.confidence.language)}
|
||||
|
||||
${section('Social life & solitude', html`
|
||||
${scored('Social', r.social)}
|
||||
<p class="small">${r.social.esn ? html`<b>ESN/buddy:</b> ${r.social.esn}` : ''}${r.social.internationals ? html` · <b>Internationals:</b> ${r.social.internationals}` : ''}</p>
|
||||
${scored('Calm & solitude', r.solitude)}`, r.confidence.social)}
|
||||
|
||||
${section('Nature', html`
|
||||
${scored('Climbing', r.nature.climbing)}
|
||||
${scored('Hiking', r.nature.hiking)}
|
||||
${scored('Ocean', r.nature.ocean)}
|
||||
${scored('Skiing', r.nature.skiing)}
|
||||
<p class="small"><b>Climate (Sep–Feb):</b> ${r.nature.climate}</p>`, r.confidence.nature)}
|
||||
` : ''}
|
||||
|
||||
${section('Safety & stability', safetyBlock(s, app), r?.confidence?.safety)}
|
||||
|
||||
${r ? html`
|
||||
${section('Calendar & application', html`
|
||||
<dl class="kv">
|
||||
<dt>Term</dt><dd>${r.calendar.term}</dd>
|
||||
<dt>Fit with CTU winter</dt><dd><b class="tone-${r.calendar.fit}">${r.calendar.fit}</b> · full year: ${r.calendar.fullYear}</dd>
|
||||
<dt>Host deadline</dt><dd>${r.application.nominationDeadline ?? 'unknown'}</dd>
|
||||
</dl>${para(r.calendar.text)}${para(r.application.text)}`, r.confidence.calendar)}
|
||||
|
||||
${section('Sources', html`
|
||||
<ol class="sources">${r.sources.map((src) => html`<li>${extLink(src.url, src.label)}</li>`)}</ol>
|
||||
<p class="muted small">Researched ${r.researchedAt} · overall ${CONF_LABEL[r.confidence.overall]}. Check money and language rules officially before applying.</p>`)}
|
||||
` : ''}
|
||||
|
||||
${section('My notes', html`
|
||||
<textarea name="note" rows="4" maxlength="5000" placeholder="Your thoughts, questions to ask, people to contact…">${note}</textarea>
|
||||
<p class="muted small" data-note-status>${note ? 'Saved' : 'Saved automatically'}</p>`)}
|
||||
|
||||
${history.length ? section('My picks', html`
|
||||
<ul class="history">${history.map((m) => {
|
||||
const meA = m.a === s.code;
|
||||
const other = app.byCode.get(meA ? m.b : m.a);
|
||||
const delta = meA ? m.da : m.db;
|
||||
const outcome = m.r === 'draw' ? 'tied with' : (m.r === 'a') === meA ? 'beat' : 'lost to';
|
||||
return html`<li><span class="${delta >= 0 ? 'up' : 'down'}">${delta >= 0 ? '+' : ''}${Math.round(delta)}</span> ${outcome} ${shortName(other)}</li>`;
|
||||
})}</ul>`) : ''}
|
||||
</article>`);
|
||||
|
||||
root.onclick = (e) => {
|
||||
const t = e.target.closest('[data-action]');
|
||||
if (!t) return;
|
||||
const action = t.dataset.action;
|
||||
if (action === 'back') app.back();
|
||||
else if (action === 'drop') app.drop(s.code);
|
||||
else if (action === 'restore') app.restore(s.code);
|
||||
else if (action === 'duel') app.duelWith(s.code);
|
||||
};
|
||||
const textarea = root.querySelector('textarea[name="note"]');
|
||||
const status = root.querySelector('[data-note-status]');
|
||||
let timer;
|
||||
const save = () => {
|
||||
clearTimeout(timer);
|
||||
if (textarea.value === (app.notes[s.code]?.text ?? '')) return;
|
||||
status.textContent = 'Saving…';
|
||||
app.saveNote(s.code, textarea.value)
|
||||
.then(() => { status.textContent = 'Saved'; })
|
||||
.catch(() => { status.textContent = 'Not saved: offline? It will retry when you leave the field.'; });
|
||||
};
|
||||
textarea.addEventListener('input', () => { status.textContent = 'Editing…'; clearTimeout(timer); timer = setTimeout(save, 1200); });
|
||||
textarea.addEventListener('blur', save);
|
||||
}
|
||||
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();
|
||||
};
|
||||
}
|
||||
85
public/js/views/triage.js
Normal file
85
public/js/views/triage.js
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
// Quick first pass: one school at a time, Keep or Drop. Schools with hard problems (language you
|
||||
// don't speak, unrelated subject, unsafe country) come first, with the reasons shown.
|
||||
|
||||
import { html, bar } from '../ui.js';
|
||||
import { shortName, place, languageFit, subjectFit, netCost, moneyRange, monthlyGrant, money } from '../metrics.js';
|
||||
|
||||
/** Reasons a school is probably not worth comparing. Empty = nothing obviously wrong. */
|
||||
export function concerns(s, app) {
|
||||
const out = [];
|
||||
const lang = languageFit(s, app.settings.languages);
|
||||
if (lang.status === 'fail') out.push(`Language: ${lang.text.replace('✗ ', '')}`);
|
||||
const subj = subjectFit(s);
|
||||
if (subj.rank <= 1) out.push(`Subject area: ${subj.text}`);
|
||||
const c = app.data.countries?.[s.country];
|
||||
if (c && c.stabilityScore <= 3) out.push(`Country stability ${c.stabilityScore}/10 (MFA: ${c.mfaAdvisory?.level})`);
|
||||
const r = s.research;
|
||||
if (r && r.safety.score <= 3) out.push(`City safety ${r.safety.score}/10`);
|
||||
if (r && r.aiRobotics.access.score <= 2) out.push(`Few relevant courses for you (access ${r.aiRobotics.access.score}/10)`);
|
||||
return out;
|
||||
}
|
||||
|
||||
export function render(root, app) {
|
||||
const all = app.data.schools.map((s) => ({ s, st: app.state.stats.get(s.code) }));
|
||||
const queue = all
|
||||
.filter(({ st }) => !st.reviewed && !st.dropped)
|
||||
.map((x) => ({ ...x, why: concerns(x.s, app) }))
|
||||
.sort((x, y) => y.why.length - x.why.length);
|
||||
const done = all.length - queue.length;
|
||||
|
||||
if (!queue.length) {
|
||||
root.innerHTML = String(html`
|
||||
<section class="empty">
|
||||
<h2>Triage done</h2>
|
||||
<p>You've been through all ${all.length} schools. Now the comparisons do the rest.</p>
|
||||
<a class="btn" href="#/">Start comparing</a>
|
||||
</section>`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { s, why } = queue[0];
|
||||
const r = s.research;
|
||||
const n = netCost(s, app.settings, app.data);
|
||||
const g = monthlyGrant(s, app.settings, app.data);
|
||||
root.innerHTML = String(html`
|
||||
<section class="triage">
|
||||
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="${all.length}" aria-valuenow="${done}">
|
||||
<span>${done} / ${all.length} reviewed</span><i class="w${Math.round((done / all.length) * 10)}"></i>
|
||||
</div>
|
||||
<p class="muted small">Optional first pass. Drop the obvious no-gos so your picks go to real candidates. Problem schools come first.</p>
|
||||
<article class="tcard">
|
||||
<header>
|
||||
<span class="flag" aria-hidden="true">${s.flag}</span>
|
||||
<div><h2>${shortName(s)}</h2><p class="muted">${place(s)}</p></div>
|
||||
</header>
|
||||
${why.length ? html`<ul class="concerns">${why.map((w) => html`<li>${w}</li>`)}</ul>` : ''}
|
||||
${r ? html`
|
||||
<p>${r.summary}</p>
|
||||
<dl class="tgrid">
|
||||
<dt>AI research</dt><dd>${bar(r.aiRobotics.academic.score)}</dd>
|
||||
<dt>Course access</dt><dd>${bar(r.aiRobotics.access.score)}</dd>
|
||||
<dt>Social / calm</dt><dd>${r.social.score} / ${r.solitude.score}</dd>
|
||||
<dt>Climb / hike / ocean</dt><dd>${r.nature.climbing.score} / ${r.nature.hiking.score} / ${r.nature.ocean.score}</dd>
|
||||
<dt>CTU money</dt><dd>${money(g.eur, app.settings, app.data)}/mo</dd>
|
||||
<dt>Out of pocket</dt><dd>${n ? moneyRange([n.lo, n.hi], app.settings, app.data, { compact: true }) : '–'}</dd>
|
||||
</dl>
|
||||
${r.watchouts.length ? html`<ul class="wo-list">${r.watchouts.slice(0, 3).map((w) => html`<li>${w}</li>`)}</ul>` : ''}`
|
||||
: html`<p class="notice">Research pending: judge from the catalog for now, or keep it and decide later.</p>`}
|
||||
<button type="button" class="link" data-action="open" data-slug="${s.slug}">All details</button>
|
||||
</article>
|
||||
</section>
|
||||
<div class="actionbar" role="group" aria-label="Triage">
|
||||
<div class="actionbar-main">
|
||||
<button type="button" class="pick pick-drop" data-action="drop">Drop</button>
|
||||
<button type="button" class="pick pick-keep" data-action="keep">Keep</button>
|
||||
</div>
|
||||
</div>`);
|
||||
|
||||
root.onclick = (e) => {
|
||||
const t = e.target.closest('[data-action]');
|
||||
if (!t) return;
|
||||
if (t.dataset.action === 'drop') app.drop(s.code);
|
||||
if (t.dataset.action === 'keep') app.review(s.code);
|
||||
if (t.dataset.action === 'open') app.navigate(`#/school/${t.dataset.slug}`);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue