1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Update HTML5 saver to use current filename where possible

Most browsers still ignore the specified filename, sadly.
This commit is contained in:
Jeremy Ruston 2013-09-19 10:50:14 +01:00
parent ff98173d40
commit dec7870eeb

View File

@ -19,11 +19,17 @@ var DownloadSaver = function(wiki) {
};
DownloadSaver.prototype.save = function(text) {
// Get the current filename
var filename = "tiddlywiki.html",
p = document.location.pathname.lastIndexOf("/");
if(p !== -1) {
filename = document.location.pathname.substr(p+1);
}
// Set up the link
var link = document.createElement("a");
link.setAttribute("target","_blank");
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
link.setAttribute("download","tiddlywiki.html");
link.setAttribute("download",filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);