Commit 5b490eb2 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Add CTRL+L as load shortcut

..as mentioned in the info tab.

Change-Id: I9ddbe1ad7eb3242ad7839650aecc7305a902fb0d
Notry: true
Bug: v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1407056
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58789}
parent ad6c02af
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as d3 from "d3";
import { SourceResolver } from "../src/source-resolver";
import { SelectionBroker } from "../src/selection-broker";
import { DisassemblyView } from "../src/disassembly-view";
......@@ -113,19 +112,30 @@ window.onload = function () {
// The <input> form #upload-helper with type file can't be a picture.
// We hence keep it hidden, and forward the click from the picture
// button #upload.
d3.select("#upload").on("click",
() => document.getElementById("upload-helper").click());
d3.select("#upload-helper").on("change", function (this: HTMLInputElement) {
const uploadFile = this.files && this.files[0];
if (uploadFile) {
const filereader = new FileReader();
filereader.onload = () => {
const txtRes = filereader.result;
if (typeof txtRes == 'string') {
loadFile(txtRes);
}
};
filereader.readAsText(uploadFile);
document.getElementById("upload").addEventListener("click", e => {
document.getElementById("upload-helper").click();
e.stopPropagation();
});
document.getElementById("upload-helper").addEventListener("change",
function (this: HTMLInputElement) {
const uploadFile = this.files && this.files[0];
if (uploadFile) {
const filereader = new FileReader();
filereader.onload = () => {
const txtRes = filereader.result;
if (typeof txtRes == 'string') {
loadFile(txtRes);
}
};
filereader.readAsText(uploadFile);
}
}
);
window.addEventListener("keydown", (e: KeyboardEvent) => {
if (e.keyCode == 76 && e.ctrlKey) { // CTRL + L
document.getElementById("upload-helper").click();
e.stopPropagation();
e.preventDefault();
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment