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;
|
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) {
|
async function handleResponse(data, successMessage, failureMessage) {
|
||||||
"use strict";
|
"use strict";
|
||||||
const statusMessageContainer = document.getElementById("statusMessageContainer");
|
const statusMessageContainer = document.getElementById("statusMessageContainer");
|
||||||
@ -588,24 +578,26 @@ async function getFileList() {
|
|||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append('action', 'getAllFiles');
|
formData.append('action', 'getAllFiles');
|
||||||
|
|
||||||
let xhr = new XMLHttpRequest();
|
try {
|
||||||
xhr.open('POST', '/upload', true);
|
const response = await fetch('/upload', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
let tmp;
|
if (!response.ok) {
|
||||||
xhr.onload = function () {
|
throw new Error('Network response was not ok');
|
||||||
if (xhr.status === 200) {
|
|
||||||
const resp = JSON.parse(xhr.responseText);
|
|
||||||
if (resp.Status == "Success") {
|
|
||||||
tmp = resp.Files;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tmp = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
xhr.send(formData);
|
const resp = await response.json();
|
||||||
until(_ => (tmp === undefined));
|
|
||||||
return tmp;
|
if (resp.Status === "Success") {
|
||||||
|
return resp.Files;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listFiles() {
|
async function listFiles() {
|
||||||
|
Loading…
Reference in New Issue
Block a user