mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Switch "userName" to "username"
Because the former is naff
This commit is contained in:
parent
822f436534
commit
d14c61ef45
@ -24,24 +24,24 @@ var UploadSaver = function(wiki) {
|
|||||||
UploadSaver.prototype.save = function(text) {
|
UploadSaver.prototype.save = function(text) {
|
||||||
// Get the various parameters we need
|
// Get the various parameters we need
|
||||||
var backupDir = ".",
|
var backupDir = ".",
|
||||||
userName = this.wiki.getTextReference("$:/UploadName"),
|
username = this.wiki.getTextReference("$:/UploadName"),
|
||||||
password = $tw.utils.getPassword("upload"),
|
password = $tw.utils.getPassword("upload"),
|
||||||
uploadDir = ".",
|
uploadDir = ".",
|
||||||
url = this.wiki.getTextReference("$:/UploadURL");
|
url = this.wiki.getTextReference("$:/UploadURL");
|
||||||
// Bail out if we don't have the bits we need
|
// Bail out if we don't have the bits we need
|
||||||
if(!userName || userName.toString().trim() === "" || !password || password.toString().trim() === "") {
|
if(!username || username.toString().trim() === "" || !password || password.toString().trim() === "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Construct the url if not provided
|
// Construct the url if not provided
|
||||||
if(!url) {
|
if(!url) {
|
||||||
url = "http://" + userName + ".tiddlyspot.com/store.cgi";
|
url = "http://" + username + ".tiddlyspot.com/store.cgi";
|
||||||
}
|
}
|
||||||
// Assemble the header
|
// Assemble the header
|
||||||
var boundary = "---------------------------" + "AaB03x";
|
var boundary = "---------------------------" + "AaB03x";
|
||||||
var uploadFormName = "UploadPlugin";
|
var uploadFormName = "UploadPlugin";
|
||||||
var head = [];
|
var head = [];
|
||||||
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
||||||
head.push("backupDir=" + backupDir + ";user=" + userName + ";password=" + password + ";uploaddir=" + uploadDir + ";;");
|
head.push("backupDir=" + backupDir + ";user=" + username + ";password=" + password + ";uploaddir=" + uploadDir + ";;");
|
||||||
head.push("\r\n" + "--" + boundary);
|
head.push("\r\n" + "--" + boundary);
|
||||||
head.push("Content-disposition: form-data; name=\"userfile\"; filename=\"index.html\"");
|
head.push("Content-disposition: form-data; name=\"userfile\"; filename=\"index.html\"");
|
||||||
head.push("Content-Type: text/html;charset=UTF-8");
|
head.push("Content-Type: text/html;charset=UTF-8");
|
||||||
@ -52,7 +52,7 @@ UploadSaver.prototype.save = function(text) {
|
|||||||
data = head.join("\r\n") + text + tail;
|
data = head.join("\r\n") + text + tail;
|
||||||
// Do the HTTP post
|
// Do the HTTP post
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
http.open("POST",url,true,userName,password);
|
http.open("POST",url,true,username,password);
|
||||||
http.setRequestHeader("Content-Type","multipart/form-data; ;charset=UTF-8; boundary=" + boundary);
|
http.setRequestHeader("Content-Type","multipart/form-data; ;charset=UTF-8; boundary=" + boundary);
|
||||||
http.onreadystatechange = function() {
|
http.onreadystatechange = function() {
|
||||||
if(http.readyState == 4 && http.status == 200) {
|
if(http.readyState == 4 && http.status == 200) {
|
||||||
|
@ -127,7 +127,7 @@ Syncer.prototype.storeTiddler = function(tiddlerFields) {
|
|||||||
|
|
||||||
Syncer.prototype.getStatus = function(callback) {
|
Syncer.prototype.getStatus = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.syncadaptor.getStatus(function(err,isLoggedIn,userName) {
|
this.syncadaptor.getStatus(function(err,isLoggedIn,username) {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.showError(err);
|
self.showError(err);
|
||||||
return;
|
return;
|
||||||
@ -135,13 +135,13 @@ Syncer.prototype.getStatus = function(callback) {
|
|||||||
// Set the various status tiddlers
|
// Set the various status tiddlers
|
||||||
self.wiki.addTiddler({title: self.titleIsLoggedIn,text: isLoggedIn ? "yes" : "no"});
|
self.wiki.addTiddler({title: self.titleIsLoggedIn,text: isLoggedIn ? "yes" : "no"});
|
||||||
if(isLoggedIn) {
|
if(isLoggedIn) {
|
||||||
self.wiki.addTiddler({title: self.titleUserName,text: userName});
|
self.wiki.addTiddler({title: self.titleUserName,text: username});
|
||||||
} else {
|
} else {
|
||||||
self.wiki.deleteTiddler(self.titleUserName);
|
self.wiki.deleteTiddler(self.titleUserName);
|
||||||
}
|
}
|
||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(err,isLoggedIn,userName);
|
callback(err,isLoggedIn,username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -224,7 +224,7 @@ Dispay a password prompt and allow the user to login
|
|||||||
*/
|
*/
|
||||||
Syncer.prototype.handleLoginEvent = function() {
|
Syncer.prototype.handleLoginEvent = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.getStatus(function(err,isLoggedIn,userName) {
|
this.getStatus(function(err,isLoggedIn,username) {
|
||||||
if(!isLoggedIn) {
|
if(!isLoggedIn) {
|
||||||
$tw.passwordPrompt.createPrompt({
|
$tw.passwordPrompt.createPrompt({
|
||||||
serviceName: "Login to TiddlySpace",
|
serviceName: "Login to TiddlySpace",
|
||||||
@ -252,7 +252,7 @@ Syncer.prototype.login = function(username,password,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
self.getStatus(function(err,isLoggedIn,userName) {
|
self.getStatus(function(err,isLoggedIn,username) {
|
||||||
if(callback) {
|
if(callback) {
|
||||||
callback(null,isLoggedIn);
|
callback(null,isLoggedIn);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ Returns an object storing any additional information required by the adaptor.
|
|||||||
Retrieves status information from the server.
|
Retrieves status information from the server.
|
||||||
|
|
||||||
|!Parameter |!Description |
|
|!Parameter |!Description |
|
||||||
|callback |Callback function invoked with parameters `err,isLoggedIn,userName` |
|
|callback |Callback function invoked with parameters `err,isLoggedIn,username` |
|
||||||
|
|
||||||
!! `login(username,password,callback)`
|
!! `login(username,password,callback)`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user