mirror of
https://github.com/DarrylNixon/binhop
synced 2024-04-22 12:37:06 -07:00
pivot to web!
This commit is contained in:
parent
53f960b3b2
commit
60524bf2dc
15 changed files with 254 additions and 137 deletions
82
static/binhop.js
Normal file
82
static/binhop.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
async function process_upload(file) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const button = document.querySelector('button');
|
||||
button.setAttribute('aria-busy', 'true');
|
||||
button.textContent = `processing ${file.name}...`;
|
||||
|
||||
const response = await fetch('api/upload_file', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
timeout: 600000 // 10 minutes
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const container = document.querySelector('.container');
|
||||
|
||||
// visualization
|
||||
container.innerHTML = `
|
||||
<div class="grid">
|
||||
<div id="blob-column">
|
||||
<canvas id="blob" width="600px" height="600px" style="background-color: #18232c;"></canvas>
|
||||
</div>
|
||||
<div id="info-column">
|
||||
<small>
|
||||
<h1>${data.meta.name}</h1>
|
||||
<details open>
|
||||
<summary>blob meta</summary>
|
||||
<figure>
|
||||
<table role="grid">
|
||||
<tr>
|
||||
<th><strong>filename:</strong></th>
|
||||
<td>${data.meta.name}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><strong>process duration:</strong></th>
|
||||
<td>${data.meta.duration}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><strong>size:</strong></th>
|
||||
<td>${data.meta.sizeb} (${data.meta.sizeh})</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><strong>sha1:</strong></th>
|
||||
<td>${data.meta.sha1}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><strong>md5:</strong></th>
|
||||
<td>${data.meta.md5}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</figure>
|
||||
</details>
|
||||
<article>
|
||||
<header>Header</header>
|
||||
Body
|
||||
<footer>Footer</footer>
|
||||
</article>
|
||||
<article>
|
||||
<header>Header</header>
|
||||
Body
|
||||
<footer>Footer</footer>
|
||||
</article>
|
||||
<pre>${JSON.stringify(data, null, 2)}</pre>
|
||||
</small>
|
||||
</div>
|
||||
</div>`;
|
||||
} else {
|
||||
console.error('error uploading file');
|
||||
}
|
||||
}
|
||||
|
||||
function upload_file() {
|
||||
const fileInput = document.createElement('input');
|
||||
fileInput.type = 'file';
|
||||
fileInput.addEventListener('change', (event) => {
|
||||
const file = event.target.files[0];
|
||||
process_upload(file);
|
||||
});
|
||||
fileInput.click();
|
||||
}
|
BIN
static/binhop.png
Normal file
BIN
static/binhop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
5
static/pico.classless.min.css
vendored
Normal file
5
static/pico.classless.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/pico.classless.min.css.map
Normal file
1
static/pico.classless.min.css.map
Normal file
File diff suppressed because one or more lines are too long
5
static/pico.min.css
vendored
Normal file
5
static/pico.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/pico.min.css.map
Normal file
1
static/pico.min.css.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue