mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-21 16:58:44 +00:00
Fixes ESLint errors (#9668)
* fix: apply automatic eslint fixes * lint: allow hashbang comment for tiddlywiki.js * lint: first back of manual lint fixes for unused vars * lint: added more fixes for unused vars * lint: missed files * lint: updated eslint config with selected rules from #9669
This commit is contained in:
@@ -15,27 +15,27 @@ var AndTidWiki = function(wiki) {
|
||||
|
||||
AndTidWiki.prototype.save = function(text,method,callback,options) {
|
||||
var filename = options && options.variables ? options.variables.filename : null;
|
||||
if (method === "download") {
|
||||
if(method === "download") {
|
||||
// Support download
|
||||
if (window.twi.saveDownload) {
|
||||
if(window.twi.saveDownload) {
|
||||
try {
|
||||
window.twi.saveDownload(text,filename);
|
||||
} catch(err) {
|
||||
if (err.message === "Method not found") {
|
||||
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);
|
||||
if(filename) {
|
||||
link.setAttribute("download",filename);
|
||||
}
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
} else if (window.twi.saveWiki) {
|
||||
} else if(window.twi.saveWiki) {
|
||||
// Direct save in Tiddloid
|
||||
window.twi.saveWiki(text);
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@ var findSaver = function(window) {
|
||||
console.log({ msg: "custom saver is disabled", reason: err });
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
var saver = findSaver(window) || findSaver(window.parent) || {};
|
||||
|
||||
var CustomSaver = function(wiki) {
|
||||
|
||||
@@ -80,7 +80,7 @@ GiteaSaver.prototype.save = function(text,method,callback) {
|
||||
callback: function(err,getResponseDataJson,xhr) {
|
||||
if(xhr.status === 404) {
|
||||
callback("Please ensure the branch in the Gitea repo exists");
|
||||
}else{
|
||||
} else {
|
||||
data["branch"] = branch;
|
||||
self.upload(uri + filename, use_put?"PUT":"POST", headers, data, callback);
|
||||
}
|
||||
@@ -101,7 +101,6 @@ GiteaSaver.prototype.upload = function(uri,method,headers,data,callback) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,8 +17,7 @@ var GitHubSaver = function(wiki) {
|
||||
};
|
||||
|
||||
GitHubSaver.prototype.save = function(text,method,callback) {
|
||||
var self = this,
|
||||
username = this.wiki.getTiddlerText("$:/GitHub/Username"),
|
||||
var username = this.wiki.getTiddlerText("$:/GitHub/Username"),
|
||||
password = $tw.utils.getPassword("github"),
|
||||
repo = this.wiki.getTiddlerText("$:/GitHub/Repo"),
|
||||
path = this.wiki.getTiddlerText("$:/GitHub/Path",""),
|
||||
@@ -81,7 +80,6 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,8 +18,7 @@ var GitLabSaver = function(wiki) {
|
||||
|
||||
GitLabSaver.prototype.save = function(text,method,callback) {
|
||||
/* See https://docs.gitlab.com/ee/api/repository_files.html */
|
||||
var self = this,
|
||||
username = this.wiki.getTiddlerText("$:/GitLab/Username"),
|
||||
var username = this.wiki.getTiddlerText("$:/GitLab/Username"),
|
||||
password = $tw.utils.getPassword("gitlab"),
|
||||
repo = this.wiki.getTiddlerText("$:/GitLab/Repo"),
|
||||
path = this.wiki.getTiddlerText("$:/GitLab/Path",""),
|
||||
@@ -45,7 +44,7 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
||||
var uri = endpoint + "/projects/" + encodeURIComponent(repo) + "/repository/";
|
||||
// Perform a get request to get the details (inc shas) of files in the same path as our file
|
||||
$tw.utils.httpRequest({
|
||||
url: uri + "tree/?path=" + encodeURIComponent(path.replace(/^\/+|\/$/g, '')) + "&branch=" + encodeURIComponent(branch.replace(/^\/+|\/$/g, '')),
|
||||
url: uri + "tree/?path=" + encodeURIComponent(path.replace(/^\/+|\/$/g, "")) + "&branch=" + encodeURIComponent(branch.replace(/^\/+|\/$/g, "")),
|
||||
type: "GET",
|
||||
headers: headers,
|
||||
callback: function(err,getResponseDataJson,xhr) {
|
||||
@@ -71,7 +70,7 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
||||
};
|
||||
// Perform a request to save the file
|
||||
$tw.utils.httpRequest({
|
||||
url: uri + "files/" + encodeURIComponent(path.replace(/^\/+/, '') + filename),
|
||||
url: uri + "files/" + encodeURIComponent(path.replace(/^\/+/, "") + filename),
|
||||
type: requestType,
|
||||
headers: headers,
|
||||
data: JSON.stringify(data),
|
||||
@@ -79,7 +78,6 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ PutSaver.prototype.save = function(text,method,callback) {
|
||||
} else if(status === 403) { // permission denied
|
||||
errorMsg = $tw.language.getString("Error/PutForbidden");
|
||||
}
|
||||
if (xhr.responseText) {
|
||||
if(xhr.responseText) {
|
||||
// treat any server response like a plain text error explanation
|
||||
errorMsg = errorMsg + "\n\n" + xhr.responseText;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ UploadSaver.prototype.save = function(text,method,callback) {
|
||||
uploadWithUrlOnly = this.wiki.getTextReference("$:/UploadWithUrlOnly") || "no",
|
||||
url = this.wiki.getTextReference("$:/UploadURL");
|
||||
// Bail out if we don't have the bits we need
|
||||
if (uploadWithUrlOnly === "yes") {
|
||||
if(uploadWithUrlOnly === "yes") {
|
||||
// The url is good enough. No need for a username and password.
|
||||
// Assume the server uses some other kind of auth mechanism.
|
||||
if(!url || url.toString().trim() === "") {
|
||||
@@ -48,7 +48,6 @@ UploadSaver.prototype.save = function(text,method,callback) {
|
||||
}
|
||||
// Assemble the header
|
||||
var boundary = "---------------------------" + "AaB03x";
|
||||
var uploadFormName = "UploadPlugin";
|
||||
var head = [];
|
||||
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
||||
head.push("backupDir=" + backupDir + ";user=" + username + ";password=" + password + ";uploaddir=" + uploadDir + ";;");
|
||||
|
||||
Reference in New Issue
Block a user