1
0

JS changes

This commit is contained in:
Scott E. Graves
2017-03-18 18:03:38 -05:00
parent 829341f4a7
commit 62b3dac1e3
6 changed files with 99 additions and 8 deletions

View File

@@ -0,0 +1,4 @@
// Application to/from HTML
(() => {
})();

View File

@@ -0,0 +1,46 @@
// Main
(() => {
const UiState = (()=> {
function _isWalletLocked() {
return window.uiState.isWalletLocked;
}
function _isWalletConfigured() {
return window.uiState.isWalletConfigured;
}
return {
isWalletLocked: _isWalletLocked,
isWalletConfigured: _isWalletConfigured
};
})();
function setMainWindow(name) {
const elem = document.getElementById(name);
const mainWindow = document.getElementById('main_window');
if (mainWindow.childElementCount === 1) {
const curElem = mainWindow.firstChild;
mainWindow.removeChild(curElem);
curElem.classList.add('hidden-element');
document.body.appendChild(curElem);
}
elem.parentElement.removeChild(elem);
elem.classList.remove('hidden-element');
mainWindow.appendChild(elem);
}
document.addEventListener('load', ()=> {
if (UiState.isWalletConfigured()) {
if (UiState.isWalletLocked()) {
setMainWindow('unlock_window')
} else {
setMainWindow('app_window')
}
} else {
setMainWindow('create_window')
}
});
})();