mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-12-24 19:04:29 +01:00
Improved diffview
This commit is contained in:
parent
7e685957b5
commit
68f5f8b5e5
4 changed files with 46 additions and 6 deletions
|
@ -491,6 +491,16 @@ .object p {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.edit {
|
||||||
|
color: #FFFF00;
|
||||||
|
}
|
||||||
|
p.add {
|
||||||
|
color: #00FF00;
|
||||||
|
}
|
||||||
|
p.delete {
|
||||||
|
color: #FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
#drawControlsContainer {
|
#drawControlsContainer {
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
border-right: 1px #000 solid;
|
border-right: 1px #000 solid;
|
||||||
|
|
|
@ -22,6 +22,12 @@ function createInfoBlock(entry) {
|
||||||
|
|
||||||
element.appendChild(headerElement);
|
element.appendChild(headerElement);
|
||||||
|
|
||||||
|
if (entry.diff) {
|
||||||
|
let diffElement = createInfoParagraph("Diff: ", entry.diff);
|
||||||
|
diffElement.className = entry.diff;
|
||||||
|
element.appendChild(diffElement);
|
||||||
|
}
|
||||||
|
|
||||||
if (entry.description) {
|
if (entry.description) {
|
||||||
let descElement = document.createElement("p");
|
let descElement = document.createElement("p");
|
||||||
descElement.innerText = entry.description;
|
descElement.innerText = entry.description;
|
||||||
|
|
|
@ -146,11 +146,7 @@ async function init(){
|
||||||
a[c.id] = c;
|
a[c.id] = c;
|
||||||
return a;
|
return a;
|
||||||
},{});
|
},{});
|
||||||
if(mode.endsWith("only")){
|
// Mark added/edited entries
|
||||||
atlas = atlas.filter(function(entry) {
|
|
||||||
return JSON.stringify(entry) !== JSON.stringify(liveAtlasReduced[entry.id]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
atlas = atlas.map(function(entry) {
|
atlas = atlas.map(function(entry) {
|
||||||
if(liveAtlasReduced[entry.id] === undefined){
|
if(liveAtlasReduced[entry.id] === undefined){
|
||||||
entry.diff = "add";
|
entry.diff = "add";
|
||||||
|
@ -159,12 +155,36 @@ async function init(){
|
||||||
}
|
}
|
||||||
return entry;
|
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
|
//TEMP FOR TIME TRAVEL
|
||||||
atlasBackup = atlas;
|
atlasBackup = atlas;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Diff mode failed to load, reverting to normal view - " + error);
|
console.log("Diff mode failed to load, reverting to normal view - " + error);
|
||||||
} finally {
|
} finally {
|
||||||
initView();
|
if(initOverlap && mode.includes("overlap")){
|
||||||
|
initOverlap();
|
||||||
|
} else {
|
||||||
|
initView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,10 @@ function renderBackground(atlas){
|
||||||
bgStrokeStyle = "rgba(255, 255, 0, 1)";
|
bgStrokeStyle = "rgba(255, 255, 0, 1)";
|
||||||
backgroundContext.lineWidth = 2;
|
backgroundContext.lineWidth = 2;
|
||||||
break;
|
break;
|
||||||
|
case "delete":
|
||||||
|
bgStrokeStyle = "rgba(255, 0, 0, 1)";
|
||||||
|
backgroundContext.lineWidth = 2;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
bgStrokeStyle = "rgba(255, 255, 255, 0.8)";
|
bgStrokeStyle = "rgba(255, 255, 255, 0.8)";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue