Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
scottanderson committed Oct 11, 2024
1 parent 05b93a5 commit 44b16d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ts/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,14 @@ export class Studio {
btnDownload.appendChild(imgDownload);
btnDownload.classList.add('btn', 'btn-secondary');
btnDownload.addEventListener('click', () => {
if (this.modified) {
console.log('Exporting', this.railroad);
}
const gvas = railroadToGvas(this.railroad);
console.log('Exported', gvas);
const blob = gvasToBlob(gvas);
const url = URL.createObjectURL(blob);
console.log('Serialized', blob);
const a = document.createElement('a');
a.href = url;
a.download = this.exportFileName();
Expand Down
6 changes: 4 additions & 2 deletions ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function handleDrop(e: DragEvent) {

function handleFile(file?: File): void {
if (!file) return;
console.log('Parsing', file);
file.arrayBuffer()
.then((buffer) => handleArrayBuffer(buffer, file.name))
.catch(handleError);
Expand All @@ -111,6 +112,7 @@ function handleUrl(url: string) {
console.log(response);
throw new Error(`Fetch failed: ${url} ${response.status} ${response.statusText}`);
}
console.log('Parsing', response);
return response.arrayBuffer();
})
.then((buffer) => handleArrayBuffer(buffer, filename))
Expand All @@ -137,7 +139,7 @@ function handleArrayBuffer(buffer: ArrayBuffer, filename: string) {
return new Promise<void>((resolve, reject) => {
window.setTimeout(rejectOnCatch(reject, () => {
const gvas = parseGvas(buffer);
console.log(gvas);
console.log('Parsed', gvas);
titleText.textContent = 'Importing ' + filename;
window.setTimeout(rejectOnCatch(reject, () => {
const railroad = gvasToRailroad(gvas);
Expand All @@ -148,7 +150,7 @@ function handleArrayBuffer(buffer: ArrayBuffer, filename: string) {
// Initialize the Studio UI
window.studio = new Studio(filename, railroad, header, content);
document.title = filename + ' - Railroad Studio';
console.log(railroad);
console.log('Imported', railroad);
resolve();
}), 10);
}), 10);
Expand Down

0 comments on commit 44b16d4

Please sign in to comment.