|
|
|
@ -139,7 +139,7 @@ function togglemenu() { |
|
|
|
|
|
|
|
|
|
/// Download Profile Backup
|
|
|
|
|
function backup() { |
|
|
|
|
status("<p>Starting Download...</p>"); |
|
|
|
|
status("<p>Starting backup download ...</p>"); |
|
|
|
|
var download = document.createElement('a'); |
|
|
|
|
download.href = 'data:attachment/text,'+encodeURI(JSON.stringify(localStorage)); |
|
|
|
|
download.target = '_blank'; |
|
|
|
@ -155,11 +155,29 @@ function backup() { |
|
|
|
|
}); |
|
|
|
|
download.dispatchEvent(clickEvent); |
|
|
|
|
togglemenu(); |
|
|
|
|
setTimeout(start, 20000); |
|
|
|
|
setTimeout(start, 2000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Upload Profile Backup
|
|
|
|
|
function restore(evt) { |
|
|
|
|
status("<p>Starting backup restore ...</p>"); |
|
|
|
|
if (!window.FileReader) |
|
|
|
|
return error("your browser dows not support file upload", true); |
|
|
|
|
for (var i=0, f; f=evt.target.files[i]; ++i) { |
|
|
|
|
var file = f; |
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
reader.onload = function(evt) { |
|
|
|
|
if (evt.target.error) return error("error reading file", true); |
|
|
|
|
if (evt.target.readyState==0) return notice("waiting for data ..."); |
|
|
|
|
if (evt.target.readyState==1) return notice("loading data ..."); |
|
|
|
|
var parsed=JSON.parse(evt.target.result); |
|
|
|
|
togglemenu(); |
|
|
|
|
localStorage.pubKey = parsed.pubKey; |
|
|
|
|
localStorage.privKey = parsed.privKey; |
|
|
|
|
setTimeout(start, 2000); |
|
|
|
|
} |
|
|
|
|
reader.readAsText(file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Check if user name is available
|
|
|
|
@ -251,8 +269,8 @@ function createkeypair(user, pwd) { |
|
|
|
|
passphrase: pwd |
|
|
|
|
}).then(function(keyPair) { |
|
|
|
|
success("keys generated"); |
|
|
|
|
localStorage.pubKey = keyPair.publicKeyArmored; |
|
|
|
|
localStorage.privKey = keyPair.privateKeyArmored; |
|
|
|
|
localStorage["pubKey"] = keyPair.publicKeyArmored; |
|
|
|
|
localStorage["privKey"] = keyPair.privateKeyArmored; |
|
|
|
|
login(); |
|
|
|
|
}).catch(function(e) { |
|
|
|
|
error(e); |
|
|
|
@ -262,15 +280,15 @@ function createkeypair(user, pwd) { |
|
|
|
|
/// Get Own Public Key
|
|
|
|
|
/** @return public key object */ |
|
|
|
|
function publicKey() { |
|
|
|
|
if (typeof localStorage.pubKey == 'undefined') return null; |
|
|
|
|
return openpgp.key.readArmored(localStorage.pubKey); |
|
|
|
|
if (typeof localStorage["pubKey"] == 'undefined') return null; |
|
|
|
|
return openpgp.key.readArmored(localStorage["pubKey"]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Get Own Private Key
|
|
|
|
|
/** @return private key object */ |
|
|
|
|
function privateKey() { |
|
|
|
|
if (typeof localStorage.privKey == 'undefined') return null; |
|
|
|
|
return openpgp.key.readArmored(localStorage.privKey); |
|
|
|
|
if (typeof localStorage["privKey"] == 'undefined') return null; |
|
|
|
|
return openpgp.key.readArmored(localStorage["privKey"]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Get Own User Name
|
|
|
|
|