forked from Adleraci/adlerka.top
MEME
This commit is contained in:
parent
8fff030655
commit
1e38547f07
@ -12,16 +12,6 @@ function isLoggedIn() {
|
||||
return UserInfo.Email && 0 < UserInfo.Email.length;
|
||||
}
|
||||
|
||||
function until(conditionFunction) {
|
||||
|
||||
const poll = resolve => {
|
||||
if(conditionFunction()) resolve();
|
||||
else setTimeout(_ => poll(resolve), 400);
|
||||
}
|
||||
|
||||
return new Promise(poll);
|
||||
}
|
||||
|
||||
async function handleResponse(data, successMessage, failureMessage) {
|
||||
"use strict";
|
||||
const statusMessageContainer = document.getElementById("statusMessageContainer");
|
||||
@ -588,24 +578,26 @@ async function getFileList() {
|
||||
let formData = new FormData();
|
||||
formData.append('action', 'getAllFiles');
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/upload', true);
|
||||
try {
|
||||
const response = await fetch('/upload', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
let tmp;
|
||||
xhr.onload = function () {
|
||||
if (xhr.status === 200) {
|
||||
const resp = JSON.parse(xhr.responseText);
|
||||
if (resp.Status == "Success") {
|
||||
tmp = resp.Files;
|
||||
}
|
||||
else {
|
||||
tmp = false;
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
};
|
||||
xhr.send(formData);
|
||||
until(_ => (tmp === undefined));
|
||||
return tmp;
|
||||
|
||||
const resp = await response.json();
|
||||
|
||||
if (resp.Status === "Success") {
|
||||
return resp.Files;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function listFiles() {
|
||||
|
Loading…
Reference in New Issue
Block a user