Skip to content

Commit 13115df

Browse files
committed
toggle to hide the path to the class
1 parent fd1978c commit 13115df

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

public/feather_diff.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import * as tiny from "./tiny_mappings.js";
2424
const buildTargetElement = document.getElementById("build-target");
2525
const diffViewerElement = document.getElementById("diff-viewer");
2626

27+
const hideClassPath = document.getElementById("hide-class-path");
28+
2729
async function updateFeatherBuilds() {
2830
if (
2931
possibleVersions.some((version) => versionSelectorInput.value === version)
@@ -83,7 +85,7 @@ import * as tiny from "./tiny_mappings.js";
8385
}
8486

8587
function diffMappings(source, target) {
86-
printDiff(diffMemberArray(source.classes, target), "classes-diff")
88+
printDiff(diffMemberArray(source.classes, target, hideClassPath.checked), "classes-diff")
8789
printDiff(diffMemberArray(source.methods, target), "methods-diff")
8890
printDiff(diffMemberArray(source.fields, target), "fields-diff")
8991
}
@@ -92,16 +94,26 @@ import * as tiny from "./tiny_mappings.js";
9294
document.getElementById(elementID).innerText = diff.map(value => `${value.source} -> ${value.target}`).join("\n")
9395
}
9496

95-
function diffMemberArray(source, targetMappings) {
97+
function diffMemberArray(source, targetMappings, stripPath = false) {
9698
let diff = []
9799

98100
source.forEach(source => {
99101
let target = targetMappings.find(source.calamus)
100102

101103
if (target !== undefined && source.feather !== target.feather) {
104+
let sourceFeather = source.feather;
105+
let targetFeather = target.feather;
106+
107+
if (stripPath) {
108+
if (sourceFeather.substring(0, sourceFeather.lastIndexOf('/')) === targetFeather.substring(0, targetFeather.lastIndexOf('/'))) {
109+
sourceFeather = sourceFeather.split('/').pop();
110+
targetFeather = targetFeather.split('/').pop();
111+
}
112+
}
113+
102114
diff.push({
103-
source: source.feather,
104-
target: target.feather
115+
source: sourceFeather,
116+
target: targetFeather
105117
})
106118
}
107119
})
@@ -132,6 +144,10 @@ import * as tiny from "./tiny_mappings.js";
132144
async (_) => await updateFeatherDiff(),
133145
);
134146

147+
hideClassPath.addEventListener("change", async (_) => {
148+
await updateFeatherDiff();
149+
});
150+
135151
function updateVersionList() {
136152
const list = possibleVersions;
137153
while (versionListElement.firstChild)

src/pages/featherDiff.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ import Layout from "../layouts/Layout.astro";
4040
<!-- Data here will be inserted by JavaScript -->
4141
</select>
4242
</div>
43+
<fieldset>
44+
<input type="checkbox" id="hide-class-path" />
45+
<label for="hide-class-path">Hide class paths</label>
46+
</fieldset>
4347
</div>
4448

4549
<div id="diff-viewer" style="display:none; max-width: 100%;">

0 commit comments

Comments
 (0)