forked from Adleraci/adlerka.top
Adlerka SMP FTW
This commit is contained in:
parent
e74a9c8578
commit
b38b4726d9
@ -553,11 +553,9 @@ function uploadFile() {
|
||||
xhr.open('POST', '/upload', true);
|
||||
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 200) {
|
||||
document.getElementById('uploadStatus').innerHTML = 'File uploaded successfully.';
|
||||
} else {
|
||||
document.getElementById('uploadStatus').innerHTML = 'Error uploading file.';
|
||||
}
|
||||
const respData = JSON.parse(xhr.responseText);
|
||||
handleResponse(resp, "Súbor bol úspešne nahraný", "Nastala chyba pri nahrávaní súboru");
|
||||
fileInput.reset();
|
||||
};
|
||||
|
||||
xhr.send(formData);
|
||||
@ -584,10 +582,32 @@ async function listFiles() {
|
||||
if (xhr.status === 200) {
|
||||
const resp = JSON.parse(xhr.responseText);
|
||||
if (resp.Status == "Success") {
|
||||
displayList(resp['Files'], "filelist", deleteFile);
|
||||
displayList(resp.Files, "filelist", deleteFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(formData);
|
||||
}
|
||||
|
||||
function addMeme() {
|
||||
let formData = new FormData();
|
||||
let memeTitleElement = document.getElementById("meme_title_input");
|
||||
let memeTextElement = document.getElementById("meme_text_input");
|
||||
let memeImageElement = document.getElementById("meme_image_input");
|
||||
formData.append('action', 'addMeme');
|
||||
formData.append('meme_title', memeTitleElement.value);
|
||||
formData.append('meme_text', memeTextElement.value);
|
||||
formData.append('meme_image_id', memeImageElement.value);
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/meme', true);
|
||||
xhr.onload = function () {
|
||||
const resp = JSON.parse(xhr.responseText);
|
||||
handleResponse(resp, "Meme bol pridaný", "Nastala chyba pri pridávaní meme-u");
|
||||
memeTitleElement.reset();
|
||||
memeTextElement.reset();
|
||||
memeImageElement.reset();
|
||||
};
|
||||
xhr.send(formData);
|
||||
}
|
@ -6,7 +6,7 @@ function endpoint($endpoint_data): array
|
||||
{
|
||||
|
||||
return match ($endpoint_data["action"]) {
|
||||
"addMeme" => addMeme($endpoint_data['memetitle'], $endpoint_data['memetext'], $endpoint_data['imageid']),
|
||||
"addMeme" => addMeme($endpoint_data['meme_title'], $endpoint_data['meme_text'], $endpoint_data['meme_image_id']),
|
||||
"renderGallery" => renderMemeGallery(),
|
||||
default => ["Status" => "Fail", "message" => "Invalid action"],
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user