1
0

Continue UI

This commit is contained in:
Scott E. Graves
2017-03-19 21:35:42 -05:00
parent fff3ac0eb8
commit 1192283ebf
5 changed files with 87 additions and 7 deletions

View File

@@ -21,6 +21,16 @@
};
})();
const UiActions = (() => {
function _unlockWallet(pwd, cb) {
return window.uiActions.unlockWallet(pwd, cb);
}
return {
unlockWallet: _unlockWallet
};
})();
function setMainWindow(name) {
console.log('Setting main window: ' + name);
const elem = document.getElementById(name);
@@ -37,12 +47,34 @@
mainWindow.appendChild(elem);
}
function displayErrorPopup(title, msg, cb) {
if (cb) {
cb();
}
}
window.addEventListener('load', ()=> {
console.log('Main window load');
if (UiState.isOnline()) {
if (UiState.isWalletConfigured()) {
if (UiState.isWalletLocked()) {
setMainWindow('unlock_window');
const unlockButton = document.getElementById('ID_UnlockWalletButton');
unlockButton.onclick = ()=> {
const password = document.getElementById('ID_WalletUnlockPwd');
if (UiActions.unlockWallet(password.value, (success, reason) => {
password.value = '';
if (success) {
setMainWindow('app_window');
} else {
displayErrorPopup('Failed to unlock wallet', reason, ()=> {
window.reload();
});
}
})) {
setMainWindow('unlocking_window');
}
};
} else {
setMainWindow('app_window');
}