2013-11-12 20:49:00 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/savers/msdownload.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: saver
|
|
|
|
|
|
|
|
Handles saving changes via window.navigator.msSaveBlob()
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Select the appropriate saver module and set it up
|
|
|
|
*/
|
|
|
|
var MsDownloadSaver = function(wiki) {
|
|
|
|
};
|
|
|
|
|
2013-11-27 20:51:08 +00:00
|
|
|
MsDownloadSaver.prototype.save = function(text,method,callback) {
|
2013-11-12 20:49:00 +00:00
|
|
|
// 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 blob = new Blob([text], {type: "text/html"});
|
|
|
|
window.navigator.msSaveBlob(blob,filename);
|
2014-08-27 08:59:01 +00:00
|
|
|
// Callback that we succeeded
|
|
|
|
callback(null);
|
2013-11-12 20:49:00 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Information about this saver
|
|
|
|
*/
|
|
|
|
MsDownloadSaver.prototype.info = {
|
|
|
|
name: "msdownload",
|
2014-02-04 21:21:01 +00:00
|
|
|
priority: 110,
|
|
|
|
capabilities: ["save", "download"]
|
2013-11-12 20:49:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Static method that returns true if this saver is capable of working
|
|
|
|
*/
|
|
|
|
exports.canSave = function(wiki) {
|
|
|
|
return !!window.navigator.msSaveBlob;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Create an instance of this saver
|
|
|
|
*/
|
|
|
|
exports.create = function(wiki) {
|
|
|
|
return new MsDownloadSaver(wiki);
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|