Push filters onto the history, link company names to their roles, and star a company from the feed
A filter set in the rail is now a history entry, so back takes it off; the search box and typed fields replace, and the agent and order replace and are left alone by back and forward. popstate reads the address into the filter and reloads. Each pushed entry carries the address under it, which replaces pushedReader, so closing the reader and taking a company off are history.back() only when the entry under is that list. A company's name in a row and in the reader links to ?company_keys=, keeping agent and order; a plain click filters in place and pushes. With one company filtered, a strip over the feed names it, counts its roles, links its careers page and carries its affinity control, and reloads the feed once the score it queued has run. On a phone the name takes taps from a band around it without making the row taller, and with a filter on the header no longer runs past 390px. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
64f367cc18
commit
4ae5e845ee
3 files changed
+316
-48
No files matched your search
+41
-1
@@ -730,6 +730,15 @@ body[data-reader="open"] .row[data-open="true"] {
|
||||
/* The company is the second thing you read after the title -- it is how you
|
||||
decide whether to read on. It gets weight and full ink, not grey. */
|
||||
.meta b { font-weight: 650; color: var(--fg); }
|
||||
/* The company's name is also a link to its roles (roles.js `companyName`),
|
||||
and still reads as the name: same weight and ink, underlined only under
|
||||
a pointer. */
|
||||
.meta .company { font-weight: 650; color: var(--fg); text-decoration: none; }
|
||||
@media (hover: hover) {
|
||||
.meta .company:hover, .reader-meta .company:hover {
|
||||
text-decoration: underline; text-underline-offset: 2px;
|
||||
}
|
||||
}
|
||||
.meta .badge, .reader-meta .badge {
|
||||
background: none; color: var(--dim);
|
||||
border: 1px solid var(--line); border-radius: 999px;
|
||||
@@ -761,6 +770,23 @@ tr.muted { opacity: .55; }
|
||||
font-size: .84rem; color: var(--faint);
|
||||
}
|
||||
|
||||
/* The company filtered to (roles.js `renderStrip`), in the reader summary's
|
||||
band: a note about the list rather than a row of it. Gone while a role is
|
||||
open, where the list is an index and the company is in the reader. */
|
||||
.company-strip {
|
||||
margin: .7rem 0 .2rem; padding: .6rem .9rem;
|
||||
background: color-mix(in srgb, var(--accent) 7%, var(--panel));
|
||||
border-left: 3px solid var(--accent); border-radius: .3rem;
|
||||
}
|
||||
body[data-reader="open"] .company-strip { display: none; }
|
||||
.strip-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
|
||||
.strip-name { font-size: 1.05rem; font-weight: 650; overflow-wrap: anywhere; }
|
||||
.strip-count, .company-strip .reader-careers { font-size: .85rem; color: var(--dim); }
|
||||
.company-strip .affinity { font-size: .85rem; }
|
||||
.strip-drop { margin-left: auto; }
|
||||
.strip-note, .strip-status { margin: .35rem 0 0; font-size: .8rem; line-height: 1.45; color: var(--dim); }
|
||||
.strip-status:empty { display: none; }
|
||||
|
||||
.empty { padding: 4rem 0; max-width: 34rem; color: var(--dim); }
|
||||
.empty h2 { font-size: 1.2rem; font-weight: 600; color: var(--fg); margin: 0 0 .4rem; }
|
||||
|
||||
@@ -847,7 +873,8 @@ tr.muted { opacity: .55; }
|
||||
.reader-body > * { max-width: 48rem; margin-inline: auto; }
|
||||
|
||||
.reader-meta { margin-top: 0; }
|
||||
.reader-meta b { font-weight: 600; color: var(--dim); }
|
||||
.reader-meta b, .reader-meta .company { font-weight: 600; color: var(--dim); }
|
||||
.reader-meta .company { text-decoration: none; }
|
||||
.reader-meta .reader-careers { color: var(--dim); }
|
||||
.reader-meta .affinity { font-size: .85rem; }
|
||||
.reader-meta .affinity:empty { display: none; }
|
||||
@@ -1017,6 +1044,12 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
each one a line of its own. The rail's chips are the tag targets sized
|
||||
for a thumb. */
|
||||
.meta .tag.mini, .reader-meta .tag.mini { min-height: 0; }
|
||||
/* A company's name takes taps from a band around it, padding a thumb can
|
||||
hit given back by a negative margin, so the row is no taller. On top of
|
||||
the lines above and below, which it overlaps by a few pixels. */
|
||||
.meta .company, .reader-meta .company {
|
||||
position: relative; padding: .55rem .35rem; margin: -.55rem -.35rem;
|
||||
}
|
||||
/* No keys on a touch screen, so no key hints. */
|
||||
.rail-keys { display: none; }
|
||||
}
|
||||
@@ -1363,4 +1396,11 @@ table.list select { padding: .25rem .4rem; }
|
||||
/* Which leaves the field a few letters wide, so while it is typed in it
|
||||
takes the bar and the tabs step aside; they are back when it is left. */
|
||||
.top:has(#search:focus) nav a:not(.icon), .top:has(#search:focus) desk-queue { display: none; }
|
||||
/* With a filter on, the burger says how many in words, which at 390px
|
||||
made the bar 30 to 50px wider than the screen, and a phone widens the
|
||||
page to fit, the reader's ✕ with it. The queue steps aside, as it does
|
||||
for the search, and so do the burger's three lines, since its words say
|
||||
what it opens. */
|
||||
.top:has(#rail-toggle[aria-label*="filter"]) desk-queue,
|
||||
#rail-toggle[aria-label*="filter"] .burger { display: none; }
|
||||
}
|
||||
+272
-47
@@ -16,8 +16,9 @@
|
||||
*
|
||||
* Opening a role pushes `/roles/{uid}`; closing goes back. Stepping with j/k
|
||||
* while it is open replaces that entry rather than stacking one per role, so
|
||||
* back always means "out of the reader". The server answers `/roles/{uid}`
|
||||
* with this same page, and `route` is the only thing that reads the path.
|
||||
* back from a role means "out of the reader". The server answers
|
||||
* `/roles/{uid}` with this same page, and `route` is the only thing that
|
||||
* reads the path.
|
||||
*
|
||||
* The rail opens on Viewing as: the search agent the feed is seen as. An
|
||||
* agent is a persona ("me as a candidate", "me as a hiring manager watching
|
||||
@@ -34,10 +35,34 @@
|
||||
* or Newest first (`order=newest`), the same two whichever agent is viewed,
|
||||
* and both carry the agent's votes and hidden companies.
|
||||
*
|
||||
* The filters are in the query string, replaced rather than pushed, so a
|
||||
* reload or a link keeps them and the back button is not buried under them.
|
||||
* `?company=` and `?agent=` are how the Companies and Search agents pages
|
||||
* link in.
|
||||
* The filters are in the query string, so a reload or a link keeps them, and
|
||||
* each one set is a history entry, so back takes it off again: a tag, the
|
||||
* period, Show read, a select, a checkbox, Clear, and a company. Text is the
|
||||
* exception: the search box and the typed fields replace the entry, or back
|
||||
* would step through a search a letter at a time. Who is viewing and the
|
||||
* order are not filters and replace too; back and forward leave both as
|
||||
* they are and write them into the entry they land on. `popstate` reads the
|
||||
* address into the filter and reloads the feed, pushing nothing.
|
||||
*
|
||||
* Every entry this page pushes carries `{from}`, the address it was pushed
|
||||
* over, so a way out that means "the list as it was" (closing the reader,
|
||||
* taking the company off) is `history.back()` when the entry under it is
|
||||
* that list, and a new entry otherwise, e.g. on a link arrived at from
|
||||
* another page. That replaces a flag held in memory, and survives a reload
|
||||
* and a step back into the reader.
|
||||
*
|
||||
* A filter set while the reader is open pushes the new list over the role,
|
||||
* so the reader shuts and back reopens the role over the old list: back
|
||||
* undoes the one thing done last, and a click on the company in the reader
|
||||
* reads as the link it is. Nothing to change (Clear with nothing set) just
|
||||
* closes the reader, as Escape would.
|
||||
*
|
||||
* A company's name, in a row and in the reader, is a link to that company's
|
||||
* roles (`?company_keys=`), keeping the agent and the order; a plain click
|
||||
* filters in place and pushes. With one company filtered a strip over the
|
||||
* feed names it, counts its roles, links its careers page and carries its
|
||||
* ★ ▲ ⊘ for the viewing agent. `?company=`, `?company_keys=` and `?agent=`
|
||||
* are how the Companies and Search agents pages link in.
|
||||
*
|
||||
* The list is paged: 60 rows, then 60 more each time the end of the list comes
|
||||
* within 600px of the screen, with the offset the rows already shown. Back to
|
||||
@@ -85,7 +110,7 @@
|
||||
return {
|
||||
sort: "score", agent: null, period: "all", tags: new Set(), showRead: true,
|
||||
company: "", place: "", function: "", remote: "", judged: "", pay: "",
|
||||
showMuted: false, gated: false,
|
||||
showMuted: false, gated: false, companyKeys: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,7 +129,6 @@
|
||||
selected: 0, // which row the keyboard is on
|
||||
reading: null, // the fetched role, or null while it loads
|
||||
readingUid: null, // set before the fetch lands, so a late answer is dropped
|
||||
pushedReader: false, // we own a history entry, so closing is `history.back()`
|
||||
summarising: null, // the uid whose summary is being waited for
|
||||
listY: 0, // where the page was scrolled when the reader replaced the feed
|
||||
feedError: false, // the feed's own fetch failed; the empty state offers a retry
|
||||
@@ -125,10 +149,10 @@
|
||||
const sortShown = () =>
|
||||
(state.filter.sort === "score" && state.filter.agent !== null ? "score" : "time");
|
||||
|
||||
function feedParams() {
|
||||
const f = state.filter;
|
||||
/** The feed's query for a filter, the one on screen unless told. */
|
||||
function feedParams(f = state.filter, q = state.q) {
|
||||
const p = new URLSearchParams();
|
||||
if (state.q) p.set("q", state.q);
|
||||
if (q) p.set("q", q);
|
||||
for (const key of ["company", "place"]) if (f[key].trim()) p.set(key, f[key].trim());
|
||||
for (const key of ["function", "remote", "judged", "pay"]) if (f[key]) p.set(key, f[key]);
|
||||
const days = PERIODS[f.period].days;
|
||||
@@ -136,6 +160,7 @@
|
||||
if (f.showMuted) p.set("show_muted", "true");
|
||||
if (!f.showRead) p.set("include_read", "false");
|
||||
f.tags.forEach((t) => p.append("tags", t));
|
||||
f.companyKeys.forEach((key) => p.append("company_keys", key));
|
||||
if (f.agent !== null) {
|
||||
p.set("agent", String(f.agent));
|
||||
p.set("order", sortShown() === "score" ? "score" : "newest");
|
||||
@@ -148,9 +173,12 @@
|
||||
|
||||
const PERIOD_OF_DAYS = { 1: "today", 7: "week", 30: "month" };
|
||||
|
||||
/** The query string into the filter, once, at load. */
|
||||
function readUrl() {
|
||||
const q = new URLSearchParams(location.search);
|
||||
/** A query string into the filter and the search: the address at load, on
|
||||
back and forward, and a company link followed in place. Who is viewing
|
||||
and the order are read only when `view` is set, at load: on back and
|
||||
forward they stay as they are, since neither is a step in the history. */
|
||||
function readUrl(search = location.search, { view = true } = {}) {
|
||||
const q = new URLSearchParams(search);
|
||||
const f = state.filter;
|
||||
state.q = q.get("q") || "";
|
||||
for (const key of ["company", "place", "function", "remote", "judged", "pay"]) {
|
||||
@@ -161,6 +189,8 @@
|
||||
f.showRead = q.get("include_read") !== "false";
|
||||
f.gated = q.get("gated") === "true" || q.get("gated") === "1";
|
||||
f.tags = new Set(q.getAll("tags"));
|
||||
f.companyKeys = [...new Set(q.getAll("company_keys").filter(Boolean))];
|
||||
if (!view) return;
|
||||
if (q.get("sort") === "time") f.sort = "time";
|
||||
// Checked against the enabled agents once they are in (`chooseAgent`).
|
||||
if (q.get("agent")) f.agent = Number(q.get("agent"));
|
||||
@@ -170,15 +200,63 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** The filter into the query string, replacing the entry rather than
|
||||
adding one: a filter is a question, not a place. */
|
||||
function writeUrl() {
|
||||
const p = feedParams();
|
||||
const here = () => location.pathname + location.search;
|
||||
|
||||
/** `path` with a filter's query, the one on screen unless told. */
|
||||
function addressFor(path, f = state.filter, q = state.q) {
|
||||
const p = feedParams(f, q);
|
||||
p.delete("order");
|
||||
if (state.filter.sort === "time") p.set("sort", "time");
|
||||
if (f.sort === "time") p.set("sort", "time");
|
||||
const query = p.toString();
|
||||
const url = location.pathname + (query ? `?${query}` : "");
|
||||
if (url !== location.pathname + location.search) history.replaceState(history.state, "", url);
|
||||
return path + (query ? `?${query}` : "");
|
||||
}
|
||||
|
||||
/** The filter into the address. `push` makes it an entry of its own,
|
||||
carrying the address it was pushed over (`from`); otherwise the entry
|
||||
is replaced and keeps its `from`. `list` takes the path to the list,
|
||||
for a filter, which shuts the reader; without it the path stays, for
|
||||
the agent and the order, which do not. False when nothing changed. */
|
||||
function writeUrl({ push = false, list = false } = {}) {
|
||||
const url = addressFor(list ? pathFor(null) : location.pathname);
|
||||
const was = here();
|
||||
if (url === was) return false;
|
||||
if (push) history.pushState({ from: was }, "", url);
|
||||
else history.replaceState(history.state, "", url);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** An address with the agent and the order taken out and the rest sorted:
|
||||
what two entries are compared on, since neither of those is a step. */
|
||||
function filterPart(url) {
|
||||
const u = new URL(url, location.origin);
|
||||
u.searchParams.delete("agent");
|
||||
u.searchParams.delete("sort");
|
||||
u.searchParams.sort();
|
||||
return u.pathname + u.search;
|
||||
}
|
||||
|
||||
/** Whether the entry under this one is ours and shows `url`, so getting
|
||||
there is `history.back()` rather than one more entry on top. */
|
||||
function underIs(url) {
|
||||
const from = history.state && history.state.from;
|
||||
return typeof from === "string" && filterPart(from) === filterPart(url);
|
||||
}
|
||||
|
||||
/* Back or forward: the entry's filter into the rail and the feed, and its
|
||||
role into the reader. The agent and the order are the ones on screen,
|
||||
written into the entry landed on, so the entry says what is shown. */
|
||||
function restore() {
|
||||
const before = addressFor(pathFor(null));
|
||||
const muted = state.filter.showMuted;
|
||||
readUrl(location.search, { view: false });
|
||||
$("#search").value = state.q;
|
||||
writeUrl();
|
||||
route();
|
||||
if (addressFor(pathFor(null)) === before) return;
|
||||
reload();
|
||||
if (state.filter.showMuted !== muted) loadFilters().catch(() => {});
|
||||
renderRail();
|
||||
renderActive();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- loading
|
||||
@@ -304,13 +382,19 @@
|
||||
|
||||
// ------------------------------------------------------------ the rail
|
||||
|
||||
function setFilter(patch = {}, { counts = false } = {}) {
|
||||
/* A filter is a question about the feed, and the role open over the old
|
||||
answer is the wrong thing to leave on screen, so the new list goes over
|
||||
it: pushed, so back takes the filter off and brings the role back, or
|
||||
replacing the entry for text being typed (`replace`). A filter that
|
||||
changes nothing only closes the reader. */
|
||||
function setFilter(patch = {}, { counts = false, replace = false } = {}) {
|
||||
Object.assign(state.filter, patch);
|
||||
writeUrl();
|
||||
// A filter is a question about the feed, and the role open over the old
|
||||
// answer is the wrong thing to leave on screen. Its entry is replaced
|
||||
// rather than popped, or back would land on the list the filter just left.
|
||||
if (state.readingUid) navigate(pathFor(null), { replace: true });
|
||||
if (state.readingUid && addressFor(pathFor(null)) === pathFor(null) + location.search) {
|
||||
closeReader();
|
||||
} else {
|
||||
writeUrl({ push: !replace, list: true });
|
||||
route();
|
||||
}
|
||||
reload();
|
||||
if (counts) loadFilters().catch(() => {});
|
||||
renderRail();
|
||||
@@ -324,12 +408,64 @@
|
||||
setFilter({}, { counts: true });
|
||||
}
|
||||
|
||||
/* The other order over the same filter: the entry is replaced, since an
|
||||
order is not a step back would undo, and an open role stays open, as it
|
||||
does for another agent, since the role in question has not changed. */
|
||||
function setOrder(sort) {
|
||||
if (sort === state.filter.sort) return;
|
||||
state.filter.sort = sort;
|
||||
writeUrl();
|
||||
renderRail();
|
||||
renderActive();
|
||||
reload();
|
||||
}
|
||||
|
||||
// Text that has not changed is not a change: without this, Escape in an
|
||||
// empty box would shut the reader and call it a search.
|
||||
function setSearch(q) {
|
||||
if (q === state.q) return;
|
||||
state.q = q;
|
||||
setFilter({});
|
||||
setFilter({}, { replace: true });
|
||||
}
|
||||
|
||||
/** Where a company's name links: its roles, as the agent viewing them, in
|
||||
the order on screen. A company this agent hid keeps Show hidden
|
||||
companies, or its own name would lead to an empty list. */
|
||||
function companyHref(key) {
|
||||
const p = new URLSearchParams();
|
||||
p.append("company_keys", key);
|
||||
if (companies.get(key)?.affinity === -1) p.set("show_muted", "true");
|
||||
const now = new URLSearchParams(location.search);
|
||||
for (const name of ["agent", "sort"]) if (now.get(name)) p.set(name, now.get(name));
|
||||
return `${pathFor(null)}?${p}`;
|
||||
}
|
||||
|
||||
/** A company's name, as a link to its roles when it has a key. */
|
||||
function companyName(role) {
|
||||
if (!role.company_key) return `<b>${esc(role.company)}</b>`;
|
||||
return `<a class="company" href="${esc(companyHref(role.company_key))}"
|
||||
data-company="${esc(role.company_key)}" title="Only ${esc(role.company)}'s roles"
|
||||
>${esc(role.company)}</a>`;
|
||||
}
|
||||
|
||||
/* A plain click lists the company's roles in place, the list its link
|
||||
leads to, and pushes, so back is the list it left; a modified or middle
|
||||
click is the browser's, and opens the link. */
|
||||
function companyClick(e) {
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return;
|
||||
e.preventDefault();
|
||||
const counts = state.filter.showMuted;
|
||||
readUrl(new URL(e.currentTarget.href).search, { view: false });
|
||||
$("#search").value = state.q;
|
||||
setFilter({}, { counts: counts !== state.filter.showMuted });
|
||||
}
|
||||
|
||||
/* The strip's way back to every company: back, when the entry under this
|
||||
one is the same list without the company, else that list pushed. */
|
||||
function dropCompany() {
|
||||
const without = Object.assign({}, state.filter, { companyKeys: [] });
|
||||
if (underIs(addressFor(pathFor(null), without))) history.back();
|
||||
else setFilter({ companyKeys: [] });
|
||||
}
|
||||
|
||||
function toggleTag(tag) {
|
||||
@@ -403,7 +539,7 @@
|
||||
setValue("f-show-muted", f.showMuted);
|
||||
setValue("f-gated", f.gated);
|
||||
const more = [f.company.trim(), f.place.trim(), f.function, f.remote, f.pay, f.judged,
|
||||
f.showMuted, ranked && f.gated].filter(Boolean).length;
|
||||
f.showMuted, ranked && f.gated].filter(Boolean).length + f.companyKeys.length;
|
||||
$("#f-active").textContent = more ? ` · ${more}` : "";
|
||||
|
||||
document.body.dataset.rail = state.railOpen ? "open" : "shut";
|
||||
@@ -443,7 +579,7 @@
|
||||
const f = state.filter;
|
||||
const on = [!f.showRead, f.period !== "all", f.company.trim(), f.place.trim(),
|
||||
f.function, f.remote, f.pay, f.judged, f.showMuted, sortShown() === "score" && f.gated]
|
||||
.filter(Boolean).length + f.tags.size;
|
||||
.filter(Boolean).length + f.tags.size + f.companyKeys.length;
|
||||
const count = on === 1 ? "1 filter" : `${on} filters`;
|
||||
$(".rail-toggle-label").textContent = on ? count : "Menu";
|
||||
$("#rail-toggle").setAttribute("aria-label", on ? `Menu — ${count} on` : "Menu");
|
||||
@@ -532,7 +668,7 @@
|
||||
<div class="body">
|
||||
<a class="headline" href="${esc(pathFor(role.uid))}">${esc(role.title || "(untitled)")}</a>
|
||||
<div class="meta">
|
||||
${role.company ? `<b>${esc(role.company)}</b>` : ""}
|
||||
${role.company ? companyName(role) : ""}
|
||||
${role.place ? `<span>${esc(role.place)}</span>` : ""}
|
||||
${badges(role)}
|
||||
<span title="Posted">${ago(role.posted_at)}</span>
|
||||
@@ -553,8 +689,10 @@
|
||||
e.preventDefault();
|
||||
openReader(role.uid);
|
||||
};
|
||||
// A tag on a role is also the fastest way to ask for more like it.
|
||||
// A tag on a role is also the fastest way to ask for more like it, and
|
||||
// its company the fastest way to ask for the rest of that company's.
|
||||
el.querySelectorAll(".tag").forEach((b) => { b.onclick = () => toggleTag(b.dataset.tag); });
|
||||
el.querySelector(".company")?.addEventListener("click", companyClick);
|
||||
}
|
||||
|
||||
/* A passed role and a hidden company's are dimmed, never dropped: the pass
|
||||
@@ -596,6 +734,8 @@
|
||||
$("#list").dataset.sort = sortShown();
|
||||
sync($("#roles-list"), state.items.map((role, i) => [role.uid, { role, i }]), makeRow, fillRow);
|
||||
|
||||
renderStrip();
|
||||
|
||||
const empty = $("#feed-empty");
|
||||
empty.hidden = !((state.loaded || state.feedError) && !state.items.length);
|
||||
if (!empty.hidden) {
|
||||
@@ -608,7 +748,8 @@
|
||||
} else {
|
||||
const f = state.filter;
|
||||
const filtered = state.q || f.tags.size || f.period !== "all" || !f.showRead
|
||||
|| f.company.trim() || f.place.trim() || f.function || f.remote || f.pay || f.judged;
|
||||
|| f.company.trim() || f.place.trim() || f.function || f.remote || f.pay || f.judged
|
||||
|| f.companyKeys.length;
|
||||
empty.innerHTML = filtered
|
||||
? `<h2>Nothing matches</h2>
|
||||
<p>No open role fits these filters.
|
||||
@@ -632,23 +773,105 @@
|
||||
: `${number.format(n)} ${n === 1 ? "role" : "roles"} — that is all of them.`;
|
||||
}
|
||||
|
||||
/* With exactly one company filtered, which is where its name leads, a
|
||||
strip over the feed says whose roles these are and carries what is done
|
||||
with a company from here: its careers page, and its ★ ▲ ⊘ for the viewing
|
||||
agent, which is where a company is starred from. Built again only for
|
||||
another company or agent, since the feed is drawn on every page; the
|
||||
count and the affinity are patched. */
|
||||
function renderStrip() {
|
||||
const el = $("#company-strip");
|
||||
const key = state.filter.companyKeys.length === 1 ? state.filter.companyKeys[0] : null;
|
||||
el.hidden = key === null;
|
||||
if (key === null) {
|
||||
el.replaceChildren();
|
||||
delete el.dataset.key;
|
||||
return;
|
||||
}
|
||||
const company = companies.get(key);
|
||||
const name = company?.name || state.items.find((r) => r.company_key === key)?.company || key;
|
||||
const careers = safeUrl(company?.careers_url);
|
||||
const affinity = company ? company.affinity : 0;
|
||||
const sig = JSON.stringify([key, name, careers, state.filter.agent]);
|
||||
if (el.dataset.key !== sig) {
|
||||
el.dataset.key = sig;
|
||||
el.innerHTML = `
|
||||
<div class="strip-head">
|
||||
<b class="strip-name">${esc(name)}</b>
|
||||
<span class="strip-count"></span>
|
||||
${careers ? `<a class="reader-careers" href="${esc(careers)}" target="_blank" rel="noopener"
|
||||
title="The company's careers page">Careers ↗</a>` : ""}
|
||||
<span class="affinity-slot"></span>
|
||||
<button type="button" class="linky strip-drop"
|
||||
title="Take the company filter off">All companies</button>
|
||||
</div>
|
||||
<p class="strip-note">★ Favourite lists its roles from every place the agent's
|
||||
required gates allow, not only the agent's own places.</p>
|
||||
<p class="strip-status" role="status"></p>`;
|
||||
el.querySelector(".strip-drop").onclick = dropCompany;
|
||||
}
|
||||
const slot = el.querySelector(".affinity-slot");
|
||||
if (slot.dataset.affinity !== String(affinity)) {
|
||||
slot.dataset.affinity = String(affinity);
|
||||
slot.replaceChildren(affinityControl(key, affinity,
|
||||
() => affinityChanged(key, company), state.filter.agent));
|
||||
}
|
||||
const n = state.total;
|
||||
el.querySelector(".strip-count").textContent = state.loaded
|
||||
? `${number.format(n)} ${n === 1 ? "role matches" : "roles match"}` : "";
|
||||
}
|
||||
|
||||
/* A company seen only through a search has no row until its first change
|
||||
creates one, so the list is reloaded then. A change dims or undims its
|
||||
rows at once; where they rank waits on the `score` it queued, and the
|
||||
feed reloads when that has finished. */
|
||||
async function affinityChanged(key, company) {
|
||||
if (!company) await loadCompanies(state.filter.agent).catch(() => {});
|
||||
renderFeed();
|
||||
const status = () => $("#company-strip .strip-status");
|
||||
if (status()) status().textContent = "Scoring again; the list reloads when that is done.";
|
||||
await scored();
|
||||
if (status()) status().textContent = "";
|
||||
if (state.filter.companyKeys.includes(key)) reload();
|
||||
}
|
||||
|
||||
/* Wait for the `score` that carries a change just made, the way agents.js's
|
||||
`rescore` waits. The affinity route answers with that job's id
|
||||
(`score_job`), but app.js's `setAffinity` keeps the answer to itself,
|
||||
so the job is read off the queue: right after the change it is the
|
||||
newest `score` queued or running, which is what `_score_after_change`
|
||||
answers with. None there means it has already finished. */
|
||||
async function scored() {
|
||||
let job;
|
||||
for (let i = 0; i < 300; i += 1) {
|
||||
let snapshot;
|
||||
try {
|
||||
snapshot = await api("/api/jobs");
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
const live = [...snapshot.running, ...snapshot.queued].filter((j) => j.kind === "score");
|
||||
if (job === undefined) job = Math.max(-1, ...live.map((j) => j.id));
|
||||
if (!live.some((j) => j.id === job)) return;
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------- the reader
|
||||
|
||||
// Reading happens in a third column rather than on a page of its own, so
|
||||
// voting stays one keystroke away from the text being judged.
|
||||
function openReader(uid) {
|
||||
if (!uid) return;
|
||||
const reading = Boolean(state.readingUid);
|
||||
navigate(pathFor(uid), { replace: reading });
|
||||
if (!reading) state.pushedReader = true;
|
||||
navigate(pathFor(uid), { replace: Boolean(state.readingUid) });
|
||||
}
|
||||
|
||||
// Every way of closing goes through the back button rather than around it,
|
||||
// so the entry `openReader` pushed is popped by the close that matches it. A
|
||||
// role arrived at directly (a link, a reload) has no entry of ours under it,
|
||||
// so its list replaces it instead of leaving the app.
|
||||
// so the entry `openReader` pushed is popped by the close that matches it.
|
||||
// A role with no list of ours under it (arrived at by a link) has its entry
|
||||
// replaced by the list instead, rather than leaving the app.
|
||||
function closeReader() {
|
||||
if (state.pushedReader) history.back();
|
||||
if (underIs(pathFor(null) + location.search)) history.back();
|
||||
else navigate(pathFor(null), { replace: true });
|
||||
}
|
||||
|
||||
@@ -695,7 +918,6 @@
|
||||
|
||||
// What `route` does when the path no longer names a role.
|
||||
function shutReader() {
|
||||
state.pushedReader = false;
|
||||
state.reading = null;
|
||||
state.readingUid = null;
|
||||
state.summarising = null;
|
||||
@@ -813,7 +1035,7 @@
|
||||
</div>
|
||||
<div class="reader-body">
|
||||
<div class="reader-meta">
|
||||
${r.company ? `<b>${esc(r.company)}</b>` : ""}
|
||||
${r.company ? companyName(r) : ""}
|
||||
${careers ? `<a class="reader-careers" href="${esc(careers)}" target="_blank" rel="noopener"
|
||||
title="The company's careers page">Careers ↗</a>` : ""}
|
||||
<span class="affinity-slot"></span>
|
||||
@@ -853,6 +1075,7 @@
|
||||
el.querySelector(".step-prev").onclick = () => move(-1);
|
||||
el.querySelector(".step-next").onclick = () => move(1);
|
||||
el.querySelectorAll(".tag").forEach((b) => { b.onclick = () => toggleTag(b.dataset.tag); });
|
||||
el.querySelector(".reader-meta .company")?.addEventListener("click", companyClick);
|
||||
el.querySelector('[data-tool="summarise"]')?.addEventListener("click",
|
||||
(e) => summarise(e.currentTarget));
|
||||
el.querySelector('[data-tool="fetch"]')?.addEventListener("click",
|
||||
@@ -1022,7 +1245,8 @@
|
||||
|
||||
function navigate(path, { replace = false } = {}) {
|
||||
if (path !== location.pathname) {
|
||||
history[replace ? "replaceState" : "pushState"](null, "", path + location.search);
|
||||
if (replace) history.replaceState(history.state, "", path + location.search);
|
||||
else history.pushState({ from: here() }, "", path + location.search);
|
||||
}
|
||||
route();
|
||||
}
|
||||
@@ -1039,8 +1263,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The system back gesture, which on a phone is the reflex Escape is here.
|
||||
window.addEventListener("popstate", route);
|
||||
// The system back gesture, which on a phone is the reflex Escape is here,
|
||||
// and back and forward through the filters.
|
||||
window.addEventListener("popstate", restore);
|
||||
|
||||
// ------------------------------------------------ back from another page
|
||||
|
||||
@@ -1082,7 +1307,7 @@
|
||||
$("#sort").querySelectorAll("[data-sort]").forEach((b) => {
|
||||
b.onclick = () => {
|
||||
if (b.getAttribute("aria-disabled") === "true") return;
|
||||
setFilter({ sort: b.dataset.sort });
|
||||
setOrder(b.dataset.sort);
|
||||
};
|
||||
});
|
||||
$("#period").innerHTML = Object.entries(PERIODS).map(([key, p]) =>
|
||||
@@ -1090,7 +1315,7 @@
|
||||
$("#period").addEventListener("change", (e) => setFilter({ period: e.target.value }));
|
||||
$("#clear-tags").addEventListener("click", () => { state.filter.tags.clear(); setFilter({}); });
|
||||
|
||||
const typed = debounce(() => setFilter({}), 300);
|
||||
const typed = debounce(() => setFilter({}, { replace: true }), 300);
|
||||
for (const key of ["company", "place"]) {
|
||||
$(`#f-${key}`).addEventListener("input", (e) => { state.filter[key] = e.target.value; typed(); });
|
||||
}
|
||||
|
||||
@@ -112,6 +112,9 @@
|
||||
</aside>
|
||||
|
||||
<main id="list">
|
||||
{# The company filtered to, when there is exactly one: its name, its
|
||||
roles, its careers page and its star (`renderStrip`). #}
|
||||
<section id="company-strip" class="company-strip" aria-label="Company" hidden></section>
|
||||
<div id="roles-list" class="feed"></div>
|
||||
<div id="feed-empty" class="empty" hidden></div>
|
||||
<div id="feed-end" class="feed-end" role="status"></div>
|
||||
|
||||
Reference in new issue
Block a user