mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
This adds the ability to move the file data from Utils.displayFilesAsHTML to the input.
This commit is contained in:
parent
213ec028b8
commit
4143bba89f
3 changed files with 18 additions and 0 deletions
|
@ -942,6 +942,12 @@ const Utils = {
|
||||||
"aria-controls='collapse" + i + "' " +
|
"aria-controls='collapse" + i + "' " +
|
||||||
"title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">🔍</a>";
|
"title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">🔍</a>";
|
||||||
|
|
||||||
|
const hexFileData = Utils.byteArrayToHex(new Uint8Array(file.bytes));
|
||||||
|
|
||||||
|
const switchFileDataToInput = "<a href='#switchFileToInput" + i + "' " +
|
||||||
|
"class='file-switch' " +
|
||||||
|
"fileValue='" + hexFileData + "'>⇧</a>";
|
||||||
|
|
||||||
const html = "<div class='panel panel-default'>" +
|
const html = "<div class='panel panel-default'>" +
|
||||||
"<div class='panel-heading' role='tab' id='heading" + i + "'>" +
|
"<div class='panel-heading' role='tab' id='heading" + i + "'>" +
|
||||||
"<h4 class='panel-title'>" +
|
"<h4 class='panel-title'>" +
|
||||||
|
@ -949,6 +955,7 @@ const Utils = {
|
||||||
Utils.escapeHtml(file.fileName) +
|
Utils.escapeHtml(file.fileName) +
|
||||||
" " + expandFileContentsElem +
|
" " + expandFileContentsElem +
|
||||||
" " + downloadAnchorElem +
|
" " + downloadAnchorElem +
|
||||||
|
" " + switchFileDataToInput +
|
||||||
"<span class='pull-right'>" +
|
"<span class='pull-right'>" +
|
||||||
// These are for formatting when stripping HTML
|
// These are for formatting when stripping HTML
|
||||||
"<span style='display: none'>\n</span>" +
|
"<span style='display: none'>\n</span>" +
|
||||||
|
|
|
@ -158,6 +158,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
document.getElementById("alert-close").addEventListener("click", this.app.alertCloseClick.bind(this.app));
|
document.getElementById("alert-close").addEventListener("click", this.app.alertCloseClick.bind(this.app));
|
||||||
|
this.addDynamicListener(".file-switch", "click", this.output.fileSwitch, this.output);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,16 @@ OutputWaiter.prototype.undoSwitchClick = function() {
|
||||||
document.getElementById("undo-switch").disabled = true;
|
document.getElementById("undo-switch").disabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for file switch click events.
|
||||||
|
* Moves a files data for items created via Utils.displayFilesAsHTML to the input.
|
||||||
|
*/
|
||||||
|
OutputWaiter.prototype.fileSwitch = function(e) {
|
||||||
|
this.switchOrigData = this.manager.input.get();
|
||||||
|
this.app.setInput(e.target.getAttribute("fileValue"));
|
||||||
|
document.getElementById("undo-switch").disabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for maximise output click events.
|
* Handler for maximise output click events.
|
||||||
|
|
Loading…
Reference in a new issue