mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-26 11:53:26 -08: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
1 changed files with 7 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue