Split code into classes to make the codebase look cleaner

Added a new favicon/icon
Add more checks before uploading a paste, changed alert to use the showNotification function
Added password modal for private pastes instead of using alert
Fix a paste page navigation in dashboard
Improve auth css
This commit is contained in:
whoswhip
2025-05-23 18:54:29 -04:00
parent 2126c3a078
commit 73743399f1
17 changed files with 1027 additions and 491 deletions
+10 -1
View File
@@ -3,6 +3,7 @@
justify-content: center;
align-items: center;
min-height: 100vh;
min-width: 100%;
padding: 20px;
background-color: var(--neutral-950);
}
@@ -13,7 +14,7 @@
padding: 30px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 450px;
max-width: 650px;
border: 1px solid var(--neutral-800);
}
@@ -131,9 +132,17 @@
}
@media (max-width: 480px) {
.auth-container {
padding: 0px;
}
.auth-form-container {
padding: 20px;
max-width: 100%;
border-radius: 0;
}
.auth-title {
font-size: 1.6rem;
+61 -35
View File
@@ -14,7 +14,8 @@ body {
gap: 25px;
}
.account-info, .paste-list {
.account-info,
.paste-list {
width: 48%;
border-radius: 8px;
padding: 25px;
@@ -34,12 +35,14 @@ body {
flex-direction: column;
}
.account-info:hover, .paste-list:hover {
.account-info:hover,
.paste-list:hover {
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
border-color: var(--neutral-700);
}
.account-info h1, .paste-list h1 {
.account-info h1,
.paste-list h1 {
margin-bottom: 25px;
color: var(--neutral-100);
text-align: center;
@@ -126,6 +129,12 @@ body {
color: var(--neutral-300);
font-size: 0.9rem;
text-align: center;
overflow: hidden !important;
text-overflow: clip !important;
white-space: nowrap !important;
max-width: 80px;
text-align: left;
margin-right: -70px !important;
}
#paste-syntax {
@@ -134,20 +143,7 @@ body {
text-align: right;
}
@media (max-width: 768px) {
#pastes li a {
grid-template-columns: 3fr 2fr;
}
#paste-syntax {
display: none;
}
}
@media (max-width: 576px) {
#pastes li a {
padding: 0.7rem 0.8rem;
}
}
.paste-actions {
display: flex;
@@ -219,8 +215,9 @@ body {
.main-container {
padding: 15px;
}
.account-info, .paste-list {
.account-info,
.paste-list {
padding: 20px;
}
}
@@ -230,8 +227,9 @@ body {
flex-direction: column;
gap: 20px;
}
.account-info, .paste-list {
.account-info,
.paste-list {
width: 100%;
}
}
@@ -240,24 +238,28 @@ body {
.main-container {
padding: 10px;
}
.account-info, .paste-list {
.account-info,
.paste-list {
padding: 15px;
}
.account-info h1, .paste-list h1 {
.account-info h1,
.paste-list h1 {
font-size: 1.5rem;
}
#pastes li {
flex-direction: column;
align-items: flex-start;
grid-template-columns: 1fr;
}
#pastes li span {
margin-top: 5px;
font-size: 0.8rem;
}
}
.logout-modal-overlay {
@@ -266,31 +268,35 @@ body {
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0,0,0,0.5);
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 2000;
}
.logout-modal-box {
background: var(--neutral-900);
color: var(--neutral-100);
padding: 2rem 2.5rem;
border-radius: 10px;
box-shadow: 0 8px 32px rgba(0,0,0,0.25);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
text-align: center;
min-width: 300px;
max-width: 90vw;
}
.logout-modal-box h2 {
margin-bottom: 1rem;
font-size: 1.4rem;
color: var(--neutral-50);
}
.logout-modal-box p {
margin-bottom: 2rem;
color: var(--neutral-300);
}
.logout-modal-box button {
margin: 0 0.5rem;
padding: 0.7rem 1.5rem;
@@ -301,17 +307,21 @@ body {
font-size: 1rem;
transition: background 0.2s, color 0.2s;
}
#confirm-logout {
background: #e74c3c;
color: #fff;
}
#confirm-logout:hover {
background: #c0392b;
}
#cancel-logout {
background: var(--neutral-700);
color: #fff;
}
#cancel-logout:hover {
background: var(--neutral-600);
}
@@ -327,15 +337,17 @@ body {
font-weight: 500;
cursor: pointer;
transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
letter-spacing: 0.5px;
}
#logout-button:hover {
background-color: var(--neutral-600);
color: var(--neutral-10);
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(0,0,0,0.13);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13);
}
#logout-button:active {
background-color: var(--neutral-800);
color: var(--neutral-200);
@@ -353,16 +365,18 @@ body {
font-weight: 500;
cursor: pointer;
transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
letter-spacing: 0.5px;
margin-top: 10px;
}
#delete-account-button:hover {
background-color: #c0392b;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(0,0,0,0.13);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.13);
}
#delete-account-button:active {
background-color: #a93226;
color: #fff;
@@ -376,31 +390,35 @@ body {
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0,0,0,0.5);
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 2100;
}
.delete-modal-box {
background: var(--neutral-900);
color: var(--neutral-100);
padding: 2rem 2.5rem;
border-radius: 10px;
box-shadow: 0 8px 32px rgba(0,0,0,0.25);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
text-align: center;
min-width: 320px;
max-width: 95vw;
}
.delete-modal-box h2 {
margin-bottom: 1rem;
font-size: 1.4rem;
color: #e74c3c;
}
.delete-modal-box p {
margin-bottom: 1.2rem;
color: var(--neutral-300);
}
.delete-modal-box input {
margin-bottom: 0.7rem;
width: 90%;
@@ -413,9 +431,11 @@ body {
outline: none;
transition: border 0.2s;
}
.delete-modal-box input:focus {
border: 1.5px solid #e74c3c;
}
.delete-modal-box button {
margin: 0 0.5rem;
padding: 0.7rem 1.5rem;
@@ -426,13 +446,16 @@ body {
font-size: 1rem;
transition: background 0.2s, color 0.2s;
}
#confirm-delete-account {
background: #e74c3c;
color: #fff;
}
#confirm-delete-account:hover {
background: #c0392b;
}
#confirm-delete-account:disabled {
background: var(--neutral-800);
color: var(--neutral-500);
@@ -441,15 +464,18 @@ body {
box-shadow: none;
transform: none;
}
#cancel-delete-account {
background: var(--neutral-700);
color: #fff;
}
#cancel-delete-account:hover {
background: var(--neutral-600);
}
#delete-error {
color: #e74c3c;
font-size: 1rem;
margin-top: 1rem;
}
}
+200 -6
View File
@@ -8,12 +8,24 @@
}
#blur {
z-index: 999;
z-index: 50;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: auto;
}
#notification-container {
position: fixed;
z-index: 10001;
top: 24px;
left: 0;
right: 0;
margin: 0 auto;
width: fit-content;
pointer-events: none;
}
.paste-information {
@@ -55,7 +67,7 @@
#paste-content {
padding: 10px;
max-width: 100%;
max-height: 20vh;
max-height: 50vh;
overflow-y: scroll;
overflow-wrap: break-word;
word-wrap: break-word;
@@ -103,6 +115,7 @@ button:active {
.hljs-ln-numbers {
border-right: 1px solid var(--neutral-700);
padding-right: 8px !important;
padding-left: 8px !important;
text-align: center;
user-select: none;
}
@@ -122,9 +135,10 @@ pre code.hljs {
code.hljs {
padding: 3px 5px
}
.hljs {
color: #c9d1d9;
background: var(--neutral-900);
background: #1e1e1e;
}
.hljs-doctag,
@@ -225,11 +239,15 @@ code.hljs {
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Minimal, clean style for paste information card */
.paste-information-card {
display: flex;
flex-wrap: wrap;
@@ -244,6 +262,7 @@ code.hljs {
border-bottom: 1px solid var(--neutral-700);
min-width: 0;
}
.paste-info-item {
display: flex;
align-items: center;
@@ -256,20 +275,24 @@ code.hljs {
padding: 0 6px;
transition: none;
}
.info-icon {
font-size: 1em;
opacity: 0.7;
margin-right: 2px;
}
#author-link {
color: var(--neutral-100);
text-decoration: underline dotted;
font-weight: 400;
transition: color 0.2s;
}
#author-link:hover {
color: #4ea1f7;
}
.paste-header h1#paste-title {
font-size: 1.5rem;
font-weight: 600;
@@ -286,18 +309,189 @@ code.hljs {
vertical-align: middle;
opacity: 0.7;
}
.syntax-icon {
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 7l-4 3 4 3M13 7l4 3-4 3"/></svg>') no-repeat center/1em 1em;
}
.date-icon {
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="8"/><path d="M10 6v4l2 2"/></svg>') no-repeat center/1em 1em;
}
.size-icon {
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="3" width="12" height="14" rx="2"/><path d="M10 7v5m0 0l-2-2m2 2l2-2"/></svg>') no-repeat center/1em 1em;
}
.views-icon {
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><ellipse cx="10" cy="10" rx="8" ry="5"/><circle cx="10" cy="10" r="2.5"/></svg>') no-repeat center/1em 1em;
}
.author-icon {
background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%23aaa" stroke-width="2" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="7.5" r="3.5"/><path d="M3 17c0-3.3 3.1-6 7-6s7 2.7 7 6"/></svg>') no-repeat center/1em 1em;
}
#password-modal-bg {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
z-index: 101;
}
#password-modal {
background: var(--neutral-900);
padding: 2em 2.5em 1.5em 2.5em;
border-radius: 12px;
box-shadow: 0 4px 32px #000a;
display: flex;
flex-direction: column;
align-items: center;
min-width: 320px;
border: 1px solid var(--neutral-800);
font-family: inherit;
color: white;
}
#password-modal .modal-title {
font-weight: bold;
font-size: 1.2em;
margin-bottom: 0.5em;
letter-spacing: 0.5px;
color: white
}
#password-modal label {
margin-bottom: 1em;
color: white;
font-size: 1em;
text-align: center;
}
#password-modal input[type="password"] {
margin-bottom: 1em;
padding: 0.7em 1em;
width: 100%;
border-radius: 6px;
border: 1px solid var(--neutral-900);
background: var(--neutral-800);
color: white;
font-size: 1em;
outline: none;
box-sizing: border-box;
transition: border-color 0.2s;
}
#password-modal input[type="password"]:focus {
border-color: var(--neutral-700);
}
#password-modal .modal-btn-row {
display: flex;
justify-content: space-between;
width: 100%;
gap: 0.5em;
}
#password-modal button {
padding: 0.5em 1.5em;
border-radius: 4px;
border: none;
font-weight: bold;
font-size: 1em;
cursor: pointer;
transition: background 0.2s;
}
#password-modal button:first-child {
background: var(--neutral-700);
border: 1px solid var(--neutral-600);
color: #fff;
}
#password-modal button:first-child:hover {
background: var(--neutral-600);
border: 1px solid var(--neutral-500);
}
#password-modal button:last-child {
background: var(--neutral-700);
border: 1px solid var(--neutral-600);
color: #fff;
}
#password-modal button:last-child:hover {
background: var(--neutral-600);
border: 1px solid var(--neutral-500);
}
.has-true-size-tooltip {
position: relative;
cursor: pointer;
}
.true-size-tooltip {
position: absolute;
left: 50%;
bottom: 120%;
transform: translateX(-50%);
background: var(--neutral-900, #23272e);
color: var(--neutral-50, #fff);
padding: 6px 14px;
border-radius: 6px;
font-size: 0.95em;
white-space: nowrap;
box-shadow: 0 2px 8px #0007;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s;
z-index: 200;
border: 1px solid var(--neutral-700, #444);
}
.has-true-size-tooltip:hover .true-size-tooltip {
opacity: 1;
}
@media (max-width: 768px) {
.main-container {
max-height: 100% !important;
}
#password-modal-bg {
padding: 1em;
}
#password-modal {
padding: 1.5em 2em 1em 2em;
min-width: auto;
}
#paste-content {
word-break: break-all;
}
}
@media (max-width: 480px) {
.paste-actions {
display: flex;
justify-content: space-between;
}
.paste-actions button {
width: 30%;
margin: 0;
margin-right: 2.5px;
margin-left: 2.5px;
}
.paste-information-card {
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
}
+40 -3
View File
@@ -1,38 +1,45 @@
body, html {
body,
html {
height: 100%;
min-height: 100%;
box-sizing: border-box;
}
.main-container {
max-width: 600px;
margin: 2.5rem auto;
padding: 1.5rem 1.5rem 2.5rem 1.5rem;
background-color: var(--neutral-900);
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0,0,0,0.18);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
width: 100%;
display: flex;
flex-direction: column;
align-items: stretch;
}
.user-header {
text-align: center;
margin-bottom: 2rem;
}
.user-header h1 {
font-size: 2.1rem;
font-weight: 700;
color: var(--neutral-50);
margin: 0 0 0.2rem 0;
}
.user-header p {
color: var(--neutral-400);
font-size: 1rem;
margin: 0;
}
.user-pastes-section {
margin-top: 0;
}
.archive-information {
display: grid;
grid-template-columns: 2fr 1fr 1fr;
@@ -46,9 +53,11 @@ body, html {
border-bottom: 2px solid var(--neutral-700);
width: 100%;
}
.archive-information p {
margin: 0;
}
.archive-list {
list-style-type: none;
margin: 0;
@@ -60,24 +69,30 @@ body, html {
scrollbar-width: thin;
scrollbar-color: var(--neutral-700) var(--neutral-900);
}
.archive-list::-webkit-scrollbar {
width: 8px;
}
.archive-list::-webkit-scrollbar-track {
background: var(--neutral-900);
border-radius: 6px;
}
.archive-list::-webkit-scrollbar-thumb {
background-color: var(--neutral-700);
border-radius: 6px;
}
.archive-list li {
margin: 0.75rem 0;
transition: transform 0.2s ease;
}
.archive-list li:hover {
transform: translateY(-2px);
}
.archive-list li a {
display: grid;
grid-template-columns: 2fr 1fr 1fr;
@@ -91,41 +106,50 @@ body, html {
border: 1px solid var(--neutral-700);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.archive-list li a:hover {
background-color: var(--neutral-750);
border-color: var(--neutral-600);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.archive-list li a p {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.archive-list li a p:nth-child(2) {
padding-left: 1rem;
text-align: center;
}
.archive-list li a p:nth-child(3){
.archive-list li a p:nth-child(3) {
text-align: right;
}
#archive-title {
font-weight: 500;
color: var(--neutral-100);
}
#archive-date {
color: var(--neutral-300);
font-size: 0.9rem;
text-align: center;
}
#archive-syntax {
color: var(--neutral-300);
font-size: 0.9rem;
text-align: right;
}
.user-pastes-throbber {
margin: 1.5rem auto;
}
.pastes-actions {
display: flex;
justify-content: center;
@@ -138,11 +162,13 @@ body, html {
opacity: 0.5;
cursor: not-allowed;
}
.pastes-actions span {
color: var(--neutral-300);
font-size: 1.1rem;
font-weight: 500;
}
@media (max-width: 768px) {
.main-container {
max-width: 98vw;
@@ -150,29 +176,40 @@ body, html {
padding: 0.5rem;
border-radius: 0;
}
.archive-list li a p:last-child {
display: none;
}
.archive-information,
.archive-list li a {
grid-template-columns: 3fr 2fr;
}
#archive-syntax {
display: none;
}
.archive-information p:last-child {
display: none;
}
}
@media (max-width: 480px) {
.main-container {
padding: 1rem;
margin: 1rem;
}
.user-header h1 {
font-size: 1.5rem;
}
.archive-list {
max-height: 60vh;
}
}
#next-button-svg {
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/></svg>');
color: white;
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

+1 -1
View File
@@ -20,7 +20,7 @@
<form class="create-form" id="create-form">
<input type="text" name="title" id="title" placeholder="Title" maxlength="500">
<textarea name="content" id="content" placeholder="Content"></textarea>
<label id="syntax-label" style="">Syntax Highlighting -</label>
<label id="syntax-label">Syntax Highlighting -</label>
<select name="syntax" id="syntax">
<option value="none">None</option>
<option value="AutoHotkey">AutoHotkey</option>
+23 -1
View File
@@ -1,6 +1,9 @@
const siteInfo = [];
document.addEventListener("DOMContentLoaded", async function () {
var visibility = document.getElementById("visibility");
visibility.value = "0";
getSiteInfo();
});
@@ -13,11 +16,20 @@ document.getElementById("create-form").addEventListener("submit", async function
var password = document.getElementById("password").value;
var syntax = document.getElementById("syntax").value;
if (content.length > siteInfo.maxFileSize) {
showNotification("Content exceeds maximum size.", "error");
return;
}
if (content.length === 0) {
showNotification("Content cannot be empty.", "error");
return;
}
if (visibility === "2" && password !== "" && password.length >= 6) {
content = await encryptAES(content, password);
}
else if (visibility === "2") {
alert("Password must be at least 6 characters long");
showNotification("Password must be at least 6 characters long.", "error");
return;
}
@@ -42,6 +54,16 @@ function changeVisibility() {
}
}
function getSiteInfo() {
fetch("/api/site/info")
.then(response => response.json())
.then(data => {
siteInfo = data.info;
var content = document.getElementById("content")
content.setAttribute("maxlength", siteInfo.maxFileSize);
});
}
async function encryptAES(content, password) {
const enc = new TextEncoder();
const keyMaterial = await window.crypto.subtle.importKey(
+2 -1
View File
@@ -66,6 +66,7 @@ const navbarHTML = `
}
.nav-link {
background-color: #171717;
color: rgba(255, 255, 255, 0.85);
text-decoration: none;
font-size: 1.1rem;
@@ -217,7 +218,7 @@ function showNotification(message, type = 'info', duration = 3000) {
position: fixed;
bottom: 32px;
right: 32px;
z-index: 2000;
z-index: 1000;
display: flex;
flex-direction: column;
align-items: flex-end;
+103 -7
View File
@@ -14,14 +14,99 @@ document.addEventListener("DOMContentLoaded", async function () {
const [content, info] = await Promise.all([contentPromise, infoPromise]);
const paste = info.paste;
function showPasswordModal(errorMsg = "") {
return new Promise((resolve, reject) => {
const oldModal = document.getElementById("password-modal-bg");
if (oldModal) oldModal.remove();
const modalBg = document.createElement("div");
modalBg.id = "password-modal-bg";
const modal = document.createElement("div");
modal.id = "password-modal";
const title = document.createElement("div");
title.innerText = "Private Paste";
title.className = "modal-title";
const label = document.createElement("label");
label.innerText = "Enter the password to view this paste:";
label.htmlFor = "password-input";
const input = document.createElement("input");
input.type = "password";
input.id = "password-input";
input.autocomplete = "current-password";
if (errorMsg) {
showNotification(errorMsg, "error", 3000);
}
const btnRow = document.createElement("div");
btnRow.className = "modal-btn-row";
const okBtn = document.createElement("button");
okBtn.innerText = "Unlock";
const cancelBtn = document.createElement("button");
cancelBtn.innerText = "Cancel";
btnRow.appendChild(cancelBtn);
btnRow.appendChild(okBtn);
modal.appendChild(title);
modal.appendChild(label);
modal.appendChild(input);
modal.appendChild(btnRow);
modalBg.appendChild(modal);
document.body.appendChild(modalBg);
input.focus();
function cleanup() {
if (modalBg.parentNode) modalBg.parentNode.removeChild(modalBg);
}
okBtn.onclick = () => {
resolve(input.value);
};
cancelBtn.onclick = () => {
cleanup();
reject(new Error("User cancelled"));
};
input.addEventListener("keydown", e => {
if (e.key === "Enter") {
okBtn.click();
} else if (e.key === "Escape") {
cancelBtn.click();
}
});
modalBg.addEventListener("click", e => {
if (e.target === modalBg) {
cancelBtn.click();
}
});
});
}
if (paste.visibility === 2) {
const password = prompt("Enter the password");
try {
const decrypted = await decryptAES(content, password);
blur2.dataset.decrypted = "true";
addContent(decrypted, paste.syntax);
} catch (error) {
alert("Failed to decrypt, invalid password, or invalid data.");
let success = false;
let lastError = "";
while (!success) {
try {
const password = await showPasswordModal(lastError);
const decrypted = await decryptAES(content, password);
blur2.dataset.decrypted = "true";
addContent(decrypted, paste.syntax);
document.getElementById("password-modal-bg")?.remove();
success = true;
} catch (error) {
if (error.message === "User cancelled") {
document.getElementById("password-modal-bg")?.remove();
break;
}
lastError = "Failed to decrypt, invalid password, or invalid data.";
}
}
} else {
blur2.dataset.decrypted = "true";
@@ -36,6 +121,16 @@ function addInfo(paste) {
document.getElementById("paste-date").innerText = `${convertUnixToLocal(paste.created)}`;
document.getElementById("paste-syntax").innerText = paste.syntax;
document.getElementById("paste-size").innerText = paste.size === 0 ? "" : formatSize(paste.size);
if (paste.size !== paste.trueSize && paste.trueSize) {
const sizeElem = document.getElementById("paste-size");
sizeElem.classList.add("has-true-size-tooltip");
let tooltip = document.createElement("div");
tooltip.className = "true-size-tooltip";
tooltip.innerText = `True size: ${formatSize(paste.trueSize)}`;
sizeElem.appendChild(tooltip);
sizeElem.onmouseenter = () => { tooltip.style.opacity = 1; };
sizeElem.onmouseleave = () => { tooltip.style.opacity = 0; };
}
document.getElementById("paste-author").innerText = paste.username;
document.getElementById("author-link").href = paste.username === "Anonymous" ? "" : `/u/${paste.username}`;
if (paste.username === "Anonymous") {
@@ -81,6 +176,7 @@ function addContent(content, syntax) {
code.classList.add("language-" + syntax === "plaintext" ? "none" : syntax);
if (syntax !== "plaintext" && syntax !== "none" && syntax !== "" && syntax !== null) {
hljs.highlightElement(code);
document.getElementById("paste-content").style.padding = "0px"
}
hljs.lineNumbersBlock(code);
document.getElementById("content-throbber").style.display = "none";
+2 -2
View File
@@ -55,13 +55,13 @@ document.addEventListener("DOMContentLoaded", async function () {
await loadUserPastes(userData, 0);
currentPage = 0;
document.getElementById("user-prev-page").onclick = async function () {
document.getElementById("previous-button").onclick = async function () {
if (currentPage > 0) {
currentPage--;
await loadUserPastes(userData, currentPage);
}
};
document.getElementById("user-next-page").onclick = async function () {
document.getElementById("next-button").onclick = async function () {
if (!lastPage) {
currentPage++;
await loadUserPastes(userData, currentPage);