Captcha bfkešárna opravena

This commit is contained in:
2026-04-24 15:58:03 +02:00
parent 4ec7338204
commit 243e7bbffc
12 changed files with 46 additions and 17 deletions

View File

@@ -5,8 +5,8 @@ import type { PropsWithChildren } from "@kitajs/html";
const CatalogTile = ({ post }: PropsWithChildren<{ post: Post }>) => (
<div
class="catalog-tile"
id={`${post.board}-${post.id}`}
class="catalog-tile"
data-board={post.board}
data-id={post.id}
>

View File

@@ -28,8 +28,8 @@ const PostComponent = ({
reply?: boolean;
}>) => (
<div
class={`post${reply ? " reply" : ""}`}
id={`${board.id}-${post.id}`}
class={`post${reply ? " reply" : ""}`}
data-board={board.id}
data-id={post.id}
>

View File

@@ -5,7 +5,7 @@ import { Form, FormButton, FormField, FormHeader } from "./form.js";
import type { PropsWithChildren } from "@kitajs/html";
const PostActionsForm = ({ ctx }: PropsWithChildren<{ ctx: TemplateCtx }>) => (
<div class="form-group" id="post-actions">
<div id="post-actions" class="form-group">
<Form fullWidth headerOnly>
<FormHeader>
Akce příspěvku

View File

@@ -16,10 +16,10 @@ const PostForm = ({
thread?: number;
}>) => (
<form
id="post-form"
method="post"
enctype="multipart/form-data"
action="/actions/create_post"
id="post-form"
>
<input name="board" type="hidden" value={board.id} />
{thread && <input name="thread" type="hidden" value={thread.toString()} />}
@@ -87,10 +87,10 @@ const PostForm = ({
}
>
<textarea
id="post-form-content"
name="content"
rows="10"
cols="35"
id="post-form-content"
></textarea>
</FormField>
{
@@ -105,7 +105,7 @@ const PostForm = ({
) && (
<>
<FormField label="CAPTCHA" wrapper required>
<img class="full-width" src="/captcha" />
<img id="captcha" class="full-width" src="/captcha" />
<input name="captcha" type="text" />
</FormField>
</>
@@ -138,12 +138,12 @@ const PostForm = ({
}
>
<input
id="post-form-file"
class="file-input"
name="files"
type="file"
multiple={board.config.max_files > 1}
data-max-files={board.config.max_files}
id="post-form-file"
/>
<label>
[ Spoiler? <input name="spoiler" type="checkbox" /> ]

View File

@@ -74,13 +74,13 @@ const Template = (ctx: TemplateCtx) => (
<FormHeader>Tyto možnosti vyžadují JavaScript</FormHeader>
</noscript>
<FormField label="Vlastní CSS">
<textarea rows="10" cols="35" id="uconfig-css"></textarea>
<textarea id="uconfig-css" rows="10" cols="35"></textarea>
</FormField>
<FormField label="Vlastní JS">
<textarea rows="10" cols="35" id="uconfig-js"></textarea>
<textarea id="uconfig-js" rows="10" cols="35"></textarea>
</FormField>
<FormField label="Anonymizovat jména souborů" wrapper>
<input type="checkbox" id="uconfig-anon-files" />
<input id="uconfig-anon-files" type="checkbox" />
</FormField>
<tr>
<td colspan="2">

View File

@@ -14,11 +14,11 @@ const ErrorPage = (ctx: TemplateCtx, errors: CzchanError[]) => (
<PageBody ctx={ctx}>
<div class="container">
<div class="infobox center">
<h2 class="infobox-head" id="error-title">
<h2 id="error-title" class="infobox-head">
Chyba {errors[0].statusCode}
</h2>
<div class="infobox-body">
<ul class="message-list" id="error-messages">
<ul id="error-messages" class="message-list">
{errors.map((err) => (
<li safe>{err.message}</li>
))}

View File

@@ -9,11 +9,11 @@ const ResultPage = (ctx: TemplateCtx, messages: string[]) => (
<PageBody ctx={ctx}>
<div class="container">
<div class="infobox center">
<h2 class="infobox-head" id="result-title">
<h2 id="result-title" class="infobox-head">
Výsledek
</h2>
<div class="infobox-body">
<ul class="message-list" id="result-messages">
<ul id="result-messages" class="message-list">
{messages.map((message) => (
<li safe>{message}</li>
))}

View File

@@ -20,7 +20,7 @@ const autoUpdate = () => {
const infoContainer = $("#update-info-container");
infoContainer.append(
'<hr><nav class="updater"><span id="update-info"></span> <b><a href="javascript:void(0)" id="update">[Aktualizovat]</a></b> <label>[ Auto? <input type="checkbox" id="do-update" checked=""> ]</label></nav>',
'<hr><nav class="updater"><span id="update-info"></span> <b><a id="update" href="javascript:void(0)">[Aktualizovat]</a></b> <label>[ Auto? <input id="do-update" type="checkbox" checked=""> ]</label></nav>',
);
let seconds = 0;

27
web/ts/forms/captcha.ts Normal file
View File

@@ -0,0 +1,27 @@
import $ from "jquery";
const captcha = () => {
const eventHandler = () => {
const captcha = $("#captcha");
if (captcha.length === 0) {
return;
}
const src = captcha.attr("src");
if (!src) {
return;
}
const now = Date.now();
const segments = src.split("?");
captcha.prop("src", `${segments[0]}?${now}`);
};
$(window).on("pageshow", eventHandler);
$(window).on("load", eventHandler);
};
export { captcha };

View File

@@ -19,7 +19,7 @@ const dragPostActions = () => {
}
options.html(
'<label>[ <img class="icon" src="/public/img/icons/sticky.png"> <input type="checkbox" id="post-actions-sticky" checked=""> ]</label>',
'<label>[ <img class="icon" src="/public/img/icons/sticky.png"> <input id="post-actions-sticky" type="checkbox" checked=""> ]</label>',
);
const stickyCheckbox = $("#post-actions-sticky");

View File

@@ -2,7 +2,7 @@ import $ from "jquery";
const popup = (title: string, messages: string[]) => {
const popup = $(
`<div class="container"><div class="infobox"><h2 class="infobox-head clearfix"><span id="popup-title"></span><small class="float-r"><a href="javascript:void(0)" id="popup-closer">[X]</a></small></h2><div class="infobox-body"><ul class="message-list" id="popup-messages"></ul></div></div></div>`,
`<div class="container"><div class="infobox"><h2 class="infobox-head clearfix"><span id="popup-title"></span><small class="float-r"><a id="popup-closer" href="javascript:void(0)">[X]</a></small></h2><div class="infobox-body"><ul id="popup-messages" class="message-list"></ul></div></div></div>`,
);
popup.find("#popup-title").text(title);

View File

@@ -1,5 +1,6 @@
import { autoUpdate } from "./auto_update.js";
import { ajaxify } from "./forms/ajaxify.js";
import { captcha } from "./forms/captcha.js";
import { fileSelector } from "./forms/file_selector.js";
import { dragPostActions } from "./forms/post_actions.js";
import { dragPostForm } from "./forms/post_form.js";
@@ -17,6 +18,7 @@ $(function () {
initYous();
// Forms
fileSelector($("#post-form"));
captcha();
dragPostForm();
dragPostActions();
ajaxify($(".ajax-form"));