~kline/torgateway

93e76c8cfa806eb1e0102b7a9033b10c13fef247 — Gareth Pulham 1 year, 17 days ago 1a6cfbf
Add error/success messaging
2 files changed, 15 insertions(+), 1 deletions(-)

M static/main.js
M templates/index.html
M static/main.js => static/main.js +13 -1
@@ 9,6 9,7 @@ const submit = document.querySelector("#submit");
// Start/status
const resultbox = document.querySelector("#progress");
const ignition = document.querySelector("#ignition");
const message = document.querySelector("#message");

let bgworker = null;



@@ 16,7 17,18 @@ function requestAccount() {
    let formData = new FormData(account);
    fetch("/register", {method: "POST", body: formData})
        .then(response => response.json())
        .then(data => console.log(data));
        .then(data => {
            console.log(data);
            if (data["status"] == "success") {
                console.log("success!");
                message.style.background = "lightgreen";
                message.textContent = "Your account, "+data["username"]+", has been registered.";
            } else {
                console.log("failure!");
                message.style.background = "pink";
                message.textContent = "Error: "+data["reason"];
            }
        });
}

function checkSubmittable() {

M templates/index.html => templates/index.html +2 -0
@@ 4,6 4,7 @@
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <style> body { margin: 0 auto; max-width: 60rem; padding: 0 1rem; } </style>

        <title>Tor Registration Service</title>
    </head>


@@ 33,6 34,7 @@
          <br />
          <input type="button" id="submit" value="Not available yet" />
        </form>
        <p id="message"></p>
        <script src="static/main.js"></script>
    </body>
</html>