mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Enhance rate limiting and mobile UI improvements for full mobile support!
Added new rate limiter policies "OneRequest" and "OneRequestPerIP" in `Program.cs`. Updated routing middleware and user authentication logic. Enhanced mobile navigation with a hamburger menu in multiple HTML files (`admin.html`, `user.html`, `archives.html`, `banned.html`, `error.html`, `login.html`, `paste.html`, `privatepaste.html`, `recent_pastes.html`). Introduced a notification system in `admin.html` and `login.html`. Updated CSS and JavaScript for better mobile responsiveness and user experience.
This commit is contained in:
@@ -30,14 +30,24 @@
|
||||
<h3 id="error-message"></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notifcations-wrapper" id="notifications">
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let isLoggingIn = false;
|
||||
|
||||
document.getElementById("signupForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var usernameContent = document.getElementById("usernameInput").value;
|
||||
var passwordContent = document.getElementById("passwordInput").value;
|
||||
|
||||
if (isLoggingIn) {
|
||||
createNotification("Please wait for the login to finish.");
|
||||
return;
|
||||
}
|
||||
isLoggingIn = true;
|
||||
|
||||
var requestUrl = "/api/accounts/create";
|
||||
fetch(requestUrl, {
|
||||
method: "POST",
|
||||
@@ -54,6 +64,7 @@
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
window.location.href = "/";
|
||||
isLoggingIn = false;
|
||||
}
|
||||
else if (result.error != null) {
|
||||
const errorElement = document.getElementById("error-message");
|
||||
@@ -63,6 +74,7 @@
|
||||
setTimeout(() => {
|
||||
errorElement.style.opacity = 0;
|
||||
}, 3000);
|
||||
isLoggingIn = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -76,6 +88,32 @@
|
||||
var characterCount = passwordContent.length;
|
||||
document.getElementById("passcharacterCount").innerText = `${characterCount}/50`;
|
||||
});
|
||||
function createNotification(message) {
|
||||
const notificationWrapper = document.getElementById('notifications');
|
||||
const notificationDiv = document.createElement('div');
|
||||
notificationDiv.classList.add('notification-div');
|
||||
notificationDiv.id = 'notification';
|
||||
|
||||
const notificationText = document.createElement('h2');
|
||||
notificationText.id = 'notification-text';
|
||||
notificationText.innerText = message;
|
||||
|
||||
notificationDiv.appendChild(notificationText);
|
||||
notificationWrapper.appendChild(notificationDiv);
|
||||
|
||||
notificationDiv.style.animation = 'none';
|
||||
notificationDiv.style.display = 'none';
|
||||
notificationDiv.style.display = 'flex';
|
||||
notificationDiv.style.animation = 'hoverup 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
|
||||
setTimeout(() => {
|
||||
notificationDiv.remove();
|
||||
}, 4900);
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
@@ -255,6 +293,69 @@
|
||||
#button-margin-top {
|
||||
margin-top: 30px;
|
||||
}
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes hoverdown {
|
||||
0% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(200%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.notification-div {
|
||||
display: flex;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
color: white;
|
||||
background-color: #181818;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.notifcations-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user