A built-in's switch and the settings it keeps in Plugins › Built-in or on its own page (Gateway's Recent calls at a time) were found by nothing in Settings' search, and one switched off took its Settings tab and rows with it, so searching "Observability" with it off said no setting matched (the scattered settings audit after netube99 on X). The search now lists, after Settings' own rows and under "Plugins › Built-in", each built-in whose name, line or schema setting has the words, in the language shown or English, one off saying Off. Open goes to Plugins › Built-in and lights that row, again when the list is drawn a second time as the plugins are read. The list is drawn by a lazy setfeats.js the first time a search runs, and only when what it finds changes, as Settings' observer runs the search again on each change under the view. Run (mote, at f98e954ce's tree plus this): settings-search, old-webkit, builtin-places, provider-prefs, i18n-keys: 170 pass, 0 fail, Chromium and WebKit, every language; TestCoreScriptBudget ok. Broken by hand: without the row's light, and with the match always false, the new case went red in Chromium (7 pass, 2 fail each).
69 lines
2.9 KiB
JavaScript
69 lines
2.9 KiB
JavaScript
// Settings' search, through Plugins › Built-in too: a built-in's switch,
|
||
// and the settings it has there or on its own page (Gateway's Recent calls
|
||
// at a time), were found by nothing in Settings, and one switched off took
|
||
// its Settings rows away with it, so a search for it said no setting
|
||
// matched (the scattered settings audit after netube99 on X). Each built-in
|
||
// whose name, words or settings match is listed after Settings' own rows,
|
||
// off ones too, and Open goes to its row in Plugins › Built-in. Loaded by
|
||
// app.js the first time a search runs, as provlinks.js is.
|
||
|
||
// the built-in an Open is for: its row is lit (and scrolled to once) each
|
||
// time Plugins › Built-in draws it in the next few seconds, as the list is
|
||
// drawn again when the plugins are read
|
||
let featAt = null, featAtEnd = 0;
|
||
{
|
||
const draw = window.renderBuiltins;
|
||
window.renderBuiltins = (box, list, done) => {
|
||
draw(box, list, done);
|
||
const row = featAt && box.querySelector(`.feat-row[data-id="${featAt.id}"]`);
|
||
if (!row) return;
|
||
if (!featAt.scrolled) row.scrollIntoView({ block: "center" });
|
||
featAt.scrolled = true;
|
||
row.classList.add("flash");
|
||
};
|
||
}
|
||
window.setFeatsFind = function (words) {
|
||
let box = document.getElementById("setFeats");
|
||
if (!box) {
|
||
box = el("section", "set-page set-feats");
|
||
box.id = "setFeats";
|
||
box.append(el("div", "list prefs"));
|
||
$("#view-settings").append(box);
|
||
}
|
||
const list = box.firstChild;
|
||
const say = (s) => (s ? s + " " + t(s) : "");
|
||
const found = ((words.length && prefs?.builtins) || []).filter((f) => {
|
||
const props = Object.values(f.schema?.properties || {});
|
||
const text = [say(f.name), say(f.sub), ...props.map((p) => say(p.title) + " " + say(p.description))].join(" ").toLowerCase();
|
||
return words.every((w) => text.includes(w));
|
||
});
|
||
// drawn again only when it changes: a draw is a change Settings'
|
||
// observer runs the search again on
|
||
const key = document.documentElement.lang + " " + found.map((f) => f.id + (f.on ? "+" : "-")).join(" ");
|
||
if (box.dataset.key === key) return found.length;
|
||
box.dataset.key = key;
|
||
list.replaceChildren();
|
||
for (const f of found) {
|
||
const r = el("div", "row pref feat-find");
|
||
r.dataset.id = f.id;
|
||
const who = el("div", "who");
|
||
who.append(el("div", "name", t(f.name)));
|
||
const sub = [f.on ? "" : t("Off"), f.sub ? t(f.sub) : ""].filter(Boolean).join(" · ");
|
||
if (sub) who.append(el("div", "sub", sub));
|
||
const go = el("button", "text", t("Open"));
|
||
go.type = "button";
|
||
go.onclick = () => {
|
||
featAt = { id: f.id, scrolled: false };
|
||
clearTimeout(featAtEnd);
|
||
featAtEnd = setTimeout(() => { featAt = null; }, 3000);
|
||
window.pluginTabTo?.("builtin");
|
||
show("plugins");
|
||
};
|
||
r.append(who, go);
|
||
list.append(r);
|
||
}
|
||
box.dataset.part = t("Plugins") + " › " + t("Built-in");
|
||
box.hidden = !found.length;
|
||
return found.length;
|
||
};
|