1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-28 08:50:22 +00:00

fixed file upload after esbuild refactor

This commit is contained in:
Steven Hugg 2021-08-06 18:05:32 -05:00
parent 79b1d8ba4b
commit 5eb3e864fb
6 changed files with 10 additions and 14 deletions

View File

@ -14,9 +14,6 @@ body {
</head>
<body>
<!-- for file upload -->
<input type="file" id="uploadFileElem" multiple accept="*" style="display:none" onchange="handleFileUpload(this.files)">
<div id="controls_top" class="disable-select">
<div id="controls_dynamic" style="visibility:hidden">
<!-- main menu -->

View File

@ -36,9 +36,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
</head>
<body>
<!-- for file upload -->
<input type="file" id="uploadFileElem" multiple accept="*" style="display:none" onchange="handleFileUpload(this.files)">
<div id="controls_top" class="disable-select">
<div id="controls_dynamic" style="visibility:hidden">
<!-- main menu -->

View File

@ -256,7 +256,7 @@ export class AnimationTimer {
scheduleFrame(msec:number) {
var fn = (timestamp) => {
try {
this.nextFrame(timestamp*1000);
this.nextFrame(timestamp);
} catch (e) {
this.running = false;
this.pulsing = false;

View File

@ -247,10 +247,8 @@ export abstract class BaseWASIMachine extends BaseWASMMachine {
return buffer.length;
}
async loadWASM() {
await loadScript('node_modules/@wasmer/wasi/lib/index.iife.js'); //TODO: require('@wasmer/wasi');
await loadScript('node_modules/@wasmer/wasmfs/lib/index.iife.js'); //TODO: require('@wasmer/wasi');
let WASI = window['WASI'];
let WasmFs = window['WasmFs'];
let WASI = await import('@wasmer/wasi');
let WasmFs = await import('@wasmer/wasmfs');
this.wasmFs = new WasmFs.WasmFs();
let bindings = WASI.WASI.defaultBindings;
bindings.fs = this.wasmFs.fs;

View File

@ -484,11 +484,14 @@ function _createNewFile(e) {
}
function _uploadNewFile(e) {
$("#uploadFileElem").click();
const uploadFileElem = $(`<input type="file" multiple accept="*" style="display:none">`);
const file = uploadFileElem[0] as HTMLInputElement;
uploadFileElem.change((e) => { handleFileUpload(file.files) });
uploadFileElem.click();
}
// called from index.html
function handleFileUpload(files: File[]) {
function handleFileUpload(files: FileList) {
console.log(files);
var index = 0;
function uploadNextFile() {

View File

@ -41,7 +41,8 @@ var _c64 = require('gen/platform/c64.js');
var _vectrex = require('gen/platform/vectrex.js');
var _zx = require('gen/platform/zx.js');
var _atari8 = require('gen/platform/atari8.js');
var util = require('gen/common/util.js');
util.loadScript = function(s) { console.log('tried to load',s); } // for vcs
//