1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Ensure tiddlyspot saver works with local storage disabled

Fixes #3955
This commit is contained in:
Jeremy Ruston 2019-06-08 16:38:13 +01:00
parent abb3c01505
commit 8012a3508f

View File

@ -136,22 +136,31 @@ exports.getBoundingPageRect = function(element) {
Saves a named password in the browser
*/
exports.savePassword = function(name,password) {
var done = false;
try {
if(window.localStorage) {
localStorage.setItem("tw5-password-" + name,password);
}
window.localStorage.setItem("tw5-password-" + name,password);
done = true;
} catch(e) {
}
if(!done) {
$tw.savedPasswords = $tw.savedPasswords || Object.create(null);
$tw.savedPasswords[name] = password;
}
};
/*
Retrieve a named password from the browser
*/
exports.getPassword = function(name) {
var value;
try {
return window.localStorage ? localStorage.getItem("tw5-password-" + name) : "";
value = window.localStorage.getItem("tw5-password-" + name);
} catch(e) {
return "";
}
if(value !== undefined) {
return value;
} else {
return ($tw.savedPasswords || Object.create(null))[name] || "";
}
};