This commit is contained in:
Bruno Rybársky 2024-04-25 22:38:04 +02:00
parent b38b4726d9
commit 4996e52d4d
4 changed files with 36 additions and 3 deletions

@ -274,6 +274,9 @@ async function onPageLoad() {
if ("files" === currentSite && "list" === currentPage) {
await listFiles();
}
if ("memes" === currentSite && "create" === currentPage) {
await getMemeImages();
}
}
async function navigateTo(site, page) {
@ -571,7 +574,7 @@ function deleteFile(fileID) {
xhr.send(formData);
}
async function listFiles() {
async function getFileList() {
let formData = new FormData();
formData.append('action', 'getAllFiles');
@ -582,7 +585,10 @@ async function listFiles() {
if (xhr.status === 200) {
const resp = JSON.parse(xhr.responseText);
if (resp.Status == "Success") {
displayList(resp.Files, "filelist", deleteFile);
return resp.Files;
}
else {
return false;
}
}
};
@ -590,6 +596,13 @@ async function listFiles() {
xhr.send(formData);
}
async function listFiles() {
const fileList = getFileList();
if(fileList){
displayList(fileList, "filelist", deleteFile);
}
}
function addMeme() {
let formData = new FormData();
let memeTitleElement = document.getElementById("meme_title_input");
@ -610,4 +623,16 @@ function addMeme() {
memeImageElement.reset();
};
xhr.send(formData);
}
async function getMemeImages() {
let memeImageSelector = document.getElementById("meme_image_input");
const fileList = await getFileList();
fileList.forEach((item) => {
let option = document.createElement("option");
option.value = item.ID;
option.text = `${item.Path.split("/")[-1]} - (${item.ID}) [${item.UploadedBy}]`;
memeImageSelector.appendChild(option);
});
}

@ -5,4 +5,3 @@
<input name="userfile" type="file" id="fileInput" />
<input type="button" value="Send File" onclick="uploadFile()" />
</form>
<div id="uploadStatus"></div>

9
pages/memes/create.html Normal file

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