1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-26 07:29:22 +00:00

update project/window files when uploading

This commit is contained in:
Steven Hugg 2019-09-02 20:24:34 -04:00
parent a58d1d06ed
commit 00913e55e5
2 changed files with 8 additions and 22 deletions

View File

@ -1,4 +1,3 @@
"use strict";
import { Platform, BasePlatform } from "../baseplatform"; import { Platform, BasePlatform } from "../baseplatform";
import { PLATFORMS, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, getMousePos, KeyFlags } from "../emu"; import { PLATFORMS, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, getMousePos, KeyFlags } from "../emu";
@ -392,7 +391,7 @@ var VerilogPlatform = function(mainElement, options) {
video.vcanvas.click( (e) => { video.vcanvas.click( (e) => {
if (!gen) return; // must have created emulator if (!gen) return; // must have created emulator
if (!e.ctrlKey) { if (!e.ctrlKey) {
setFrameRateUI(60); //setFrameRateUI(60);
return; // ctrl key must be down return; // ctrl key must be down
} }
setFrameRateUI(1.0/2048); setFrameRateUI(1.0/2048);

View File

@ -338,18 +338,13 @@ function _uploadNewFile(e) {
function handleFileUpload(files: File[]) { function handleFileUpload(files: File[]) {
console.log(files); console.log(files);
var index = 0; var index = 0;
var gotoMainFile = (files.length == 1);
function uploadNextFile() { function uploadNextFile() {
var f = files[index++]; var f = files[index++];
if (!f) { if (!f) {
console.log("Done uploading"); console.log("Done uploading");
if (gotoMainFile) { updateSelector();
gotoNewLocation(); alertInfo("Files uploaded. Use the Project Selector if you want to load an uploaded file as a project.");
} else { gaEvent('workspace', 'file', 'upload');
updateSelector();
alertInfo("Files uploaded.");
gaEvent('workspace', 'file', 'upload');
}
} else { } else {
var path = f.name; var path = f.name;
var reader = new FileReader(); var reader = new FileReader();
@ -358,23 +353,15 @@ function handleFileUpload(files: File[]) {
var data : FileData = new Uint8Array(arrbuf); var data : FileData = new Uint8Array(arrbuf);
// convert to UTF8, unless it's a binary file // convert to UTF8, unless it's a binary file
if (isProbablyBinary(path, data)) { if (isProbablyBinary(path, data)) {
gotoMainFile = false; //gotoMainFile = false;
} else { } else {
data = byteArrayToUTF8(data).replace('\r\n','\n'); // convert CRLF to LF data = byteArrayToUTF8(data).replace('\r\n','\n'); // convert CRLF to LF
} }
// store in local forage // store in local forage
// TODO: use projectWindows uploadFile() // TODO: use projectWindows uploadFile()
store.setItem(path, data, function(err, result) { projectWindows.updateFile(path, data);
if (err) console.log("Uploaded " + path + " " + data.length + " bytes");
alertError("Error uploading " + path + ": " + err); uploadNextFile();
else {
console.log("Uploaded " + path + " " + data.length + " bytes");
if (index == 1) {
qs['file'] = path; // TODO?
}
uploadNextFile();
}
});
} }
reader.readAsArrayBuffer(f); // read as binary reader.readAsArrayBuffer(f); // read as binary
} }