Implement decryption phase selection
MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/decryption-phase-content.html
HiddenWallet/HiddenWallet.GUI/app/html/decryption-phase-content.html
<br />
<button class="btn btn-lg btn-primary btn-block" type="submit">Decrypt</button>
</form>
- <div class="container" ng-controller="WalletCtrl as ctrl">
- <p style="color: red" ng-show="ctrl.ErrorMessage">{{ctrl.ErrorMessage}}</p>
- <p>{{ ctrl.Wallet }}</p>
- </div>
</div>
<div class="jumbotron" id="generate-active">
<form class="form-signin">

MODIFY
HiddenWallet/HiddenWallet.GUI/app/html/decryption-phase-menu.html
HiddenWallet/HiddenWallet.GUI/app/html/decryption-phase-menu.html
@@ -4,8 +4,8 @@ Multiple lines will require custom code not provided by Bootstrap. -->
<nav>
<ul class="nav nav-justified">
<li class="active"><a>Decrypt</a></li>
- <li><a href="javascript:decryptionPhaseMenuShow('generate')">Generate</a></li>
- <li><a href="javascript:decryptionPhaseMenuShow('recover')">Recover</a></li>
+ <li><a href="javascript:decryptionPhaseShow('generate')">Generate</a></li>
+ <li><a href="javascript:decryptionPhaseShow('recover')">Recover</a></li>
</ul>
</nav>
</div>
@@ -13,9 +13,9 @@ Multiple lines will require custom code not provided by Bootstrap. -->
<div class="masthead" id="generate-active">
<nav>
<ul class="nav nav-justified">
- <li><a href="javascript:decryptionPhaseMenuShow('decrypt')">Decrypt</a></li>
+ <li><a href="javascript:decryptionPhaseShow('decrypt')">Decrypt</a></li>
<li class="active"><a>Generate</a></li>
- <li><a href="javascript:decryptionPhaseMenuShow('recover')">Recover</a></li>
+ <li><a href="javascript:decryptionPhaseShow('recover')">Recover</a></li>
</ul>
</nav>
</div>
@@ -23,8 +23,8 @@ Multiple lines will require custom code not provided by Bootstrap. -->
<div class="masthead" id="recover-active">
<nav>
<ul class="nav nav-justified">
- <li><a href="javascript:decryptionPhaseMenuShow('decrypt')">Decrypt</a></li>
- <li><a href="javascript:decryptionPhaseMenuShow('generate')">Generate</a></li>
+ <li><a href="javascript:decryptionPhaseShow('decrypt')">Decrypt</a></li>
+ <li><a href="javascript:decryptionPhaseShow('generate')">Generate</a></li>
<li class="active"><a>Recover</a></li>
</ul>
</nav>

MODIFY
HiddenWallet/HiddenWallet.GUI/index.html
HiddenWallet/HiddenWallet.GUI/index.html
<link rel="stylesheet" href="app/css/justified-nav.css">
</head>
-<body onload="decryptionPhaseMenuShow('decrypt')">
+<body onload="decryptionPhaseShow()">
<iframe id="decryption-phase-menu-frame" src="app/html/decryption-phase-menu.html" style="display:none"></iframe>
<iframe id="decryption-phase-content-frame" src="app/html/decryption-phase-content.html" style="display:none"></iframe>
<div class="container">
<script type="text/javascript" src="app/app.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
- function decryptionPhaseMenuShow(menuItem)
- {
- if (menuItem === "decrypt")
- {
+ var walletExists;
+ function decryptionPhaseShow(menuItem = "") {
+ if (menuItem === "") {
+ var result = httpGetWallet("wallet-exists");
+ walletExists = JSON.parse(result).Value;
+ if (walletExists === true) {
+ decryptionPhaseShow("decrypt");
+ }
+ else {
+ decryptionPhaseShow("generate");
+ }
+ }
+ else if (menuItem === "decrypt") {
document.getElementById("menu").innerHTML = document.getElementById("decryption-phase-menu-frame").contentWindow.document.getElementById("decrypt-active").innerHTML;
+ if (walletExists === true) {
document.getElementById("content").innerHTML = document.getElementById("decryption-phase-content-frame").contentWindow.document.getElementById("decrypt-active").innerHTML;
}
- else if (menuItem === "generate")
- {
+ else {
+ document.getElementById("content").innerHTML = '<div class="alert alert-warning" role="alert"><strong>No wallet found!</strong> Generate or recover your wallet before decrypting it!</div>';
+ }
+ }
+ else if (menuItem === "generate") {
document.getElementById("menu").innerHTML = document.getElementById("decryption-phase-menu-frame").contentWindow.document.getElementById("generate-active").innerHTML;
+ if (walletExists === false) {
document.getElementById("content").innerHTML = document.getElementById("decryption-phase-content-frame").contentWindow.document.getElementById("generate-active").innerHTML;
}
- else if (menuItem === "recover")
- {
+ else {
+ document.getElementById("content").innerHTML = '<div class="alert alert-warning" role="alert"><strong>Wallet already exists!</strong> If you wish to continue with this operation you first need to delete or rename your wallet file!</div>';
+ }
+ }
+ else if (menuItem === "recover") {
document.getElementById("menu").innerHTML = document.getElementById("decryption-phase-menu-frame").contentWindow.document.getElementById("recover-active").innerHTML;
+ if (walletExists === false) {
document.getElementById("content").innerHTML = document.getElementById("decryption-phase-content-frame").contentWindow.document.getElementById("recover-active").innerHTML;
}
+ else {
+ document.getElementById("content").innerHTML = '<div class="alert alert-warning" role="alert"><strong>Wallet already exists!</strong> If you wish to continue with this operation you first need to delete or rename your wallet file!</div>';
+ }
+ }
+ }
+
+ function httpGetWallet(path) {
+ var theUrl = "http://localhost:5000/api/v1/wallet/" + path;
+ var xmlHttp = new XMLHttpRequest();
+ xmlHttp.open("GET", theUrl, false); // false for synchronous request
+ xmlHttp.send(null);
+ return xmlHttp.responseText;
}
</script>
+
</body>
</html>
\ No newline at end of file

Implement decryption phase selection