Continue UI
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user