mirror of
https://github.com/rikkaneko/paste.git
synced 2025-06-06 16:45:41 +00:00
175 lines
6.3 KiB
HTML
175 lines
6.3 KiB
HTML
<!--
|
|
~ This file is part of paste.
|
|
~ Copyright (c) 2022 Joe Ma <rikkaneko23@gmail.com>
|
|
~
|
|
~ This program is free software: you can redistribute it and/or modify
|
|
~ it under the terms of the GNU Lesser General Public License as published by
|
|
~ the Free Software Foundation, either version 3 of the License, or
|
|
~ (at your option) any later version.
|
|
~
|
|
~ This program is distributed in the hope that it will be useful,
|
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
~ GNU General Public License for more details.
|
|
~
|
|
~ You should have received a copy of the GNU Lesser General Public License
|
|
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
-->
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Paste</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h2>Paste Service</h2>
|
|
<p>
|
|
<a href="https://pb.nekoul.com">pb.nekoul.com</a> is a pastebin-like service hosted on Cloudflare Worker.<br>
|
|
This service is primarily designed for own usage and interest only.<br>
|
|
All data may be deleted or expired without any notification and guarantee. Please <b>DO NOT</b> abuse this
|
|
service.<br>
|
|
The limit for file upload is <b>10 MB</b> and the paste will be kept for <b>28 days</b> only by default.<br>
|
|
The source code is available in my GitHub repository <a href="https://github.com/rikkaneko/paste">[here]</a>.<br>
|
|
This webpage is designed for upload files only.
|
|
For other operations like changing paste settings and deleting paste, please make use of the
|
|
<a href="https://github.com/rikkaneko/paste#api-specification">API call</a> with <a
|
|
href="https://wiki.archlinux.org/title/CURL">curl</a>.
|
|
</p>
|
|
|
|
<form id="upload_file_form" action="https://pb.nekoul.com" method="POST" enctype=multipart/form-data>
|
|
<div>
|
|
<div>
|
|
<h4>Upload file</h4>
|
|
<input id="upload_file" type="file" name="u" style="font-size: 14px">
|
|
</div>
|
|
<div>
|
|
<h4>Upload text</h4>
|
|
<div>
|
|
<textarea id="text_input"
|
|
style="width: 50%; max-width: 80%; font-size: 14px; margin-top: 2px"
|
|
rows="10" name="u" spellcheck="false"></textarea><br>
|
|
(<span id="text_length">0 characters</span>)
|
|
</div>
|
|
|
|
</div>
|
|
<h4>Settings</h4>
|
|
<table style="padding-bottom: 2px;">
|
|
<tr>
|
|
<td>
|
|
<label for="title_input">Title: </label>
|
|
</td>
|
|
<td>
|
|
<input id="title_input" type="text" name="title" spellcheck="false" style="width: 20em">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="pass_input">Password: </label>
|
|
</td>
|
|
<td>
|
|
<input id="pass_input" type="password" name="pass" style="width: 20em">
|
|
<input id="show_pass_button" type="checkbox">
|
|
<label for="show_pass_button">Show</label>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<label for="read_limit_input">Read limit: </label>
|
|
</td>
|
|
<td>
|
|
<input id="read_limit_input" type="number" name="read-limit" min="1" style="width: 3em">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input id="show_qr_checkbox" type="checkbox" name="qrcode" checked>
|
|
<label for="show_qr_checkbox">Show QR code on sumbitted</label>
|
|
</div>
|
|
<div>
|
|
<input id="gen_link" type="checkbox" name="paste-type" value="link">
|
|
<label for="gen_link">Generate as shorten URL link</label>
|
|
</div>
|
|
<br>
|
|
<div>
|
|
<input id="reset_button" type="reset" value="Reset" style="font-size: 14px">
|
|
<input id="sumbit_form_button" type="submit" value="Sumbit" style="font-size: 14px"> (<span
|
|
id="file_stats">0 bytes</span>)
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
function update_textarea() {
|
|
const length = document.getElementById('text_length');
|
|
length.textContent = `${this.value.length} characters`;
|
|
}
|
|
|
|
function update_file_status() {
|
|
const status = document.getElementById('file_stats');
|
|
const title = document.getElementById('title_input');
|
|
if (this.files[0] === undefined) {
|
|
status.textContent = '0 bytes';
|
|
return;
|
|
}
|
|
let bytes = this.files[0]?.size ?? 0;
|
|
let size = bytes + ' bytes';
|
|
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
|
|
for (let i = 0, approx = bytes / 1024; approx > 1; approx /= 1024, i++) {
|
|
size = approx.toFixed(3) + ' ' + units[i];
|
|
}
|
|
title.value = this.files[0]?.name || '';
|
|
status.textContent = `${this.files[0]?.type || 'application/octet-stream'}, ${size}`;
|
|
}
|
|
|
|
function toggle_password() {
|
|
let input_field = document.getElementById('pass_input');
|
|
if (this.checked) {
|
|
input_field.type = 'text';
|
|
} else {
|
|
input_field.type = 'password';
|
|
}
|
|
}
|
|
|
|
function reset_form() {
|
|
// Re-enable all input elements
|
|
let elements = document.getElementById('upload_file_form').elements;
|
|
for (let i = 0; i < elements.length; i++) {
|
|
elements[i].disabled = false;
|
|
}
|
|
let size = document.getElementById('file_stats');
|
|
size.textContent = '0 bytes';
|
|
}
|
|
|
|
function handle_submit_form(event) {
|
|
let elements = this.elements;
|
|
let select_file = elements.namedItem('upload_file');
|
|
let text = elements.namedItem('text_input');
|
|
if (!!select_file.value.length ^ !!text.value.length) {
|
|
// Check file size
|
|
const size = select_file.files[0]?.size ?? 0;
|
|
if (size > 10485760) {
|
|
alert('Upload file size must not excess 10 MB.');
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
for (let i = 0; i < elements.length; i++) {
|
|
elements[i].disabled = elements[i].value.length === 0;
|
|
}
|
|
} else {
|
|
alert('You must either upload a file or upload text, but not both or neither.');
|
|
// Prevent default submission
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
|
|
document.getElementById('upload_file').addEventListener('change', update_file_status, false);
|
|
document.getElementById('text_input').addEventListener('input', update_textarea, false);
|
|
document.getElementById('show_pass_button').addEventListener('change', toggle_password, false);
|
|
document.getElementById('reset_button').addEventListener('click', reset_form, false);
|
|
document.getElementById('upload_file_form').addEventListener('submit', handle_submit_form, false);
|
|
</script>
|
|
<br>
|
|
<a href="https://nekoul.com">[Homepage]</a><a href="https://github.com/rikkaneko/paste#api-specification">[API]</a>
|
|
<p>© 2022 rikkaneko</p>
|
|
</body>
|
|
</html>
|