Rewrite some stuff

This commit is contained in:
Bruno Rybársky 2024-04-26 15:03:12 +02:00
parent 8177d33304
commit 3be664d8c7
2 changed files with 13 additions and 11 deletions

@ -549,6 +549,7 @@ if ("loading" === document.readyState) {
async function uploadFile() { async function uploadFile() {
const fileInput = document.getElementById('fileInput'); const fileInput = document.getElementById('fileInput');
const fileForm = document.getElementById('uploadForm');
let data = { let data = {
action: "uploadFiles" action: "uploadFiles"
}; };
@ -556,7 +557,7 @@ async function uploadFile() {
data[`userFile${i}`] = fileInput.files[i]; data[`userFile${i}`] = fileInput.files[i];
} }
await doAction("/upload", data, "Súbor bol úspešne nahraný", "Nastala chyba pri nahrávaní súboru", false); await doAction("/upload", data, "Súbor bol úspešne nahraný", "Nastala chyba pri nahrávaní súboru", false);
fileInput.reset(); fileForm.reset();
} }
async function deleteFile(fileID) { async function deleteFile(fileID) {
@ -590,6 +591,7 @@ async function addMeme() {
let memeTitleElement = document.getElementById("meme_title_input"); let memeTitleElement = document.getElementById("meme_title_input");
let memeTextElement = document.getElementById("meme_text_input"); let memeTextElement = document.getElementById("meme_text_input");
let memeImageElement = document.getElementById("meme_image_input"); let memeImageElement = document.getElementById("meme_image_input");
let memeFormElement = document.getElementById("memeAddForm");
await doAction("/meme", { await doAction("/meme", {
action: "addMeme", action: "addMeme",
@ -597,9 +599,7 @@ async function addMeme() {
meme_text: memeTextElement.value, meme_text: memeTextElement.value,
meme_image_id: memeImageElement.value meme_image_id: memeImageElement.value
}, "Meme bol zmazaný", "Nastala chyba pri mazaní meme-u", false); }, "Meme bol zmazaný", "Nastala chyba pri mazaní meme-u", false);
memeTitleElement.reset(); memeFormElement.reset();
memeTextElement.reset();
memeImageElement.reset();
} }
async function deleteMeme(memeId) { async function deleteMeme(memeId) {

@ -1,9 +1,11 @@
<!--suppress HtmlUnknownTag, HtmlUnknownTag --> <!--suppress HtmlUnknownTag, HtmlUnknownTag -->
<page minimal_permission_level="2" secret="yes" page_title="Vytvoriť"></page> <page minimal_permission_level="2" secret="yes" page_title="Vytvoriť"></page>
<label for="meme_title_input">Názov meme-u: </label> <form id="memeAddForm">
<input type="text" id="meme_title_input"/> <label for="meme_title_input">Názov meme-u: </label>
<label for="meme_text_input">Text meme-u: </label> <input type="text" id="meme_title_input"/>
<input type="text" id="meme_text_input"/> <label for="meme_text_input">Text meme-u: </label>
<label for="meme_image_input">Obrázok meme-u</label> <input type="text" id="meme_text_input"/>
<select id="meme_image_input"></select> <label for="meme_image_input">Obrázok meme-u</label>
<input type="button" value="Pridať meme" onclick="addMeme()"/> <select id="meme_image_input"></select>
<input type="button" value="Pridať meme" onclick="addMeme()"/>
</form>