Skip to content

Commit

Permalink
elfldr: cosmetics to stdout rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
john-tornblom committed Oct 13, 2024
1 parent 665700d commit 2001119
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 14 additions & 7 deletions assets/elfldr.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<link rel="icon" href="data:,"> <!-- dont request favicon -->
<link rel="stylesheet" href="xterm.css">
<script src="xterm.js"></script>
<script src="xterm-addon-fit.min.js"></script>
<title>Payload launcher</title>
<style>
:root {
Expand All @@ -48,7 +49,7 @@
justify-content: center;
min-height: calc(100 * var(--vh) - 10vw);
margin: 0;
padding: 5vw;
padding: 0;
background-color: var(--background-color-primary);
color: #fff;
}
Expand All @@ -58,6 +59,7 @@
flex-direction: column;
align-items: center;
justify-content: center;
padding: 5vw;
}

.drop-zone {
Expand Down Expand Up @@ -153,7 +155,7 @@ <h1>Payload launcher</h1>
<input type="text" id="args-input" class="input-box" placeholder="Optional command line arguments...">
<a class="btn" id="send-btn">Send</a>
</div>
<div id="stdout" class="terminal" style="display: block;"/>
<div id="stdout" class="terminal" style="display: none; height: 90vh; width: 95vw; padding-top: 5vh;"/>
<script>
// workaround for mobile browsers reporting vh with the address bar collapsed
function setViewportHeight() {
Expand Down Expand Up @@ -241,25 +243,30 @@ <h1>Payload launcher</h1>
}

async function deploy(elf, args='') {
const launcher = document.getElementById('launcher');
launcher.style.display = 'none';
stdout.style.display = 'block';

let form = new FormData();
form.append('elf', elf);
form.append('args', args);
form.append('pipe', '1');

const fitAddon = new FitAddon.FitAddon();
const term = new Terminal({
convertEol: true,
altClickMovesCursor: false,
disableStdin: true,
fontSize: 18,
cols: 132,
rows: 26
cols: 80,
rows: 30
});

term.open(stdout);
term.loadAddon(fitAddon);
fitAddon.fit();
term.write("$ " + args + "\n");

const launcher = document.getElementById('launcher');
launcher.style.display = 'none';

let response = await fetch('/elfldr', {
body: form,
method: "post"
Expand Down
8 changes: 8 additions & 0 deletions assets/xterm-addon-fit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2001119

Please sign in to comment.