From e5c50d2a9eeae3d76ec7e32a1139d412b03383ce Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sun, 12 May 2019 15:39:09 -0400 Subject: [PATCH] got rid of local/ prefix -- idk i'm kinda scared --- src/project.ts | 11 ++----- src/store.ts | 1 - src/ui.ts | 85 +++++++++++++++++++++----------------------------- 3 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/project.ts b/src/project.ts index 3e0b569a..dd208baa 100644 --- a/src/project.ts +++ b/src/project.ts @@ -1,7 +1,7 @@ "use strict"; import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, Segment, WorkerResult } from "./workertypes"; -import { getFilenamePrefix, getFolderForPath, isProbablyBinary } from "./util"; +import { getFilenamePrefix, getFolderForPath, isProbablyBinary, getBasePlatform } from "./util"; import { Platform } from "./baseplatform"; type BuildResultCallback = (result:WorkerResult) => void; @@ -65,7 +65,6 @@ export class CodeProject { pushAllFiles(files:string[], fn:string) { // look for local and preset files - files.push('local/'+fn); files.push(fn); // look for files in current (main file) folder var dir = getFolderForPath(this.mainpath); @@ -207,11 +206,10 @@ export class CodeProject { this.filedata[path] = value; // do not update store, just cache addResult(path, value); loadNext(); - } else if (!path.startsWith("local/")) { - // don't load local/ + } else { // found on remote fetch? var preset_id = this.platform_id; - preset_id = preset_id.replace(/[.]\w+/,''); // remove .suffix from preset name + preset_id = getBasePlatform(preset_id); // remove .suffix from preset name var webpath = "presets/" + preset_id + "/" + path; // try to GET file, use file ext to determine text/binary this.callbackGetRemote( webpath, (data:FileData) => { @@ -227,9 +225,6 @@ export class CodeProject { } loadNext(); }, isProbablyBinary(path) ? 'arraybuffer' : 'text'); - } else { - // not gonna find it, keep going - loadNext(); } }); } diff --git a/src/store.ts b/src/store.ts index d1a912d4..e9a5dd61 100644 --- a/src/store.ts +++ b/src/store.ts @@ -26,7 +26,6 @@ var Ver2xFileStore = function(storage, prefix:string) { } this.deleteFile = function(name) { storage.removeItem(prefix + name); - storage.removeItem(prefix + 'local/' + name); //TODO? } } diff --git a/src/ui.ts b/src/ui.ts index 8ec88b0d..fd6bd675 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -303,7 +303,7 @@ function _createNewFile(e) { if (filename.indexOf(".") < 0) { filename += platform.getDefaultExtension(); } - var path = "local/" + filename; + var path = filename; getSkeletonFile(path).then( (result) => { return store.setItem(path, result || "\n"); }).then(() => { @@ -334,7 +334,7 @@ function handleFileUpload(files: File[]) { alertInfo("Files uploaded."); } } else { - var path = "local/" + f.name; + var path = f.name; var reader = new FileReader(); reader.onload = function(e) { var arrbuf = (e.target).result as ArrayBuffer; @@ -679,24 +679,20 @@ function _deleteFile(e) { var wnd = projectWindows.getActive(); if (wnd && wnd.getPath) { var fn = projectWindows.getActiveID(); - if (repo_id || fn.startsWith("local/") || fn.startsWith("shared/")) { - bootbox.confirm("Delete '" + fn + "'?", (ok) => { - if (ok) { - store.removeItem(fn).then( () => { - // if we delete what is selected - if (qs['file'] == fn) { - unsetLastPreset(); - gotoNewLocation(); - } else { - updateSelector(); - alertInfo("Deleted " + fn); - } - }); - } - }); - } else { - alertError("Can only delete local files."); - } + bootbox.confirm("Delete '" + fn + "'?", (ok) => { + if (ok) { + store.removeItem(fn).then( () => { + // if we delete what is selected + if (qs['file'] == fn) { + unsetLastPreset(); + gotoNewLocation(); + } else { + updateSelector(); + alertInfo("Deleted " + fn); + } + }); + } + }); } else { alertError("Cannot delete the active window."); } @@ -780,16 +776,15 @@ function _downloadAllFilesZipFile(e) { } function populateExamples(sel) { - // make sure to use callback so it follows other sections - store.length().then( (len) => { - sel.append($("