Improved diffview

This commit is contained in:
unknown 2022-04-08 17:02:14 -03:00
parent 7e685957b5
commit 68f5f8b5e5
4 changed files with 46 additions and 6 deletions

View file

@ -491,6 +491,16 @@ .object p {
margin-bottom: 10px;
}
p.edit {
color: #FFFF00;
}
p.add {
color: #00FF00;
}
p.delete {
color: #FF0000;
}
#drawControlsContainer {
background-color: #444;
border-right: 1px #000 solid;

View file

@ -22,6 +22,12 @@ function createInfoBlock(entry) {
element.appendChild(headerElement);
if (entry.diff) {
let diffElement = createInfoParagraph("Diff: ", entry.diff);
diffElement.className = entry.diff;
element.appendChild(diffElement);
}
if (entry.description) {
let descElement = document.createElement("p");
descElement.innerText = entry.description;

View file

@ -146,11 +146,7 @@ async function init(){
a[c.id] = c;
return a;
},{});
if(mode.endsWith("only")){
atlas = atlas.filter(function(entry) {
return JSON.stringify(entry) !== JSON.stringify(liveAtlasReduced[entry.id]);
});
}
// Mark added/edited entries
atlas = atlas.map(function(entry) {
if(liveAtlasReduced[entry.id] === undefined){
entry.diff = "add";
@ -159,12 +155,36 @@ async function init(){
}
return entry;
});
// Mark removed entries
let atlasReduced = atlas.reduce(function(a, c) {
a[c.id] = c;
return a;
},{});
let removedEntries = liveJson.map(function(entry) {
if(atlasReduced[entry.id] === undefined){
entry.diff = "delete";
}
return entry;
});
atlas.push(...removedEntries)
if(mode.includes("only")){
atlas = atlas.filter(function(entry) {
return typeof entry.diff == "string"
});
}
//TEMP FOR TIME TRAVEL
atlasBackup = atlas;
} catch (error) {
console.log("Diff mode failed to load, reverting to normal view - " + error);
} finally {
initView();
if(initOverlap && mode.includes("overlap")){
initOverlap();
} else {
initView();
}
}
}

View file

@ -124,6 +124,10 @@ function renderBackground(atlas){
bgStrokeStyle = "rgba(255, 255, 0, 1)";
backgroundContext.lineWidth = 2;
break;
case "delete":
bgStrokeStyle = "rgba(255, 0, 0, 1)";
backgroundContext.lineWidth = 2;
break;
default:
bgStrokeStyle = "rgba(255, 255, 255, 0.8)";
break;