Skip to content

Commit

Permalink
Wait a bit and retry if mpw object not available
Browse files Browse the repository at this point in the history
fix for issue 8
  • Loading branch information
ttyridal committed Apr 21, 2015
1 parent aa139c7 commit fb09f6a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions ext/data/main_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,32 @@ function update_page_password_input(data) {
var mpw_session=null;
var session_store={};

function recalculate(hide_after_copy) {
function recalculate(hide_after_copy, retry) {
$('#thepassword').html('(calculating..)');
$('#usermessage').html("Please wait...");
if ($('#sitename').val()==null || $('#sitename').val()=="") {
$('#usermessage').html("need sitename");
return;
}
if (!mpw_session)
mpw_session = mpw(
session_store.username,
session_store.masterkey);


if (!mpw_session) {
try {
mpw_session = mpw(
session_store.username,
session_store.masterkey);
} catch(err)
{
if (retry) {
$('#usermessage').html("Waiting didn't help :(");
$('#thepassword').html('(Failed)');
console.log(err.message,"\n",err.stack);
} else {
$('#usermessage').html("waiting for asm.js");
setTimeout(function(){ recalculate(hide_after_copy, true); }, 300);
}
return;
}
}

console.log("calc password "+$('#sitename').val()+" . "+parseInt($('#passwdgeneration').val())+" . "+$('#passwdtype').val());
var i,s="",pass=mpw_session($('#sitename').val(), parseInt($('#passwdgeneration').val()), $('#passwdtype').val());
Expand Down

0 comments on commit fb09f6a

Please sign in to comment.