Name the element a change is in and let the diff show the lines around it
Each group of changes gets a bar with its place in the settings (like router.firewall.rules[3], and the rule's zones) and buttons to show more lines above and below, or all that are hidden. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// The bars of a diff (the Changes page) show the lines hidden next to a change:
|
||||
// a bar sits above its hidden lines (.hid), which follow it up to the next line
|
||||
// that is shown. "down" shows the first ones (below the change above the bar, and
|
||||
// the bar moves after them), "up" the last ones (above the change below the bar).
|
||||
(function () {
|
||||
var STEP = 10;
|
||||
|
||||
function hiddenAfter(bar) {
|
||||
var rows = [];
|
||||
for (var el = bar.nextElementSibling; el && el.classList.contains("hid"); el = el.nextElementSibling) rows.push(el);
|
||||
return rows;
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (e) {
|
||||
var btn = e.target.closest ? e.target.closest("[data-more]") : null;
|
||||
var bar = btn && btn.closest(".diff .gap");
|
||||
if (!bar) return;
|
||||
e.preventDefault();
|
||||
var rows = hiddenAfter(bar);
|
||||
var how = btn.getAttribute("data-more");
|
||||
var shown;
|
||||
if (how === "down") {
|
||||
shown = rows.slice(0, STEP);
|
||||
shown.forEach(function (r) { r.classList.remove("hid"); });
|
||||
if (shown.length) bar.after(shown[shown.length - 1]);
|
||||
} else if (how === "up") {
|
||||
shown = rows.slice(-STEP);
|
||||
shown.forEach(function (r) { r.classList.remove("hid"); });
|
||||
} else {
|
||||
rows.forEach(function (r) { r.classList.remove("hid"); });
|
||||
}
|
||||
var left = hiddenAfter(bar).length;
|
||||
if (!left) {
|
||||
// Nothing more to show: the bar stays only to say where the changes are.
|
||||
bar.querySelectorAll("[data-more]").forEach(function (b) { b.remove(); });
|
||||
} else {
|
||||
var all = bar.querySelector('[data-more="all"]');
|
||||
if (all) all.textContent = "Show " + left + " lines";
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -72,8 +72,13 @@ th[title] { cursor: help; text-decoration: underline dotted; text-underline-offs
|
||||
.diff .add .ln { background: color-mix(in srgb, var(--good) 28%, var(--surface)); }
|
||||
.diff .del { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
|
||||
.diff .del .ln { background: color-mix(in srgb, var(--bad) 28%, var(--surface)); }
|
||||
.diff .gap { background: var(--head); color: var(--muted); padding: .1rem 0; }
|
||||
.diff .gaptext { padding-left: 7.5rem; user-select: none; }
|
||||
.diff .hid { display: none; }
|
||||
.diff .gap { background: var(--head); color: var(--muted); padding: .15rem 0; align-items: center; }
|
||||
.diff .gap .more { flex: none; width: 7.6rem; padding: 0 .5rem; display: flex; gap: .6rem; justify-content: flex-end; user-select: none; }
|
||||
.diff .gap .more:empty { display: none; }
|
||||
.diff .gap button.link { font: inherit; text-decoration: none; padding: 0 .15rem; }
|
||||
.diff .gap .path { padding: 0 .75rem; color: var(--fg); }
|
||||
.diff .gap .path:first-child { padding-left: 8.2rem; }
|
||||
.dialog-question { margin: 0; font-size: 1.05rem; }
|
||||
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; }
|
||||
.upload-card.wide { width: min(48rem, 100%); }
|
||||
|
||||
Reference in New Issue
Block a user