Bläddra i källkod

Merge branch 'unzipmod' of https://github.com/bwhitn/CyberChef into bwhitn-unzipmod

n1474335 8 år sedan
förälder
incheckning
2400de337b
3 ändrade filer med 18 tillägg och 0 borttagningar
  1. 7 0
      src/core/Utils.js
  2. 1 0
      src/web/Manager.js
  3. 10 0
      src/web/OutputWaiter.js

+ 7 - 0
src/core/Utils.js

@@ -977,6 +977,12 @@ const Utils = {
                 "aria-controls='collapse" + i + "' " +
                 "title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">&#x1F50D</a>";
 
+            const hexFileData = Utils.byteArrayToHex(new Uint8Array(file.bytes));
+
+            const switchFileDataToInput = "<a href='#switchFileToInput" + i + "' " +
+                "class='file-switch' " +
+                "fileValue='" + hexFileData + "'>&#x21E7</a>";
+
             const html = "<div class='panel panel-default'>" +
                        "<div class='panel-heading' role='tab' id='heading" + i + "'>" +
                        "<h4 class='panel-title'>" +
@@ -984,6 +990,7 @@ const Utils = {
                        Utils.escapeHtml(file.fileName) +
                        " " +  expandFileContentsElem +
                        " " + downloadAnchorElem +
+                       " " + switchFileDataToInput +
                        "<span class='pull-right'>" +
                        // These are for formatting when stripping HTML
                        "<span style='display: none'>\n</span>" +

+ 1 - 0
src/web/Manager.js

@@ -158,6 +158,7 @@ Manager.prototype.initialiseEventListeners = function() {
 
     // Misc
     document.getElementById("alert-close").addEventListener("click", this.app.alertCloseClick.bind(this.app));
+    this.addDynamicListener(".file-switch", "click", this.output.fileSwitch, this.output);
 };
 
 

+ 10 - 0
src/web/OutputWaiter.js

@@ -167,6 +167,16 @@ OutputWaiter.prototype.undoSwitchClick = function() {
     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.