update project/window files when uploading

This commit is contained in:
Steven Hugg 2019-09-02 20:24:34 -04:00
parent 25c14ed53b
commit 47aaa1d302
2 changed files with 8 additions and 22 deletions

View File

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

View File

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