aboutsummaryrefslogtreecommitdiff
path: root/pkg/tpl/add.templ
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
commit6160b4fdc5f37e4ceaa6b3c5acc855f466049d61 (patch)
treeb6e41f9cad22515a61cc50b0a82d98ee55e0c3e3 /pkg/tpl/add.templ
parent81b13617c4d0ca68afb181d1105386f0c339864d (diff)
Первая версия
Diffstat (limited to 'pkg/tpl/add.templ')
-rw-r--r--pkg/tpl/add.templ45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkg/tpl/add.templ b/pkg/tpl/add.templ
new file mode 100644
index 0000000..0611d1b
--- /dev/null
+++ b/pkg/tpl/add.templ
@@ -0,0 +1,45 @@
+package tpl
+
+import "fmt"
+
+templ AddQuotePage(form *AddQuoteForm, err string) {
+ @Layout(HeaderParams{}) {
+ <h2>Добавление цитаты</h2>
+ if err != "" {
+ <article>
+ <header>Ошибка</header>
+ { err }
+ </article>
+ }
+ <form method="post">
+ <textarea rows="5" name="quote" placeholder="Текст цитаты">{ form.Quote }</textarea>
+ <input type="hidden" name="captcha_id" value={ form.CaptchaID }/>
+ <div role="group">
+ <img class="captcha" src={ fmt.Sprintf("/captcha/download/%s.png", form.CaptchaID) }/>
+ <audio id="audiocaptcha" src={ fmt.Sprintf("/captcha/download/%s.wav?lang=ru", form.CaptchaID) }></audio>
+ <a role="button" onclick="togglePlay()">Прослушать</a>
+ <input type="text" name="captcha_value" placeholder="Код с картинки"/>
+ </div>
+ <input type="submit" value="Отправить на модерацию"/>
+ </form>
+ <script>
+ var myAudio = document.getElementById("audiocaptcha");
+ var isPlaying = false;
+ function togglePlay() {
+ isPlaying ? myAudio.pause() : myAudio.play();
+ };
+ myAudio.onplaying = function() {
+ isPlaying = true;
+ };
+ myAudio.onpause = function() {
+ isPlaying = false;
+ };
+ </script>
+ }
+}
+
+type AddQuoteForm struct {
+ Quote string `form:"quote"`
+ CaptchaID string `form:"captcha_id"`
+ CaptchaValue string `form:"captcha_value"`
+}