Add save timestamp support and log interceptor for enhanced debugging
- Introduced `created_at` metadata for saves, enabling timestamp tracking. - Added `InterceptorLogger` to capture logs, aiding in error diagnostics. - Updated web UI to display save creation timestamps. - Improved save/load functionality to maintain compatibility with older formats.
This commit is contained in:
@@ -37,6 +37,7 @@ export interface NetworkConfig {
|
||||
export interface SaveInfo {
|
||||
idx: number,
|
||||
len: number,
|
||||
created_at: string | null,
|
||||
}
|
||||
|
||||
export interface FileList {
|
||||
|
||||
@@ -33,6 +33,7 @@ class SaveEntry {
|
||||
this.view.innerHTML = template.replaceAll("${fileid}", String(fileid));
|
||||
|
||||
let name = document.getElementById("file_" + fileid + "_name") as HTMLElement;
|
||||
let created = document.getElementById("file_" + fileid + "_created") as HTMLElement;
|
||||
let size = document.getElementById("file_" + fileid + "_size") as HTMLElement;
|
||||
let deleteBtn = document.getElementById("file_" + fileid + "_delete") as HTMLButtonElement;
|
||||
deleteBtn.onclick = () => {
|
||||
@@ -45,5 +46,17 @@ class SaveEntry {
|
||||
|
||||
name.innerText = "Slot " + saveinfo.idx;
|
||||
size.innerText = saveinfo.len + " bytes";
|
||||
|
||||
// Format timestamp in browser's local timezone
|
||||
if (saveinfo.created_at) {
|
||||
try {
|
||||
const date = new Date(saveinfo.created_at);
|
||||
created.innerText = date.toLocaleString();
|
||||
} catch (e) {
|
||||
created.innerText = "Invalid date";
|
||||
}
|
||||
} else {
|
||||
created.innerText = "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
<div id="file_${fileid}_name" class="filetitle">Slot</div>
|
||||
</div>
|
||||
|
||||
<div class="flexcontainer">
|
||||
<div class="filekey">Created</div>
|
||||
<div id="file_${fileid}_created" class="filevalue"></div>
|
||||
</div>
|
||||
|
||||
<div class="flexcontainer">
|
||||
<div class="filekey">Size</div>
|
||||
<div id="file_${fileid}_size" class="filevalue"></div>
|
||||
|
||||
Reference in New Issue
Block a user