From 9404d670d311f837a7d2b17ab717989109347ec5 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 12 Jul 2012 13:13:48 +0100 Subject: [PATCH] Added download saver, our fallback based on standard HTML It's clunky, and requires manual intervention to accomplish a save, but it does work on Chrome, Safari, iOS mobile safari --- core/modules/savers/download.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/savers/download.js b/core/modules/savers/download.js index 207f3a674..58cc05b20 100644 --- a/core/modules/savers/download.js +++ b/core/modules/savers/download.js @@ -18,7 +18,16 @@ Select the appropriate saver module and set it up var DownloadSaver = function() { }; -DownloadSaver.prototype.save = function() { +DownloadSaver.prototype.save = function(text) { + // Set up the link + var link = document.createElement("a"); + link.setAttribute("target","_blank"); + link.setAttribute("href","data:text/html," + encodeURIComponent(text)); + // Use the download attribute to download it if it is supported + if(link.download !== undefined) { + link.setAttribute("download","tiddlywiki.html"); + } + link.click(); }; /*