mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-26 22:29:56 +00:00
cache result of failed web load; fixed tour
This commit is contained in:
parent
dc40d1b040
commit
3221d43cdc
@ -22,7 +22,6 @@ TODO:
|
||||
- run apple CPU until boot
|
||||
- better disasm/listing selection
|
||||
- disasm for z80
|
||||
- projects w/ include files
|
||||
- watchpoints
|
||||
- breakpoints
|
||||
- debug inspector
|
||||
@ -45,6 +44,7 @@ TODO:
|
||||
- more UI tests
|
||||
- base-36 encoding for LZG
|
||||
- disassembler for uploaded ROMs
|
||||
- show tool-specific (readonly) include files
|
||||
|
||||
|
||||
WEB WORKER FORMAT
|
||||
|
@ -41,7 +41,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
|
||||
<div id="controls_top">
|
||||
<span class="dropdown">
|
||||
<a class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<a class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Menu">
|
||||
☰ <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@ -84,11 +84,11 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
</ul>
|
||||
</span>
|
||||
|
||||
<select id="preset_select" name="">
|
||||
<select id="preset_select" name="" title="Project Select">
|
||||
</select>
|
||||
|
||||
<span class="dropdown">
|
||||
<a class="btn btn-secondary dropdown-toggle" id="windowMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<a class="btn btn-secondary dropdown-toggle" id="windowMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Window Select">
|
||||
☯ <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="windowMenuButton" id="windowMenuList">
|
||||
|
@ -35,7 +35,7 @@ body {
|
||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
||||
<script src="bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="FileSaver.js/FileSaver.min.js"></script>
|
||||
<script src="src/util.js"></script>
|
||||
<script src="gen/util.js"></script>
|
||||
<script src="src/pixed/pixeleditor.js"></script>
|
||||
|
||||
<script>
|
||||
|
@ -185,40 +185,49 @@ export class CodeProject {
|
||||
|
||||
// TODO: get local file as well as presets?
|
||||
loadFiles(paths:string[], callback:LoadFilesCallback) {
|
||||
var result = [];
|
||||
var result : Dependency[] = [];
|
||||
function addResult(path, data) {
|
||||
result.push({
|
||||
path:path,
|
||||
filename:getFilenameForPath(path),
|
||||
data:data
|
||||
});
|
||||
}
|
||||
var loadNext = () => {
|
||||
var path = paths.shift();
|
||||
if (!path) {
|
||||
callback(null, result); // TODO?
|
||||
// finished loading all files; return result
|
||||
callback(null, result);
|
||||
} else {
|
||||
// look in store
|
||||
this.store.getItem(path, (err, value) => {
|
||||
if (err) {
|
||||
if (err) { // err fetching from store
|
||||
callback(err, result);
|
||||
} else if (value) {
|
||||
result.push({
|
||||
path:path,
|
||||
filename:getFilenameForPath(path),
|
||||
data:value
|
||||
});
|
||||
} else if (value) { // found in store?
|
||||
this.filedata[path] = value;
|
||||
addResult(path, value);
|
||||
loadNext();
|
||||
} else {
|
||||
} else if (path in this.filedata) { // found in cache?
|
||||
var data = this.filedata[path];
|
||||
if (data)
|
||||
addResult(path, data);
|
||||
loadNext();
|
||||
} else { // found on remote fetch?
|
||||
var webpath = "presets/" + this.platform_id + "/" + path;
|
||||
if (this.platform_id == 'vcs' && path.indexOf('.') <= 0)
|
||||
webpath += ".a"; // legacy stuff
|
||||
// TODO: cache files
|
||||
this.callbackGetRemote( webpath, (text:string) => {
|
||||
console.log("GET",webpath,text.length,'bytes');
|
||||
result.push({
|
||||
path:path,
|
||||
filename:getFilenameForPath(path),
|
||||
data:text
|
||||
});
|
||||
this.filedata[path] = text;
|
||||
addResult(path, text);
|
||||
loadNext();
|
||||
}, 'text')
|
||||
.fail(function() {
|
||||
callback("Could not load preset " + path, result);
|
||||
.fail( (err:XMLHttpRequest) => {
|
||||
console.log("Could not load preset", path, err);
|
||||
// only cache result if status is 404 (not found)
|
||||
if (err.status && err.status == 404)
|
||||
this.filedata[path] = null;
|
||||
loadNext();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
24
src/ui.js
24
src/ui.js
@ -688,15 +688,12 @@ function showWelcomeMessage() {
|
||||
if (!localStorage.getItem("8bitworkshop.hello")) {
|
||||
// Instance the tour
|
||||
var is_vcs = platform_id == 'vcs';
|
||||
var tour = new Tour({
|
||||
autoscroll:false,
|
||||
//storage:false,
|
||||
steps: [
|
||||
var steps = [
|
||||
{
|
||||
element: "#editor",
|
||||
element: "#workspace",
|
||||
title: "Welcome to 8bitworkshop!",
|
||||
content: is_vcs ? "Type your 6502 assembly code into the editor, and it'll be assembled in real-time. All changes are saved to browser local storage."
|
||||
: "Type your C source code into the editor, and it'll be compiled in real-time. All changes are saved to browser local storage."
|
||||
: "Type your source code into the editor, and it'll be compiled in real-time. All changes are saved to browser local storage."
|
||||
},
|
||||
{
|
||||
element: "#emulator",
|
||||
@ -719,8 +716,19 @@ function showWelcomeMessage() {
|
||||
element: "#dropdownMenuButton",
|
||||
title: "Main Menu",
|
||||
content: "Click the menu to switch between platforms, create new files, or share your work with others."
|
||||
},
|
||||
]});
|
||||
}];
|
||||
if (!is_vcs) {
|
||||
steps.push({
|
||||
element: "#windowMenuButton",
|
||||
title: "Window List",
|
||||
content: "Switch between editor windows, assembly listings, and other tools like disassembler and memory dump."
|
||||
});
|
||||
}
|
||||
var tour = new Tour({
|
||||
autoscroll:false,
|
||||
//storage:false,
|
||||
steps:steps
|
||||
});
|
||||
tour.init();
|
||||
setTimeout(function() { tour.start(); }, 2000);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ var addr2symbol : {[addr:number]:string};
|
||||
var current_project;
|
||||
var VirtualList;
|
||||
var lastDebugState;
|
||||
var pixeditframe;
|
||||
|
||||
// TODO: functions
|
||||
var inspectVariable;
|
||||
@ -238,7 +237,7 @@ function SourceEditor(path, mode) {
|
||||
function openBitmapEditorWithParams(fmt, bytestr, palfmt, palstr) {
|
||||
$("#pixeditback").show();
|
||||
window.addEventListener("message", handleWindowMessage, false); // TODO: remove listener
|
||||
pixeditframe.contentWindow.postMessage({fmt:fmt, bytestr:bytestr, palfmt:palfmt, palstr:palstr}, '*');
|
||||
window['pixeditframe'].contentWindow.postMessage({fmt:fmt, bytestr:bytestr, palfmt:palfmt, palstr:palstr}, '*');
|
||||
}
|
||||
|
||||
function lookBackwardsForJSONComment(line, req) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user