Skip to content
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<img class="button-img" id="linkedin" alt="LinkedIn - daipham-3213" src="/img/linkedin.svg" width="16"
height="16" />
</a>
<button id="upload-button" title="Upload File" style="display: none;">Upload</button>
<button id="upload-button" title="Upload File">Upload</button>
</div>
</div>
<div id="terminal"></div>
Expand Down
24 changes: 13 additions & 11 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ terminalElement.style.display = 'none';
serial.style.display = 'block';

let progressTicks = 0;
window.started = false;

const emulator = new window.V86({
wasm_path: '/v86/v86.wasm',
screen_container: serial,
Expand All @@ -25,7 +27,6 @@ const emulator = new window.V86({
},
filesystem: {
basefs: '/contents.json',
baseurl: '/flat',
},
autostart: true,
disable_keyboard: true,
Expand All @@ -40,16 +41,17 @@ if (import.meta.env.DEV) {
emulator.add_listener('serial0-output-byte', (byte) => {
const char = String.fromCharCode(byte);

if (char === '$' || char === '#') {
emulator.serial_adapter.term.write('\r\n');

terminalElement.style.display = 'block';
serial.style.display = 'none';
state.textContent = '';

loadAddons(emulator.serial_adapter.term);
registerUploadFilesModal({ emulator });
terminalElement.focus();
if (char === '$' || char === '#' || char === ':') {
if (!window.started) {
window.started = true;
terminalElement.style.display = 'block';
serial.style.display = 'none';
state.textContent = '';

loadAddons(emulator.serial_adapter.term);
registerUploadFilesModal({ emulator });
terminalElement.focus();
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/js/upload-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ const registerUploadFilesModal = ({ emulator }) => {
if (fileInput && selectedFilenameSpan) {
fileInput.addEventListener('change', () => {
if (fileInput.files.length > 0) {
selectFileButton.textContent = Array.from(fileInput.files).reduce(
selectedFilenameSpan.textContent = Array.from(fileInput.files).reduce(
(acc, file, i) => {
const separator = i === 0 ? '' : ', ';
return `${separator}${file.name}`;
},
);
Array.from(fileInput.files).forEach((_file) => {
const reader = new FileReader();
const path = `/${_file.name}`;
const path = `/daiplg/${_file.name}`;
reader.onload = (f) => {
const data = new Uint8Array(f.target.result);
return emulator.create_file(path, data);
Expand Down