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:
parent
ff98173d40
commit
dec7870eeb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user