mirror of
https://github.com/gchq/CyberChef
synced 2024-11-15 17:07:57 +00:00
diff.mjs: Allows showing subtraction
Adds "Show Subtraction" button to allow seeing only the difference between two texts. When selected and combined, user can see only the characters or words that were added. If not combined, with either removed or added but selected, then nothing is displayed.
This commit is contained in:
parent
05e65a74ce
commit
726e117656
1 changed files with 8 additions and 2 deletions
|
@ -47,6 +47,11 @@ class Diff extends Operation {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Show subtraction",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Ignore whitespace",
|
"name": "Ignore whitespace",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -67,6 +72,7 @@ class Diff extends Operation {
|
||||||
diffBy,
|
diffBy,
|
||||||
showAdded,
|
showAdded,
|
||||||
showRemoved,
|
showRemoved,
|
||||||
|
showSubtraction,
|
||||||
ignoreWhitespace
|
ignoreWhitespace
|
||||||
] = args,
|
] = args,
|
||||||
samples = input.split(sampleDelim);
|
samples = input.split(sampleDelim);
|
||||||
|
@ -116,8 +122,8 @@ class Diff extends Operation {
|
||||||
if (showAdded) output += "<span class='hl5'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
if (showAdded) output += "<span class='hl5'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||||
} else if (diff[i].removed) {
|
} else if (diff[i].removed) {
|
||||||
if (showRemoved) output += "<span class='hl3'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
if (showRemoved) output += "<span class='hl3'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||||
} else {
|
} else if (!showSubtraction) {
|
||||||
output += Utils.escapeHtml(diff[i].value);
|
output += Utils.escapeHtml(diff[i].value) + "</span>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue