2021-02-06 04:52:46 +00:00
|
|
|
const postAjaxController = (data, action) => {
|
|
|
|
if (data.message) {
|
|
|
|
message = data.message
|
2021-02-08 02:07:13 +00:00
|
|
|
displayMessage(message.text, message.type);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.hasOwnProperty('path_head'))
|
2021-02-08 05:31:20 +00:00
|
|
|
updateHTMLDirList(data);
|
2021-02-08 02:07:13 +00:00
|
|
|
if (data.hasOwnProperty('faves_list'))
|
|
|
|
// generateFavesList(data.faves_list);
|
|
|
|
console.log("faves stub...");
|
|
|
|
if (data.hasOwnProperty("refresh")) {
|
|
|
|
if (data.refresh == "true") {
|
|
|
|
reloadDirectory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const generateFavesList = (data) => {
|
|
|
|
let listView = document.getElementById("faves-list");
|
|
|
|
clearChildNodes(listView);
|
|
|
|
|
|
|
|
data.forEach(faveArry => {
|
|
|
|
let fave = faveArry[0]
|
|
|
|
let faveId = faveArry[1]
|
|
|
|
let liTag = document.createElement("LI");
|
|
|
|
let parts = (fave.includes("/")) ? fave.split("/") : fave.split("\\");
|
|
|
|
|
|
|
|
let part = parts[parts.length - 1]
|
|
|
|
if (part.toLowerCase().includes("season")) {
|
|
|
|
part = parts[parts.length - 2] + "/" + part
|
|
|
|
}
|
|
|
|
|
|
|
|
let txtNode = document.createTextNode(part);
|
|
|
|
liTag.setAttribute("class", "btn btn-secondary btn-sm");
|
|
|
|
liTag.setAttribute("name", fave);
|
|
|
|
liTag.setAttribute("title", fave);
|
|
|
|
liTag.setAttribute("onclick", "loadFave(" + faveId +")");
|
|
|
|
liTag.appendChild(txtNode);
|
|
|
|
listView.appendChild(liTag);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const updateHTMLDirList = async (data) => {
|
2021-02-08 06:30:44 +00:00
|
|
|
let images = data.list.images[0];
|
|
|
|
let isInFaves = data.in_fave;
|
2021-02-08 05:31:20 +00:00
|
|
|
let background_image = (images[0]) ? images[0][0] : "";
|
|
|
|
|
2021-02-08 06:30:44 +00:00
|
|
|
|
|
|
|
document.getElementById("path").innerText = data.path_head;
|
2021-02-08 02:07:13 +00:00
|
|
|
// Setup background if there is a 000.* in selection
|
|
|
|
if (background_image.match(/000\.(jpg|png|gif)\b/) != null) {
|
|
|
|
// Due to same hash for 000 we add date to make link unique for each run to bypass cache issues...
|
2021-02-08 05:31:20 +00:00
|
|
|
background_image = "api/file-manager-action/files/" + images[0][1] + '?d=' + Date.now();
|
2021-02-08 02:07:13 +00:00
|
|
|
updateBackground(background_image, false);
|
|
|
|
} else {
|
2021-02-08 05:31:20 +00:00
|
|
|
background_image = "static/imgs/backgrounds/particles.mp4";
|
2021-02-08 02:07:13 +00:00
|
|
|
updateBackground(background_image);
|
|
|
|
}
|
2021-02-06 04:52:46 +00:00
|
|
|
|
2021-02-08 02:07:13 +00:00
|
|
|
// See if in faves
|
2021-02-08 06:30:44 +00:00
|
|
|
let tggl_faves_btn = document.getElementById("tggl-faves-btn");
|
2021-02-08 02:07:13 +00:00
|
|
|
if (isInFaves == "true")
|
2021-02-08 06:30:44 +00:00
|
|
|
tggl_faves_btn.classList.add("btn-info");
|
2021-02-08 02:07:13 +00:00
|
|
|
else
|
2021-02-08 06:30:44 +00:00
|
|
|
tggl_faves_btn.classList.remove("btn-info");
|
2021-02-08 02:07:13 +00:00
|
|
|
|
2021-02-08 05:31:20 +00:00
|
|
|
renderFilesList(data.list);
|
2021-02-08 02:07:13 +00:00
|
|
|
}
|