mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Add private pastes, user bans, and UI enhancements
Enhanced Program.cs with response caching, compression, CORS policy, and private paste handling. Refactored user ban logic and added expiration date handling. Improved admin.html with localization and overflow handling. Introduced PrivatePaste and Punishment classes. Enhanced Paste and User classes for private pastes and punishments. Updated initialization logic for punishedUsers table. Ensured salts are written back to config.json if generated. Enhanced user.html with ban/unban functionality and animations. Improved archives.html, dash.html, and index.html with new UI elements and styles. Added asynchronous content loading and notifications to paste.html. Introduced Encryption.cs for AES encryption and decryption. Created banned.html for displaying error messages. Added privatepaste.html with dynamic content, password protection, and user interactions.
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
let searchTimeout;
|
||||
@@ -220,7 +221,7 @@
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
background-color: #222222;
|
||||
max-height: 70vh;
|
||||
max-height: 30vh;
|
||||
}
|
||||
|
||||
.accounts-wrapper {
|
||||
@@ -267,6 +268,8 @@
|
||||
|
||||
.list-item {
|
||||
list-style: none;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
|
||||
+174
-21
@@ -31,7 +31,7 @@
|
||||
<div class="action-wrapper">
|
||||
<h2 style="text-align: center;">Actions</h2>
|
||||
<div class="button-wrapper">
|
||||
<a onclick="banAccount()" class="button">{typeban}</a>
|
||||
<a onclick="banorunban()" class="button">{typeban}</a>
|
||||
<a onclick="changePassword()" class="button">change password</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,6 +48,12 @@
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
<div class="input-div" id="ban-div" style="display: none;">
|
||||
<button onclick="banorunban()" class="exit-button">X</button>
|
||||
<input type="date" id="ban-date" placeholder="{typeban} date">
|
||||
<input type="text" id="ban-reason" placeholder="{typeban} reason">
|
||||
<button id="ban-button" onclick="banAccount()">{typeban}</button>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
@@ -65,29 +71,89 @@
|
||||
|
||||
creationdateElement.innerText = "Creation Date: " + localizeDateTime(parseInt(creationdateText));
|
||||
lastlogindateElement.innerText = "Last Login Date: " + localizeDateTime(parseInt(lastlogindateText));
|
||||
if ('{typeban}' == 'unban') {
|
||||
document.getElementById('ban-date').style.display = 'none';
|
||||
}
|
||||
});
|
||||
function banorunban() {
|
||||
const banDiv = document.getElementById('ban-div');
|
||||
console.log(banDiv.style.display);
|
||||
if (banDiv.style.display == 'none') {
|
||||
banDiv.style.animation = 'hoverup 1s';
|
||||
banDiv.style.display = 'flex';
|
||||
} else {
|
||||
banDiv.style.animation = 'hoverdown 1s';
|
||||
|
||||
setTimeout(() => {
|
||||
banDiv.style.transition = '200ms';
|
||||
banDiv.style.opacity = 0;
|
||||
|
||||
|
||||
}, 600);
|
||||
setTimeout(() => {
|
||||
banDiv.style.display = 'none';
|
||||
banDiv.style.opacity = 1;
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
console.log(banDiv.style.display);
|
||||
}
|
||||
function banAccount() {
|
||||
let reason = prompt('Enter the reason for {typeban}ning the account');
|
||||
fetch('/api/accounts/admin/{typeban}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
reason: `${reason}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
notification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
notification(`Failed to {typeban} ${result.error}`);
|
||||
}
|
||||
})
|
||||
let date = document.getElementById('ban-date').value;
|
||||
date = new Date(date).getTime() / 1000;
|
||||
let reason = document.getElementById('ban-reason').value;
|
||||
if (date == null || reason == null) {
|
||||
notification('Please fill out all fields');
|
||||
return;
|
||||
}
|
||||
if (date < new Date().getTime() / 1000) {
|
||||
notification('Please select a date in the future');
|
||||
return;
|
||||
}
|
||||
if ('{typeban}' == 'unban') {
|
||||
fetch('/api/accounts/admin/{typeban}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
reason: `${reason}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
notification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
notification(`Failed to {typeban} ${result.error}`);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
fetch('/api/accounts/admin/{typeban}', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uuid: '{uuid}',
|
||||
expiration: `${date}`,
|
||||
reason: `${reason}`
|
||||
})
|
||||
|
||||
}).then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.message != null) {
|
||||
notification(`${result.message} for ${reason}`);
|
||||
} else {
|
||||
notification(`Failed to {typeban} ${result.error}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(date);
|
||||
banorunban();
|
||||
}
|
||||
function changePassword() {
|
||||
let password = prompt('Enter the new password');
|
||||
@@ -131,16 +197,103 @@
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.exit-button {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #222222 2px solid;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
cursor: pointer;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
width: fit-content;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
#ban-div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.input-div {
|
||||
z-index: 2;
|
||||
position: fixed;
|
||||
background-color: #121212;
|
||||
border-radius: 10px;
|
||||
width: fit-content;
|
||||
max-width: 50%;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: fit-content;
|
||||
padding: 60px;
|
||||
max-height: 50%;
|
||||
border: #181818 3px solid;
|
||||
}
|
||||
|
||||
input {
|
||||
transition: 300ms;
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
transition: 300ms;
|
||||
outline: none;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
#ban-button {
|
||||
transition: 300ms;
|
||||
width: 80%;
|
||||
max-width: 80%;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
#ban-button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
|
||||
@keyframes hoverup {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
25% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<input type="text" placeholder="search" class="text-input" oninput="search()">
|
||||
<div class="pastes-wrapper">
|
||||
{pastes}
|
||||
<a title="" href="/yZXC7EmRpexG"><li>Untitled 46 2.1 hrs ago 488.28KB</li></a>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a class="arrow-button" href="/archive?page={backpagenum}"><</a>
|
||||
@@ -144,21 +145,14 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
max-height: 70vh;
|
||||
}
|
||||
|
||||
.pastes-wrapper a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
li {
|
||||
transition: 300ms;
|
||||
@@ -211,12 +205,22 @@
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.pastes-wrapper a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.text-input {
|
||||
transition: border 300ms;
|
||||
width: 90.62%;
|
||||
width: calc(100% - 44px);
|
||||
height: 1.2rem;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
margin-left: 12px;
|
||||
border-radius: 5px;
|
||||
border: #222222 2px solid;
|
||||
background-color: #222222;
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
||||
<title>Error {code}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="error-container">
|
||||
<h1>Error {code}</h1>
|
||||
<h2>{message}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const dateElement = document.getElementById('unix-date');
|
||||
const time = localizeDateTime(parseInt(dateElement.innerText.trim()));
|
||||
dateElement.innerText = time;
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
body{
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
.container-wrapper{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
.error-container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
.button{
|
||||
text-decoration: none;
|
||||
transition: 300ms;
|
||||
width: fit-content;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: #2a2a2a00 2px solid;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.button:hover{
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
.nav-div{
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
.nav-div a{
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
.nav-div a:hover{
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -80,20 +80,21 @@ body{
|
||||
border-radius: 5px;
|
||||
width: 80%;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
height: fit-content;
|
||||
height: 50%;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
.idek-wrapper{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.account-info{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #222222;
|
||||
width: 48%;
|
||||
height: calc(100% - 40px);
|
||||
padding: 20px;
|
||||
margin-right: 5px;
|
||||
border-radius: 5px;
|
||||
@@ -105,6 +106,7 @@ body{
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 48%;
|
||||
height: calc(100% - 40px);
|
||||
margin-left: 5px;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
|
||||
+112
-5
@@ -23,41 +23,148 @@
|
||||
<input type="text" id="pasteTitle" class="textinput" name="pasteTitle" maxlength="500">
|
||||
<label for="pasteContent" class="label">Content</label>
|
||||
<textarea id="pasteContent" class="textarea" name="pasteContent" required maxlength="500000"></textarea>
|
||||
<select for="pasteVisibility" id="pasteVisibility" class="textinput" name="pasteVisibility" required>
|
||||
<option value="Public">Public</option>
|
||||
<option value="Unlisted">Unlisted</option>
|
||||
<option value="Private">Private</option>
|
||||
</select>
|
||||
<label for="pastePassword" class="label" id="pastePasswordLabel">Paste Password</label>
|
||||
<input type="password" id="pastePassword" class="textinput" name="pastePassword" maxlength="500">
|
||||
<button type="submit" class="button">Create</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById("pasteVisibility").value = "Public";
|
||||
});
|
||||
document.getElementById("createForm").addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var textAreaContent = document.getElementById("pasteContent").value;
|
||||
var textTitleContent = document.getElementById("pasteTitle").value;
|
||||
var textVisibilityContent = document.getElementById("pasteVisibility").value;
|
||||
|
||||
var requestUrl = "/api/pastes/create";
|
||||
var fetchBody = {
|
||||
title: textTitleContent,
|
||||
content: textAreaContent,
|
||||
visibility: textVisibilityContent
|
||||
};
|
||||
if (textVisibilityContent == "Private") {
|
||||
fetchBody.password = document.getElementById("pastePassword").value;
|
||||
}
|
||||
fetch(requestUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title: textTitleContent,
|
||||
content: textAreaContent
|
||||
})
|
||||
body: JSON.stringify(fetchBody)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.pasteId != null) {
|
||||
window.location.href = `/${result.pasteId}`;
|
||||
}else if (result.error != null) {
|
||||
notification(result.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
document.getElementById("pasteVisibility").addEventListener("change", function (event) {
|
||||
var visibility = document.getElementById("pasteVisibility").value;
|
||||
if (visibility == "Private") {
|
||||
document.getElementById("pastePassword").style.display = "block";
|
||||
document.getElementById("pastePasswordLabel").style.display = "block";
|
||||
} else {
|
||||
document.getElementById("pastePassword").style.display = "none";
|
||||
document.getElementById("pastePasswordLabel").style.display = "none";
|
||||
}
|
||||
});
|
||||
function notification(message) {
|
||||
const notification = document.getElementById('notification');
|
||||
const notificationText = document.getElementById('notification-text');
|
||||
notificationText.innerText = message;
|
||||
notification.style.animation = 'none';
|
||||
notification.style.display = 'none';
|
||||
notification.style.display = 'flex';
|
||||
notification.style.animation = 'hoverup 1s';
|
||||
setTimeout(() => {
|
||||
|
||||
notification.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 4900);
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
@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%);
|
||||
}
|
||||
|
||||
}
|
||||
#pastePassword{
|
||||
display: none;
|
||||
}
|
||||
#pastePasswordLabel{
|
||||
display: none;
|
||||
}
|
||||
.notification-div {
|
||||
position: fixed;
|
||||
display: none;
|
||||
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;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h3 class="uploader-text">{username} <a id="creationdate">{creationdate}</a> {pastesize}</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p>{content}</p>
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a href="/raw/{pasteid}">
|
||||
@@ -41,8 +41,29 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
const textElement = document.getElementById('text');
|
||||
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
textElement.innerText = "Loading...";
|
||||
fetch(`/raw/{pasteid}`)
|
||||
.then(response => response.body)
|
||||
.then(stream => {
|
||||
const reader = stream.getReader();
|
||||
let text = '';
|
||||
|
||||
const read = () => {
|
||||
return reader.read().then(({ done, value }) => {
|
||||
if (done) {
|
||||
textElement.innerText = text;
|
||||
return;
|
||||
}
|
||||
text += new TextDecoder().decode(value);
|
||||
return read();
|
||||
});
|
||||
};
|
||||
|
||||
return read();
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById("copy-button").addEventListener("click", function () {
|
||||
|
||||
@@ -0,0 +1,367 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{pastetitle}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="nav-div">
|
||||
<a href="/">home</a>
|
||||
<a href="/pastes">recent pastes</a>
|
||||
<a href="/archive">archive</a>
|
||||
{html}
|
||||
</div>
|
||||
<div class="container-wrapper">
|
||||
<div class="paste-container">
|
||||
<h1 id="paste-title" title="{pastetitleattribute}">{pastetitle}</h1>
|
||||
<h3 class="uploader-text">{username} <a id="creationdate">{creationdate}</a> {pastesize}</h3>
|
||||
<div class="paste-wrapper">
|
||||
<p id="text"></p>
|
||||
</div>
|
||||
<div class="buttons-wrapper">
|
||||
<a href="" id="view-raw-a">
|
||||
<button id="view-raw-button" class="button">view raw</button>
|
||||
</a>
|
||||
<button id="copy-button" class="button">copy</button>
|
||||
<button id="download-button" class="button">download</button>
|
||||
{deletebutton}
|
||||
</div>
|
||||
</div>
|
||||
<div class="passwordDiv">
|
||||
<div class="inputDiv">
|
||||
<h1>This paste is password protected</h1>
|
||||
<input type="password" id="password" class="textinput" name="password" maxlength="500" placeholder="password">
|
||||
<button id="submitPassword" class="button-input">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notification-div" id="notification">
|
||||
<h2 id="notification-text"></h2>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
document.getElementById("submitPassword").addEventListener("click", function () {
|
||||
var password = document.getElementById("password").value;
|
||||
fetch(`/api/pastes/password/{pasteid}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(obj => {
|
||||
const result = JSON.parse(obj);
|
||||
if (result.content != null){
|
||||
const textElement = document.getElementById('text');
|
||||
textElement.innerText = result.content;
|
||||
document.querySelector(".passwordDiv").style.display = "none";
|
||||
const viewRawButton = document.getElementById('view-raw-a');
|
||||
viewRawButton.href = `/raw/{pasteid}?password=${password}`;
|
||||
}
|
||||
else {
|
||||
notification(`Error: ${result.error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
function localizeDateTime(unixTimestamp) {
|
||||
const date = new Date(unixTimestamp * 1000);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const creationdateElement = document.getElementById('creationdate');
|
||||
const creationdateText = creationdateElement.innerText.trim();
|
||||
|
||||
creationdateElement.innerText = localizeDateTime(parseInt(creationdateText));
|
||||
});
|
||||
|
||||
document.getElementById("copy-button").addEventListener("click", function () {
|
||||
navigator.clipboard.writeText(document.querySelector(".paste-wrapper").innerText);
|
||||
});
|
||||
document.getElementById("download-button").addEventListener("click", function () {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(document.querySelector(".paste-wrapper").innerText));
|
||||
element.setAttribute('download', '{pasteid}.txt');
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
element.click();
|
||||
document.body.removeChild(element);
|
||||
});
|
||||
{deletescript}
|
||||
function notification(message) {
|
||||
const notification = document.getElementById('notification');
|
||||
const notificationText = document.getElementById('notification-text');
|
||||
notificationText.innerText = message;
|
||||
notification.style.animation = 'none';
|
||||
notification.style.display = 'none';
|
||||
notification.style.display = 'flex';
|
||||
notification.style.animation = 'hoverup 1s';
|
||||
setTimeout(() => {
|
||||
|
||||
notification.style.animation = 'hoverdown 1s';
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 4900);
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</html>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
body {
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
.container-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 98.7vh;
|
||||
}
|
||||
.button-input {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: 2px solid #33333300;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.button-input:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
.passwordDiv {
|
||||
z-index: 100;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
backdrop-filter: blur(8px);
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.inputDiv {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
color: white;
|
||||
}
|
||||
.textinput {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
border-radius: 5px;
|
||||
border: 2px solid #222222;
|
||||
background-color: #181818;
|
||||
padding: 10px;
|
||||
font-size: 1.05rem;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
color: white;
|
||||
}
|
||||
.textinput:focus {
|
||||
outline: none;
|
||||
border: 2px solid #333333;
|
||||
}
|
||||
|
||||
.paste-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 80%;
|
||||
padding: 20px;
|
||||
background-color: #181818;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
max-height: 80vh;
|
||||
min-height: 20%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.paste-wrapper {
|
||||
width: 95%;
|
||||
height: fit-content;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
background-color: #1d1d1d;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
text-wrap: wrap;
|
||||
font-weight: 500;
|
||||
max-height: 80%;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
}
|
||||
|
||||
.buttons-wrapper {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.buttons-wrapper a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
transition: 300ms;
|
||||
background-color: #222222;
|
||||
color: white;
|
||||
border: 2px solid #33333300;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
padding: 10px;
|
||||
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
|
||||
font-weight: 625;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: 2px solid #3a3a3a;
|
||||
}
|
||||
|
||||
.uploader-text {
|
||||
margin-top: -1.2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.user-a {
|
||||
color: rgb(190, 190, 190);
|
||||
text-decoration: none;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.nav-div {
|
||||
top: 0;
|
||||
margin-top: 10px;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
background-color: #181818;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: fit-content;
|
||||
overflow-y: auto;
|
||||
border: #222222 2px solid;
|
||||
z-index: 102;
|
||||
}
|
||||
|
||||
.nav-div a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #222222;
|
||||
transition: 300ms;
|
||||
border: #2a2a2a00 2px solid;
|
||||
}
|
||||
|
||||
.nav-div a:hover {
|
||||
transition: 300ms;
|
||||
background-color: #333333;
|
||||
border: #3a3a3a 2px solid;
|
||||
}
|
||||
@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 {
|
||||
position: fixed;
|
||||
display: none;
|
||||
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;
|
||||
z-index: 101;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user