diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 23:19:33 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 23:19:33 +0300 |
commit | 9dfd6aa77518b3a1e6bfd926a3b7719c32a8c97f (patch) | |
tree | d10fc76ef816160871e3955aa75821bc5d5088d4 /src/components/Form.astro | |
parent | 4ca81621e5b31922565b4149ebad1deb5161071a (diff) |
use the new api
Diffstat (limited to 'src/components/Form.astro')
-rw-r--r-- | src/components/Form.astro | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/components/Form.astro b/src/components/Form.astro index 540a4d4..93192a0 100644 --- a/src/components/Form.astro +++ b/src/components/Form.astro @@ -1,20 +1,17 @@ --- -import { sha256 } from 'js-sha256'; - export interface Props { board: string; tid?: string } const { board, tid } = Astro.props; -const iphash = sha256(Astro.clientAddress); --- <div class="blackbox"> <slot /> </div> -<script define:vars={{ board, iphash, tid }}> +<script define:vars={{ board, tid }}> document.forms['form'].addEventListener('submit', async (event) => { event.preventDefault(); @@ -34,16 +31,17 @@ const iphash = sha256(Astro.clientAddress); }).then(async (r) => { if(r.status == 200) { alert('Thread Successfuly Posted'); - let id = await r.text(); - if(id == 'close') window.top.close(); - window.location.assign(`/board/${board}/${id}`); + let t = await r.text(); + if(t == 'close') window.top.close(); + window.location.assign(`/board/${board}`); + } + else { + alert(`An Error has Accured: ${r.status} ${t}`); } - else alert('An Error has Accured'); }) } form.append('board', board); - form.append('iphash', iphash); if(tid) form.append('tid', tid); let image = document.getElementById("image").files[0]; |