1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 03:19:56 +00:00
TiddlyWiki5/editions/dev/tiddlers/from Heigele and Jurke/Persist data.tid
2014-11-28 10:06:17 +00:00

22 lines
1.1 KiB
Plaintext

created: 20140708085735260
modified: 20140708085759751
tags: doc
title: Persist data
TiddlyWiki supports a wide range of methods to persist your data. One of this methods is the HTML5 fallback saver. This methods works on almost every browser. With this method a copy of the entire wiki will be downloaded by the browser. This means you get a new file everytime you hit the save button. To avoid this and because every Browser has a different API to allow writing direct to the file system there a some plugins for the different browsers. These plug-ins allow the user to save direct to the current open TiddlyWiki-File. The Listing below shows the HTML5-compliant to save the changes via the HTML5 fallback saver by downloading the TW as a complete HTML-file.
```js
DownloadSaver.prototype.save = function(text,method,callback) {
...
var link = document.createElement("a");
link.setAttribute("target","_blank");
...
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
...
link.setAttribute("download",filename);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
return true;
};
```