Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 54 additions & 10 deletions src/main/resources/templates/settings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.84.0">
<title>🧙‍♂️ Arcana on Solana</title>

<link rel="canonical" href="https://getbootstrap.com/docs/5.0/examples/navbar-fixed/">


<!-- Bootstrap core CSS -->
<link href="/static/bootstrap.min.css" rel="stylesheet">

Expand All @@ -28,12 +23,20 @@
font-size: 3.5rem;
}
}

.toast-container {
position: fixed;
bottom: 0;
right: 0;
z-index: 9999;
}
</style>

</head>

<!-- Custom styles for this template -->
<link href="/static/navbar-top-fixed.css" rel="stylesheet">
</head>

<body>

<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
Expand Down Expand Up @@ -69,7 +72,7 @@
<div class="bg-light p-5 rounded">
<h2>Settings</h2>
<div class="input-group mb-3">
<form class="form-signin" method="POST" action="/settings">
<form class="form-signin" method="POST" action="/settings" autocomplete="off" autocapitalize="none">
<div class="input-group-prepend">
<span class="input-group-text" id="rpc-server-text">RPC Server</span>
</div>
Expand All @@ -92,17 +95,58 @@
</div>
<hr>
<div class="input-group mb-3">
<form method="POST" action="/privateKeyPost">
<form method="POST" action="/privateKeyPost" autocomplete="off" autocapitalize="none">
Private Key (Base58): <input type="text" name="privateKey"/><br/><br/>
<input type="submit" class="btn btn-primary btn-block" value="Upload Private Key (Base58)"/>
</form>
</div>
</div>
</main>


<script src="/static/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const rpcForm = document.querySelector("form[action='/settings']");
const privateKeyForm = document.querySelector("form[action='/privateKeyPost']");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do the same with the privateKeyUpload (upload file) selector.

const toastContainer = document.querySelector('.toast-container');

const showToastAndSubmit = function(event, form) {
event.preventDefault();
const toastElement = document.createElement('div');
toastElement.className = 'toast align-items-center border-0';
toastElement.setAttribute('role', 'alert');
toastElement.setAttribute('aria-live', 'assertive');
toastElement.setAttribute('aria-atomic', 'true');
toastElement.innerHTML = `
<div class="d-flex">
<div class="toast-body">
Submitting details...
</div>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>`;
toastContainer.appendChild(toastElement);
const toast = new bootstrap.Toast(toastElement);
toast.show();
// Manually submit the form after a short delay to allow the toast to show
setTimeout(() => {
form.submit();
}, 2000); // 2 seconds
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lower this to maybe 500, or remove entirely.

};

rpcForm.addEventListener("submit", function(event) {
showToastAndSubmit(event, rpcForm);
});
privateKeyForm.addEventListener("submit", function(event) {
showToastAndSubmit(event, privateKeyForm);
});
});
</script>

<div class="toast-container">
<!-- Toasts will be dynamically appended here -->
</div>

</body>
</html>
</html>