Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send File Data To Input #161

Merged
merged 2 commits into from
Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,20 @@ 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'>" +
"<div>" +
Utils.escapeHtml(file.fileName) +
" " + expandFileContentsElem +
" " + downloadAnchorElem +
" " + switchFileDataToInput +
"<span class='pull-right'>" +
// These are for formatting when stripping HTML
"<span style='display: none'>\n</span>" +
Expand Down
1 change: 1 addition & 0 deletions src/web/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};


Expand Down
10 changes: 10 additions & 0 deletions src/web/OutputWaiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down