From 00913e55e52e838bd08a0372f6ab3222bf9f3d0c Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 2 Sep 2019 20:24:34 -0400 Subject: [PATCH] update project/window files when uploading --- src/platform/verilog.ts | 3 +-- src/ui.ts | 27 +++++++-------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/platform/verilog.ts b/src/platform/verilog.ts index 839afdb3..aaab5282 100644 --- a/src/platform/verilog.ts +++ b/src/platform/verilog.ts @@ -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); diff --git a/src/ui.ts b/src/ui.ts index 90195c28..3d64c448 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -338,18 +338,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(); @@ -358,23 +353,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 }