Compare commits
7 Commits
f6fc77495b
...
81802635a8
Author | SHA1 | Date |
---|---|---|
Alexander Andreev | 81802635a8 | |
Alexander Andreev | 9211abf71d | |
Alexander Andreev | 5f80c42ad9 | |
Alexander Andreev | 7026ee68c1 | |
Alexander Andreev | c1b056e22b | |
Alexander Andreev | b610105c3b | |
Alexander Andreev | 95c46d824e |
|
@ -50,7 +50,7 @@ async function getProcesses() {
|
||||||
// 127.0.0.1:19322
|
// 127.0.0.1:19322
|
||||||
async function getNewCaptcha() {
|
async function getNewCaptcha() {
|
||||||
try {
|
try {
|
||||||
return await fetch("http://startpage.arav.home.arpa/captcha/").then(r => r.text());
|
return await fetch("http://startpage.arav.home.arpa/captcha/", {method: "POST"}).then(r => r.text());
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ async function solveCaptcha(id, answer) {
|
||||||
body.append('answer', answer);
|
body.append('answer', answer);
|
||||||
let result = fetch(`http://startpage.arav.home.arpa/captcha/${id}`, { method: "POST", body: body } );
|
let result = fetch(`http://startpage.arav.home.arpa/captcha/${id}`, { method: "POST", body: body } );
|
||||||
return await result.then(r => {
|
return await result.then(r => {
|
||||||
return r.status == 200;
|
return r.status == 202;
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,15 +6,15 @@ let g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
||||||
let g_current_captcha_id = captcha_hidden_field.value;
|
let g_current_captcha_id = captcha_hidden_field.value;
|
||||||
|
|
||||||
function getColorScheme() {
|
function getColorScheme() {
|
||||||
return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNewCaptcha() {
|
async function getNewCaptcha() {
|
||||||
const id = await fetch("/captcha/").then(r => r.text());
|
const id = await fetch("/api/captcha/", { method: "POST"}).then(r => r.text());
|
||||||
g_current_captcha_id = id;
|
g_current_captcha_id = id;
|
||||||
captcha_hidden_field.value = id;
|
captcha_hidden_field.value = id;
|
||||||
setTimeout(() => { captcha_img.src = `/captcha/${id}/image?style=${getColorScheme()}` }, 600);
|
setTimeout(() => { captcha_img.src = `/api/captcha/${id}/image?style=${getColorScheme()}` }, 600);
|
||||||
g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
g_captcha_timeout_remain = g_captcha_timeout_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const captcha_span = document.getElementsByClassName("captcha")[0];
|
const captcha_span = document.getElementsByClassName("captcha")[0];
|
||||||
|
@ -22,27 +22,27 @@ const captcha_img = captcha_span.children[1];
|
||||||
|
|
||||||
captcha_span.classList.toggle("refresh");
|
captcha_span.classList.toggle("refresh");
|
||||||
captcha_span.children[3].innerHTML =
|
captcha_span.children[3].innerHTML =
|
||||||
`<button id="refresh">Refresh</button>ed in <b><span id="remain">600</span></b> seconds.`;
|
`<button id="refresh">Refresh</button>ed in <b><span id="remain">600</span></b> seconds.`;
|
||||||
|
|
||||||
const captcha_refresh = document.getElementById("refresh");
|
const captcha_refresh = document.getElementById("refresh");
|
||||||
const captcha_remain = document.getElementById("remain");
|
const captcha_remain = document.getElementById("remain");
|
||||||
|
|
||||||
captcha_refresh.classList.toggle("refresh");
|
captcha_refresh.classList.toggle("refresh");
|
||||||
captcha_refresh.addEventListener("click", async e => {
|
captcha_refresh.addEventListener("click", async e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
captcha_refresh.disabled = true;
|
captcha_refresh.disabled = true;
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
captcha_refresh.disabled = false;
|
captcha_refresh.disabled = false;
|
||||||
await fetch(`/captcha/${g_current_captcha_id}?remove`); }, 3000);
|
await fetch(`/api/captcha/${g_current_captcha_id}?remove`); }, 3000);
|
||||||
document.getElementsByName("captcha_answer")[0].value = "";
|
document.getElementsByName("captcha_answer")[0].value = "";
|
||||||
await getNewCaptcha();
|
await getNewCaptcha();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove unused CAPTCHA on a server.
|
// Remove unused CAPTCHA on a server.
|
||||||
window.addEventListener("unload", () => fetch(`/captcha/${g_current_captcha_id}?remove`));
|
window.addEventListener("unload", () => fetch(`/api/captcha/${g_current_captcha_id}?remove`));
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
captcha_remain.innerText = --g_captcha_timeout_remain;
|
captcha_remain.innerText = --g_captcha_timeout_remain;
|
||||||
if (g_captcha_timeout_remain == 0)
|
if (g_captcha_timeout_remain == 0)
|
||||||
await getNewCaptcha();
|
await getNewCaptcha();
|
||||||
}, 1000);
|
}, 1000);
|
|
@ -4,10 +4,10 @@ const articles = document.getElementsByTagName("article");
|
||||||
document.getElementById("filter").classList.remove("hidden");
|
document.getElementById("filter").classList.remove("hidden");
|
||||||
|
|
||||||
for (let i = 0; i < buttons.length; ++i)
|
for (let i = 0; i < buttons.length; ++i)
|
||||||
if (buttons[i].name !== "")
|
if (buttons[i].name !== "")
|
||||||
buttons[i].addEventListener("click", e => {
|
buttons[i].addEventListener("click", e => {
|
||||||
for (let j = 0; j < articles.length; ++j)
|
for (let j = 0; j < articles.length; ++j)
|
||||||
if (articles[j].id.startsWith(e.target.name) || e.target.name === "all")
|
if (articles[j].id.startsWith(e.target.name) || e.target.name === "all")
|
||||||
articles[j].classList.remove("hidden");
|
articles[j].classList.remove("hidden");
|
||||||
else
|
else
|
||||||
articles[j].classList.add("hidden"); });
|
articles[j].classList.add("hidden"); });
|
|
@ -123,7 +123,7 @@ block content
|
||||||
a(href='http://upload.arav.i2p') i2p
|
a(href='http://upload.arav.i2p') i2p
|
||||||
p I've made a file upload service for ya with a limit of 128MiB per file, keeping it for 36 hours, and overall storage I dedicated for it is 100GiB.
|
p I've made a file upload service for ya with a limit of 128MiB per file, keeping it for 36 hours, and overall storage I dedicated for it is 100GiB.
|
||||||
div
|
div
|
||||||
+isServiceUp("Gitea", "gitea")
|
+isServiceUp("Git", "gitea")
|
||||||
p
|
p
|
||||||
a(href='https://git.arav.top') git.arav.top
|
a(href='https://git.arav.top') git.arav.top
|
||||||
| .
|
| .
|
||||||
|
|
|
@ -30,7 +30,7 @@ block content
|
||||||
small *Only I can see if set.
|
small *Only I can see if set.
|
||||||
span.captcha
|
span.captcha
|
||||||
input(type='hidden', name='captcha_id' value=captcha_id)
|
input(type='hidden', name='captcha_id' value=captcha_id)
|
||||||
img(src='/captcha/'+captcha_id+'/image', alt="CAPTCHA" width='160' height='40')
|
img(src='/api/captcha/'+captcha_id+'/image', alt="CAPTCHA" width='160' height='40')
|
||||||
input(type='text' maxlength='6' placeholder='CAPTCHA' name='captcha_answer' required)
|
input(type='text' maxlength='6' placeholder='CAPTCHA' name='captcha_answer' required)
|
||||||
small Valid for #[b 10] minutes.
|
small Valid for #[b 10] minutes.
|
||||||
input(type='submit' value='Send a post')
|
input(type='submit' value='Send a post')
|
||||||
|
|
|
@ -45,7 +45,7 @@ block content
|
||||||
table
|
table
|
||||||
tr
|
tr
|
||||||
td justcaptcha
|
td justcaptcha
|
||||||
td 1.1.2 (19 August 2022)
|
td 2.0.0 (20 October 2022)
|
||||||
td Go
|
td Go
|
||||||
td MIT
|
td MIT
|
||||||
td
|
td
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "arav-dwelling",
|
"name": "arav-dwelling",
|
||||||
"description": "Arav's dwelling",
|
"description": "Arav's dwelling",
|
||||||
"version": "22.42.0",
|
"version": "22.42.1",
|
||||||
"author": "Alexander \"Arav\" Andreev <me@arav.top> (https://arav.top)",
|
"author": "Alexander \"Arav\" Andreev <me@arav.top> (https://arav.top)",
|
||||||
"license": "GPLv3",
|
"license": "GPLv3",
|
||||||
"homepage": "https://git.arav.top/Arav/Dwelling",
|
"homepage": "https://git.arav.top/Arav/Dwelling",
|
||||||
|
|
Loading…
Reference in New Issue