Skip to content

Commit

Permalink
circuit sim: improve behaviour of results saving
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed Aug 27, 2021
1 parent c52b56b commit 7273916
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@
saveAs(new Blob([JSON.stringify(out, null, ' ')], { type: 'application/json' }), defaultFilename);
};

function padNum(n, len) {
return n.toString().padStart(len, '0');
}

function timeString() {
const now = new Date();
return `${now.getFullYear()}-${now.getMonth()}-${now.getDay()}T${now.getHours()}${now.getMinutes()}`;
return `${padNum(now.getFullYear(), 4)}-${padNum(now.getMonth() + 1, 2)}-${padNum(now.getDate(), 2)}T${padNum(now.getHours(), 2)}${padNum(now.getMinutes(), 2)}`;
}

CircuitSimulation.prototype.loadJson = function (files) {
Expand All @@ -116,17 +120,17 @@
let parsed;
try {
parsed = JSON.parse(event.target.result);
// allow results JSON or just units member to be used
if (Array.isArray(parsed)) {
this.units = parsed;
} else {
this.units = parsed.units;
}
} catch (err) {
CATMAID.handleError(err);
return;
}

// allow results JSON or just units member to be used
if (Array.isArray(parsed)) {
this.units = parsed;
} else {
this.units = parsed.units;
}
};
reader.readAsText(files[0]);
};
Expand Down

0 comments on commit 7273916

Please sign in to comment.