mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
Fixes saving chat log for 516 byond (#89864)
This commit is contained in:
5
tgui/global.d.ts
vendored
5
tgui/global.d.ts
vendored
@@ -178,6 +178,11 @@ type ByondType = {
|
|||||||
* Maps icons to their ref
|
* Maps icons to their ref
|
||||||
*/
|
*/
|
||||||
iconRefMap: Record<string, string>;
|
iconRefMap: Record<string, string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads a blob, platform-agnostic
|
||||||
|
*/
|
||||||
|
saveBlob(blob: Blob, filename: string, ext: string): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -624,13 +624,13 @@ class ChatRenderer {
|
|||||||
'</body>\n' +
|
'</body>\n' +
|
||||||
'</html>\n';
|
'</html>\n';
|
||||||
// Create and send a nice blob
|
// Create and send a nice blob
|
||||||
const blob = new Blob([pageHtml]);
|
const blob = new Blob([pageHtml], { type: 'text/plain' });
|
||||||
const timestamp = new Date()
|
const timestamp = new Date()
|
||||||
.toISOString()
|
.toISOString()
|
||||||
.substring(0, 19)
|
.substring(0, 19)
|
||||||
.replace(/[-:]/g, '')
|
.replace(/[-:]/g, '')
|
||||||
.replace('T', '-');
|
.replace('T', '-');
|
||||||
window.navigator.msSaveBlob(blob, `ss13-chatlog-${timestamp}.html`);
|
Byond.saveBlob(blob, `ss13-chatlog-${timestamp}.html`, '.html');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,6 +345,37 @@
|
|||||||
loadAsset({ url: url, sync: sync, type: 'css' });
|
loadAsset({ url: url, sync: sync, type: 'css' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Byond.saveBlob = function (blob, filename, ext) {
|
||||||
|
if (window.navigator.msSaveBlob) {
|
||||||
|
window.navigator.msSaveBlob(blob, filename);
|
||||||
|
} else if (window.showSaveFilePicker) {
|
||||||
|
var accept = {};
|
||||||
|
accept[blob.type] = [ext];
|
||||||
|
|
||||||
|
var opts = {
|
||||||
|
suggestedName: filename,
|
||||||
|
types: [
|
||||||
|
{
|
||||||
|
description: 'SS13 file',
|
||||||
|
accept: accept,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
window
|
||||||
|
.showSaveFilePicker(opts)
|
||||||
|
.then(function (file) {
|
||||||
|
return file.createWritable();
|
||||||
|
})
|
||||||
|
.then(function (file) {
|
||||||
|
return file.write(blob).then(function () {
|
||||||
|
return file.close();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function () {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Icon cache
|
// Icon cache
|
||||||
Byond.iconRefMap = {};
|
Byond.iconRefMap = {};
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user