mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Merge branch 'master' of https://Jermolene@github.com/Jermolene/TiddlyWiki5.git
This commit is contained in:
commit
9cff8eb741
|
@ -15,24 +15,50 @@ Handles saving changes via the AndTidWiki Android app
|
||||||
var AndTidWiki = function(wiki) {
|
var AndTidWiki = function(wiki) {
|
||||||
};
|
};
|
||||||
|
|
||||||
AndTidWiki.prototype.save = function(text,method,callback) {
|
AndTidWiki.prototype.save = function(text,method,callback,options) {
|
||||||
// Get the pathname of this document
|
var filename = options && options.variables ? options.variables.filename : null;
|
||||||
var pathname = decodeURIComponent(document.location.toString().split("#")[0]);
|
if (method === "download") {
|
||||||
// Strip the file://
|
// Support download
|
||||||
if(pathname.indexOf("file://") === 0) {
|
if (window.twi.saveDownload) {
|
||||||
pathname = pathname.substr(7);
|
try {
|
||||||
|
window.twi.saveDownload(text,filename);
|
||||||
|
} catch(err) {
|
||||||
|
if (err.message === "Method not found") {
|
||||||
|
window.twi.saveDownload(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var link = document.createElement("a");
|
||||||
|
link.setAttribute("href","data:text/plain," + encodeURIComponent(text));
|
||||||
|
if (filename) {
|
||||||
|
link.setAttribute("download",filename);
|
||||||
|
}
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
|
} else if (window.twi.saveWiki) {
|
||||||
|
// Direct save in Tiddloid
|
||||||
|
window.twi.saveWiki(text);
|
||||||
|
} else {
|
||||||
|
// Get the pathname of this document
|
||||||
|
var pathname = decodeURIComponent(document.location.toString().split("#")[0]);
|
||||||
|
// Strip the file://
|
||||||
|
if(pathname.indexOf("file://") === 0) {
|
||||||
|
pathname = pathname.substr(7);
|
||||||
|
}
|
||||||
|
// Strip any query or location part
|
||||||
|
var p = pathname.indexOf("?");
|
||||||
|
if(p !== -1) {
|
||||||
|
pathname = pathname.substr(0,p);
|
||||||
|
}
|
||||||
|
p = pathname.indexOf("#");
|
||||||
|
if(p !== -1) {
|
||||||
|
pathname = pathname.substr(0,p);
|
||||||
|
}
|
||||||
|
// Save the file
|
||||||
|
window.twi.saveFile(pathname,text);
|
||||||
}
|
}
|
||||||
// Strip any query or location part
|
|
||||||
var p = pathname.indexOf("?");
|
|
||||||
if(p !== -1) {
|
|
||||||
pathname = pathname.substr(0,p);
|
|
||||||
}
|
|
||||||
p = pathname.indexOf("#");
|
|
||||||
if(p !== -1) {
|
|
||||||
pathname = pathname.substr(0,p);
|
|
||||||
}
|
|
||||||
// Save the file
|
|
||||||
window.twi.saveFile(pathname,text);
|
|
||||||
// Call the callback
|
// Call the callback
|
||||||
callback(null);
|
callback(null);
|
||||||
return true;
|
return true;
|
||||||
|
@ -44,7 +70,7 @@ Information about this saver
|
||||||
AndTidWiki.prototype.info = {
|
AndTidWiki.prototype.info = {
|
||||||
name: "andtidwiki",
|
name: "andtidwiki",
|
||||||
priority: 1600,
|
priority: 1600,
|
||||||
capabilities: ["save", "autosave"]
|
capabilities: ["save", "autosave", "download"]
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -280,7 +280,7 @@ exports.formatDateString = function(date,template) {
|
||||||
return $tw.utils.pad(date.getSeconds());
|
return $tw.utils.pad(date.getSeconds());
|
||||||
}],
|
}],
|
||||||
[/^0XXX/, function() {
|
[/^0XXX/, function() {
|
||||||
return $tw.utils.pad(date.getMilliseconds());
|
return $tw.utils.pad(date.getMilliseconds(),3);
|
||||||
}],
|
}],
|
||||||
[/^0DD/, function() {
|
[/^0DD/, function() {
|
||||||
return $tw.utils.pad(date.getDate());
|
return $tw.utils.pad(date.getDate());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user