2021-01-02 09:02:23 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
<link rel="stylesheet" href="css/spectre.min.css"/>
|
|
|
|
<link rel="stylesheet" href="css/spectre-icons.min.css"/>
|
|
|
|
<style>
|
|
|
|
div[id$="-form"]:not(.active) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<title>tcp.ac</title>
|
2021-01-02 11:27:46 +00:00
|
|
|
<pre style="text-align: center; font-weight: bold;">
|
|
|
|
,d
|
|
|
|
88
|
|
|
|
MM88MMM ,adPPYba, 8b,dPPYba, ,adPPYYba, ,adPPYba,
|
|
|
|
88 a8" "" 88P' "8a "" `Y8 a8" ""
|
|
|
|
88 8b 88 d8 ,adPPPPP88 8b
|
|
|
|
88, "8a, ,aa 88b, ,a8" 888 88, ,88 "8a, ,aa
|
|
|
|
"Y888 `"Ybbd8"' 88`YbbdP"' 888 `"8bbdP"Y8 `"Ybbd8"'
|
|
|
|
88
|
|
|
|
88
|
|
|
|
|
|
|
|
</pre>
|
2021-01-02 09:02:23 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<nav class="container mb-2 pb-2">
|
|
|
|
<div class="columns">
|
|
|
|
<div
|
|
|
|
class="column col-sm-12 col-md-10 col-lg-8 col-6 col-mx-auto"
|
|
|
|
>
|
|
|
|
<ul class="tab tab-block">
|
2021-01-02 11:27:46 +00:00
|
|
|
|
|
|
|
<li id="img-tab" class="tab-item active">
|
2021-01-02 09:02:23 +00:00
|
|
|
<a href="#">img</a>
|
|
|
|
</li>
|
2021-01-02 11:27:46 +00:00
|
|
|
|
|
|
|
<li id="url-tab" class="tab-item" style="display:none;">
|
2021-01-02 09:02:23 +00:00
|
|
|
<a href="#">txt</a>
|
|
|
|
</li>
|
2021-01-02 11:27:46 +00:00
|
|
|
|
|
|
|
<li id="url-tab" class="tab-item" style="display:none;">
|
|
|
|
<a href="#">url</a>
|
|
|
|
</li>
|
2021-01-02 09:02:23 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<main class="container mt-2 pt-2">
|
|
|
|
<div class="columns">
|
|
|
|
<div
|
|
|
|
id="img-form"
|
2021-01-02 11:27:46 +00:00
|
|
|
class="column col-sm-12 col-md-10 col-lg-8 col-6 col-mx-auto active">
|
2021-01-02 09:02:23 +00:00
|
|
|
<div class="form-group">
|
2021-01-02 11:27:46 +00:00
|
|
|
<label class="form-label" for="img-file">img</label>
|
2021-01-02 09:02:23 +00:00
|
|
|
<input
|
|
|
|
class="form-input"
|
|
|
|
id="img-file"
|
|
|
|
type="file"
|
2021-01-02 11:27:46 +00:00
|
|
|
required/>
|
|
|
|
<button
|
|
|
|
class="btn btn-primary input-group-btn"
|
|
|
|
id="img-submit"
|
|
|
|
disabled>
|
|
|
|
<i class="icon icon-upload"></i>
|
|
|
|
</button>
|
|
|
|
<p class="form-input-hint">accepted: jpeg,png,gif</p>
|
2021-01-02 09:02:23 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
id="url-form"
|
2021-01-02 11:27:46 +00:00
|
|
|
class="column col-sm-12 col-md-10 col-lg-8 col-6 col-mx-auto">
|
2021-01-02 09:02:23 +00:00
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="url-url">url</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<span class="input-group-addon">/l/</span>
|
|
|
|
<input
|
|
|
|
id="url-url"
|
|
|
|
class="form-input"
|
|
|
|
type="text"
|
2021-01-02 11:27:46 +00:00
|
|
|
placeholder="404040"
|
2021-01-02 09:02:23 +00:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
class="btn btn-primary input-group-btn"
|
|
|
|
id="url-submit"
|
|
|
|
disabled
|
|
|
|
>
|
|
|
|
<i class="icon icon-upload"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="url-forward"
|
|
|
|
>Forward</label
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
id="url-forward"
|
|
|
|
class="form-input"
|
|
|
|
type="url"
|
2021-01-02 11:27:46 +00:00
|
|
|
placeholder="http://legitwebsite.cool/goatse.png"
|
2021-01-02 09:02:23 +00:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
id="txt-form"
|
|
|
|
class="column col-sm-12 col-md-10 col-lg-8 col-6 col-mx-auto"
|
|
|
|
>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="txt-url">url</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<span class="input-group-addon">/t/</span>
|
|
|
|
<input
|
|
|
|
id="txt-url"
|
|
|
|
class="form-input"
|
|
|
|
type="text"
|
|
|
|
placeholder="a1b2c3"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
class="btn btn-primary input-group-btn"
|
|
|
|
id="txt-submit"
|
|
|
|
disabled
|
|
|
|
>
|
|
|
|
<i class="icon icon-upload"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-label" for="txt-contents"
|
|
|
|
>Contents</label
|
|
|
|
>
|
|
|
|
<textarea
|
|
|
|
id="txt-contents"
|
|
|
|
class="form-input"
|
2021-01-02 11:27:46 +00:00
|
|
|
placeholder="rm -rf /* --no-preserve-root"
|
2021-01-02 09:02:23 +00:00
|
|
|
required
|
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="form-switch">
|
|
|
|
<input id="txt-highlight" type="checkbox" />
|
2021-01-02 11:27:46 +00:00
|
|
|
<i class="form-icon"></i> syntax highlighting
|
2021-01-02 09:02:23 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<div id="modal" class="modal">
|
|
|
|
<a id="modal-bg" href="#" class="modal-overlay"></a>
|
|
|
|
<div class="modal-container">
|
|
|
|
<div class="modal-header">
|
2021-01-02 11:27:46 +00:00
|
|
|
<div class="modal-title h6">success</div>
|
2021-01-02 09:02:23 +00:00
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="content">
|
|
|
|
<div class="form-group">
|
|
|
|
<div class="has-icon-right">
|
|
|
|
<input
|
|
|
|
id="modal-input"
|
|
|
|
type="url"
|
|
|
|
class="form-input"
|
|
|
|
/>
|
|
|
|
<i class="form-icon icon icon-copy"></i>
|
|
|
|
</div>
|
|
|
|
<p class="form-input-hint" id="modal-hint">
|
2021-01-02 11:27:46 +00:00
|
|
|
click to copy to clipboard
|
2021-01-02 09:02:23 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
const tabs = {
|
|
|
|
img: [
|
|
|
|
document.querySelector("#img-tab"),
|
|
|
|
document.querySelector("#img-form"),
|
|
|
|
],
|
2021-01-02 11:27:46 +00:00
|
|
|
/*
|
2021-01-02 09:02:23 +00:00
|
|
|
url: [
|
|
|
|
document.querySelector("#url-tab"),
|
|
|
|
document.querySelector("#url-form"),
|
|
|
|
],
|
|
|
|
txt: [
|
|
|
|
document.querySelector("#txt-tab"),
|
|
|
|
document.querySelector("#txt-form"),
|
|
|
|
],
|
2021-01-02 11:27:46 +00:00
|
|
|
*/
|
2021-01-02 09:02:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const inputs = {
|
|
|
|
img: [
|
|
|
|
document.querySelector("#img-file"),
|
|
|
|
document.querySelector("#img-submit"),
|
|
|
|
],
|
2021-01-02 11:27:46 +00:00
|
|
|
/*
|
2021-01-02 09:02:23 +00:00
|
|
|
url: [
|
|
|
|
document.querySelector("#url-url"),
|
|
|
|
document.querySelector("#url-forward"),
|
|
|
|
document.querySelector("#url-submit"),
|
|
|
|
],
|
|
|
|
txt: [
|
|
|
|
document.querySelector("#txt-url"),
|
|
|
|
document.querySelector("#txt-contents"),
|
|
|
|
document.querySelector("#txt-highlight"),
|
|
|
|
document.querySelector("#txt-submit"),
|
|
|
|
],
|
2021-01-02 11:27:46 +00:00
|
|
|
*/
|
2021-01-02 09:02:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const used = {
|
|
|
|
img: [],
|
|
|
|
url: [],
|
|
|
|
txt: [],
|
|
|
|
};
|
|
|
|
|
|
|
|
let baseurl = `${location.protocol}//${location.host}${location.pathname}`;
|
|
|
|
if (!baseurl.endsWith("/")) {
|
|
|
|
baseurl += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
const modal = {
|
|
|
|
self: document.querySelector("#modal"),
|
|
|
|
input: document.querySelector("#modal-input"),
|
|
|
|
bg: document.querySelector("#modal-bg"),
|
|
|
|
hint: document.querySelector("#modal-hint"),
|
|
|
|
};
|
|
|
|
const openModal = (text) => {
|
|
|
|
modal.input.value = text;
|
2021-01-02 11:27:46 +00:00
|
|
|
modal.hint.innerText = "click to copy to clipboard";
|
2021-01-02 09:02:23 +00:00
|
|
|
modal.self.classList.add("active");
|
|
|
|
};
|
|
|
|
const closeModal = () => {
|
2021-01-02 11:27:46 +00:00
|
|
|
modal.hint.innerText = "copied to clipboard";
|
2021-01-02 09:02:23 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
modal.self.classList.remove("active");
|
|
|
|
modal.input.value = "";
|
|
|
|
}, 1000);
|
|
|
|
};
|
|
|
|
modal.input.onclick = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
modal.input.select();
|
|
|
|
document.execCommand("copy");
|
|
|
|
closeModal();
|
|
|
|
};
|
|
|
|
modal.bg.onclick = closeModal;
|
|
|
|
|
|
|
|
const fetchUsed = () => {
|
2021-01-02 11:27:46 +00:00
|
|
|
fetch(`${baseurl}i`)
|
2021-01-02 09:02:23 +00:00
|
|
|
.then((response) => response.json())
|
|
|
|
.then((json) => (used.img = json));
|
2021-01-02 11:27:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
fetch(`${baseurl}u`)
|
2021-01-02 09:02:23 +00:00
|
|
|
.then((response) => response.json())
|
|
|
|
.then((json) => (used.url = json));
|
|
|
|
fetch(`${baseurl}t`)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((json) => (used.txt = json));
|
2021-01-02 11:27:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-01-02 09:02:23 +00:00
|
|
|
};
|
2021-01-02 11:27:46 +00:00
|
|
|
|
2021-01-02 09:02:23 +00:00
|
|
|
fetchUsed();
|
|
|
|
|
|
|
|
|
2021-01-02 11:27:46 +00:00
|
|
|
/*
|
2021-01-02 09:02:23 +00:00
|
|
|
for (const group in tabs) {
|
|
|
|
tabs[group][0].onclick = () => {
|
|
|
|
const active = document.querySelectorAll(".active");
|
|
|
|
for (const el of active) {
|
|
|
|
el.classList.remove("active");
|
|
|
|
}
|
|
|
|
for (const el of tabs[group]) {
|
|
|
|
el.classList.add("active");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-01-02 11:27:46 +00:00
|
|
|
*/
|
2021-01-02 09:02:23 +00:00
|
|
|
|
2021-01-02 11:27:46 +00:00
|
|
|
const group = "img";
|
|
|
|
const submitButton = inputs[group][inputs[group].length - 1];
|
2021-01-02 09:02:23 +00:00
|
|
|
|
|
|
|
if (group === "img") {
|
|
|
|
submitButton.addEventListener("click", () => {
|
|
|
|
const imgFileInput = inputs.img[1];
|
|
|
|
const file = imgFileInput.img[0];
|
|
|
|
|
|
|
|
if (!file) {
|
2021-01-02 11:27:46 +00:00
|
|
|
alert(new Error("select a file first"));
|
2021-01-02 09:02:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const fd = new FormData();
|
2021-01-02 11:27:46 +00:00
|
|
|
fd.append("upload", file);
|
2021-01-02 09:02:23 +00:00
|
|
|
|
|
|
|
let status;
|
|
|
|
fetch(url, {
|
2021-01-02 11:27:46 +00:00
|
|
|
method: "pUT",
|
2021-01-02 09:02:23 +00:00
|
|
|
body: fd,
|
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
status = response.status;
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then((text) => {
|
|
|
|
if (status !== 201) {
|
|
|
|
throw new Error(text);
|
|
|
|
} else {
|
|
|
|
openModal(url);
|
|
|
|
clearInputs();
|
|
|
|
fetchUsed();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => alert(error));
|
|
|
|
});
|
2021-01-02 11:27:46 +00:00
|
|
|
|
|
|
|
/*
|
2021-01-02 09:02:23 +00:00
|
|
|
} else if (group === "url") {
|
|
|
|
submitButton.addEventListener("click", () => {
|
|
|
|
const id = urlInput.value;
|
|
|
|
const forward = inputs.url[1].value;
|
|
|
|
|
|
|
|
const url = `${baseurl}l/${id}`;
|
|
|
|
let status;
|
|
|
|
fetch(url, {
|
2021-01-02 11:27:46 +00:00
|
|
|
method: "pUT",
|
2021-01-02 09:02:23 +00:00
|
|
|
body: JSON.stringify({ forward }),
|
2021-01-02 11:27:46 +00:00
|
|
|
headers: { "content-Type": "application/json" },
|
2021-01-02 09:02:23 +00:00
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
status = response.status;
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then((text) => {
|
|
|
|
if (status !== 201) {
|
|
|
|
throw new Error(text);
|
|
|
|
} else {
|
|
|
|
openModal(url);
|
|
|
|
clearInputs();
|
|
|
|
fetchUsed();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => alert(error));
|
|
|
|
});
|
|
|
|
} else if (group === "txt") {
|
|
|
|
submitButton.addEventListener("click", () => {
|
|
|
|
const id = urlInput.value;
|
|
|
|
const contents = inputs.txt[1].value;
|
|
|
|
const highlight = inputs.txt[2].checked;
|
|
|
|
|
|
|
|
const url = `${baseurl}t/${id}`;
|
|
|
|
let status;
|
|
|
|
fetch(url, {
|
2021-01-02 11:27:46 +00:00
|
|
|
method: "pUT",
|
2021-01-02 09:02:23 +00:00
|
|
|
body: JSON.stringify({ contents, highlight }),
|
2021-01-02 11:27:46 +00:00
|
|
|
headers: { "content-Type": "application/json" },
|
2021-01-02 09:02:23 +00:00
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
status = response.status;
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then((text) => {
|
|
|
|
if (status !== 201) {
|
|
|
|
throw new Error(text);
|
|
|
|
} else {
|
|
|
|
openModal(url);
|
|
|
|
clearInputs();
|
|
|
|
fetchUsed();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => alert(error));
|
|
|
|
});
|
|
|
|
}
|
2021-01-02 11:27:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-01-02 09:02:23 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|