Tranga-Website/Website/interaction.js

524 lines
21 KiB
JavaScript
Raw Normal View History

let publications = [];
2023-05-23 17:57:48 +02:00
let tasks = [];
2023-05-23 18:28:27 +02:00
let toEditId;
2023-05-23 17:57:48 +02:00
2023-05-31 22:16:14 +02:00
const searchBox = document.querySelector("#searchbox");
2023-05-23 16:27:09 +02:00
const searchPublicationQuery = document.querySelector("#searchPublicationQuery");
const selectPublication = document.querySelector("#taskSelectOutput");
const connectorSelect = document.querySelector("#connectors");
const settingsPopup = document.querySelector("#settingsPopup");
2023-05-23 16:27:09 +02:00
const settingsCog = document.querySelector("#settingscog");
const selectRecurrence = document.querySelector("#selectReccurrence");
const tasksContent = document.querySelector("content");
const selectPublicationPopup = document.querySelector("#selectPublicationPopup");
const createMonitorTaskButton = document.querySelector("#createMonitorTaskButton");
const createDownloadChapterTaskButton = document.querySelector("#createDownloadChapterTaskButton");
const createMonitorTaskPopup = document.querySelector("#createMonitorTaskPopup");
const createDownloadChaptersTask = document.querySelector("#createDownloadChaptersTask");
const chapterOutput = document.querySelector("#chapterOutput");
const selectedChapters = document.querySelector("#selectedChapters");
2023-05-23 18:46:06 +02:00
const publicationViewerPopup = document.querySelector("#publicationViewerPopup");
const publicationViewerWindow = document.querySelector("publication-viewer");
2023-05-23 17:57:48 +02:00
const publicationViewerDescription = document.querySelector("#publicationViewerDescription");
const publicationViewerName = document.querySelector("#publicationViewerName");
2023-05-31 17:54:09 +02:00
const publicationViewerTags = document.querySelector("#publicationViewerTags");
2023-05-23 17:57:48 +02:00
const publicationViewerAuthor = document.querySelector("#publicationViewerAuthor");
const pubviewcover = document.querySelector("#pubviewcover");
const publicationDelete = document.querySelector("publication-delete");
2023-05-26 14:32:08 +02:00
const publicationTaskStart = document.querySelector("publication-starttask");
2023-05-24 20:57:17 +02:00
const settingDownloadLocation = document.querySelector("#downloadLocation");
2023-05-24 21:48:54 +02:00
const settingKomgaUrl = document.querySelector("#komgaUrl");
2023-05-24 20:57:17 +02:00
const settingKomgaUser = document.querySelector("#komgaUsername");
const settingKomgaPass = document.querySelector("#komgaPassword");
2023-06-03 16:25:04 +02:00
const settingKavitaUrl = document.querySelector("#kavitaUrl");
2023-06-03 21:26:29 +02:00
const settingKavitaUser = document.querySelector("#kavitaUsername");
const settingKavitaPass = document.querySelector("#kavitaPassword");
2023-06-15 18:38:47 +02:00
const settingGotifyUrl = document.querySelector("#gotifyUrl");
const settingGotifyAppToken = document.querySelector("#gotifyAppToken");
const settingLunaseaWebhook = document.querySelector("#lunaseaWebhook");
2023-06-03 16:25:04 +02:00
const libraryUpdateTime = document.querySelector("#libraryUpdateTime");
2023-05-24 21:48:54 +02:00
const settingKomgaConfigured = document.querySelector("#komgaConfigured");
2023-06-03 16:25:04 +02:00
const settingKavitaConfigured = document.querySelector("#kavitaConfigured");
2023-06-15 18:38:47 +02:00
const settingGotifyConfigured = document.querySelector("#gotifyConfigured");
const settingLunaseaConfigured = document.querySelector("#lunaseaConfigured");
2023-05-25 10:42:19 +02:00
const settingApiUri = document.querySelector("#settingApiUri");
const tagTasksRunning = document.querySelector("#tasksRunningTag");
const tagTasksQueued = document.querySelector("#tasksQueuedTag");
const downloadTasksPopup = document.querySelector("#downloadTasksPopup");
const downloadTasksOutput = downloadTasksPopup.querySelector("popup-content");
2023-05-23 16:27:09 +02:00
2023-08-31 12:58:34 +02:00
searchBox.addEventListener("keyup", () => FilterResults());
2023-05-24 21:48:54 +02:00
settingsCog.addEventListener("click", () => OpenSettings());
document.querySelector("#blurBackgroundSettingsPopup").addEventListener("click", () => settingsPopup.style.display = "none");
document.querySelector("#blurBackgroundTaskPopup").addEventListener("click", () => selectPublicationPopup.style.display = "none");
2023-05-23 18:46:06 +02:00
document.querySelector("#blurBackgroundPublicationPopup").addEventListener("click", () => HidePublicationPopup());
document.querySelector("#blurBackgroundCreateMonitorTaskPopup").addEventListener("click", () => createMonitorTaskPopup.style.display = "none");
document.querySelector("#blurBackgroundCreateDownloadChaptersTask").addEventListener("click", () => createDownloadChaptersTask.style.display = "none");
document.querySelector("#blurBackgroundTasksQueuePopup").addEventListener("click", () => downloadTasksPopup.style.display = "none");
selectedChapters.addEventListener("keypress", (event) => {
if(event.key === "Enter"){
DownloadChapterTaskClick();
}
})
2023-05-23 18:07:15 +02:00
publicationDelete.addEventListener("click", () => DeleteTaskClick());
createMonitorTaskButton.addEventListener("click", () => {
HidePublicationPopup();
createMonitorTaskPopup.style.display = "block";
});
createDownloadChapterTaskButton.addEventListener("click", () => {
HidePublicationPopup();
OpenDownloadChapterTaskPopup();
});
2023-05-26 14:32:08 +02:00
publicationTaskStart.addEventListener("click", () => StartTaskClick());
2023-05-25 10:42:19 +02:00
searchPublicationQuery.addEventListener("keypress", (event) => {
if(event.key === "Enter"){
NewSearch();
}
});
2023-05-23 16:27:09 +02:00
2023-05-23 14:44:59 +02:00
GetAvailableControllers()
.then(json => availableConnectors = json)
2023-05-23 15:15:29 +02:00
.then(json =>
2023-05-23 14:44:59 +02:00
json.forEach(connector => {
2023-05-23 15:15:29 +02:00
var option = document.createElement('option');
option.value = connector;
option.innerText = connector;
connectorSelect.appendChild(option);
})
);
2023-05-23 14:44:59 +02:00
2023-05-24 20:57:41 +02:00
function NewSearch(){
//Disable inputs
connectorSelect.disabled = true;
searchPublicationQuery.disabled = true;
2023-05-31 17:54:54 +02:00
//Waitcursor
document.body.style.cursor = "wait";
2023-05-24 20:57:41 +02:00
//Empty previous results
selectPublication.replaceChildren();
GetPublicationFromConnector(connectorSelect.value, searchPublicationQuery.value)
2023-05-24 20:57:41 +02:00
.then(json =>
json.forEach(publication => {
var option = CreatePublication(publication, connectorSelect.value);
option.addEventListener("click", (mouseEvent) => {
ShowPublicationViewerWindow(publication.internalId, mouseEvent, true);
});
selectPublication.appendChild(option);
}
))
.then(() => {
//Re-enable inputs
connectorSelect.disabled = false;
searchPublicationQuery.disabled = false;
2023-05-31 17:54:54 +02:00
//Cursor
document.body.style.cursor = "initial";
2023-05-24 20:57:41 +02:00
});
}
2023-05-24 20:17:50 +02:00
//Returns a new "Publication" Item to display in the tasks section
2023-05-23 16:27:09 +02:00
function CreatePublication(publication, connector){
2023-05-23 17:57:48 +02:00
var publicationElement = document.createElement('publication');
publicationElement.setAttribute("id", publication.internalId);
2023-05-23 15:15:29 +02:00
var img = document.createElement('img');
2023-05-25 14:28:56 +02:00
img.src = `imageCache/${publication.coverFileNameInCache}`;
2023-05-23 17:57:48 +02:00
publicationElement.appendChild(img);
2023-05-23 15:15:29 +02:00
var info = document.createElement('publication-information');
var connectorName = document.createElement('connector-name');
2023-05-23 16:27:09 +02:00
connectorName.innerText = connector;
2023-05-23 15:15:29 +02:00
connectorName.className = "pill";
info.appendChild(connectorName);
var publicationName = document.createElement('publication-name');
publicationName.innerText = publication.sortName;
info.appendChild(publicationName);
2023-05-23 17:57:48 +02:00
publicationElement.appendChild(info);
if(publications.filter(pub => pub.internalId === publication.internalId) < 1)
publications.push(publication);
return publicationElement;
2023-05-23 15:15:29 +02:00
}
function AddMonitorTask(){
var hours = document.querySelector("#hours").value;
var minutes = document.querySelector("#minutes").value;
CreateMonitorTask(connectorSelect.value, toEditId, `${hours}:${minutes}:00`, "en");
HidePublicationPopup();
createMonitorTaskPopup.style.display = "none";
selectPublicationPopup.style.display = "none";
2023-05-23 18:46:06 +02:00
}
function OpenDownloadChapterTaskPopup(){
selectedChapters.value = "";
chapterOutput.replaceChildren();
createDownloadChaptersTask.style.display = "block";
GetChapters(toEditId, connectorSelect.value, true, "en").then((json) => {
var i = 0;
json.forEach(chapter => {
var chapterDom = document.createElement("div");
var indexDom = document.createElement("span");
indexDom.className = "index";
indexDom.innerText = i++;
chapterDom.appendChild(indexDom);
var volDom = document.createElement("span");
volDom.className = "vol";
volDom.innerText = chapter.volumeNumber;
chapterDom.appendChild(volDom);
var chDom = document.createElement("span");
chDom.className = "ch";
chDom.innerText = chapter.chapterNumber;
chapterDom.appendChild(chDom);
var titleDom = document.createElement("span");
titleDom.innerText = chapter.name;
chapterDom.appendChild(titleDom);
chapterOutput.appendChild(chapterDom);
});
});
}
function DownloadChapterTaskClick(){
CreateDownloadChaptersTask(connectorSelect.value, toEditId, selectedChapters.value, "en");
HidePublicationPopup();
createDownloadChaptersTask.style.display = "none";
selectPublicationPopup.style.display = "none";
}
function DeleteTaskClick(){
taskToDelete = tasks.filter(tTask => tTask.publication.internalId === toEditId)[0];
2023-06-21 16:53:56 +02:00
DeleteTask("MonitorPublication", taskToDelete.connectorName, toEditId);
HidePublicationPopup();
2023-05-23 15:15:29 +02:00
}
2023-05-23 14:44:59 +02:00
2023-05-26 14:32:08 +02:00
function StartTaskClick(){
var toEditTask = tasks.filter(task => task.publication.internalId == toEditId)[0];
2023-06-22 22:52:26 +02:00
StartTask("MonitorPublication", toEditTask.connectorName, toEditId);
2023-05-26 14:32:08 +02:00
HidePublicationPopup();
}
2023-05-23 16:27:09 +02:00
function ResetContent(){
2023-05-24 20:17:50 +02:00
//Delete everything
2023-05-23 16:27:09 +02:00
tasksContent.replaceChildren();
2023-05-24 20:17:50 +02:00
//Add "Add new Task" Button
2023-05-23 16:27:09 +02:00
var add = document.createElement("div");
add.setAttribute("id", "addPublication")
var plus = document.createElement("p");
plus.innerText = "+";
add.appendChild(plus);
add.addEventListener("click", () => ShowNewTaskWindow());
tasksContent.appendChild(add);
}
2023-05-23 18:28:27 +02:00
function ShowPublicationViewerWindow(publicationId, event, add){
//Show popup
publicationViewerPopup.style.display = "block";
2023-05-24 20:17:50 +02:00
//Set position to mouse-position
if(event.clientY < window.innerHeight - publicationViewerWindow.offsetHeight)
publicationViewerWindow.style.top = `${event.clientY}px`;
else
publicationViewerWindow.style.top = `${event.clientY - publicationViewerWindow.offsetHeight}px`;
if(event.clientX < window.innerWidth - publicationViewerWindow.offsetWidth)
publicationViewerWindow.style.left = `${event.clientX}px`;
else
publicationViewerWindow.style.left = `${event.clientX - publicationViewerWindow.offsetWidth}px`;
2023-05-23 17:57:48 +02:00
2023-05-24 20:17:50 +02:00
//Edit information inside the window
var publication = publications.filter(pub => pub.internalId === publicationId)[0];
2023-05-23 17:57:48 +02:00
publicationViewerName.innerText = publication.sortName;
2023-05-31 17:54:09 +02:00
publicationViewerTags.innerText = publication.tags.join(", ");
2023-05-23 17:57:48 +02:00
publicationViewerDescription.innerText = publication.description;
2023-06-10 14:45:04 +02:00
publicationViewerAuthor.innerText = publication.authors.join(',');
pubviewcover.src = `imageCache/${publication.coverFileNameInCache}`;
2023-05-23 18:28:27 +02:00
toEditId = publicationId;
2023-05-23 17:57:48 +02:00
2023-05-24 20:17:50 +02:00
//Check what action should be listed
2023-05-23 18:28:27 +02:00
if(add){
createMonitorTaskButton.style.display = "initial";
createDownloadChapterTaskButton.style.display = "initial";
2023-05-23 18:28:27 +02:00
publicationDelete.style.display = "none";
2023-05-26 14:32:08 +02:00
publicationTaskStart.style.display = "none";
2023-05-23 18:28:27 +02:00
}
2023-05-23 18:46:06 +02:00
else{
createMonitorTaskButton.style.display = "none";
createDownloadChapterTaskButton.style.display = "none";
2023-05-26 14:32:08 +02:00
publicationDelete.style.display = "initial";
publicationTaskStart.style.display = "initial";
2023-05-23 18:46:06 +02:00
}
2023-05-23 17:57:48 +02:00
}
2023-05-24 20:17:50 +02:00
function HidePublicationPopup(){
publicationViewerPopup.style.display = "none";
}
2023-05-23 16:27:09 +02:00
function ShowNewTaskWindow(){
selectPublication.replaceChildren();
searchPublicationQuery.value = "";
selectPublicationPopup.style.display = "flex";
2023-05-23 16:27:09 +02:00
}
2023-05-23 18:46:06 +02:00
2023-05-23 16:27:09 +02:00
const fadeIn = [
{ opacity: "0" },
{ opacity: "1" }
];
const fadeInTiming = {
2023-05-23 17:57:48 +02:00
duration: 50,
2023-05-23 16:27:09 +02:00
iterations: 1,
fill: "forwards"
}
2023-05-24 21:48:54 +02:00
function OpenSettings(){
GetSettingsClick();
settingsPopup.style.display = "flex";
}
2023-05-24 20:57:17 +02:00
function GetSettingsClick(){
2023-05-25 10:42:19 +02:00
settingApiUri.value = "";
2023-05-24 21:48:54 +02:00
settingKomgaUrl.value = "";
settingKomgaUser.value = "";
settingKomgaPass.value = "";
2023-06-15 18:38:47 +02:00
settingKomgaConfigured.innerText = "❌";
2023-06-03 16:25:04 +02:00
settingKavitaUrl.value = "";
2023-06-03 21:26:29 +02:00
settingKavitaUser.value = "";
settingKavitaPass.value = "";
2023-06-03 16:25:04 +02:00
settingKavitaConfigured.innerText = "❌";
2023-06-15 18:38:47 +02:00
settingGotifyUrl.value = "";
settingGotifyAppToken.value = "";
settingGotifyConfigured.innerText = "❌";
settingLunaseaWebhook.value = "";
settingLunaseaConfigured.innerText = "❌";
2023-05-24 21:48:54 +02:00
2023-05-25 10:42:19 +02:00
settingApiUri.placeholder = apiUri;
2023-05-24 21:48:54 +02:00
GetSettings().then(json => {
settingDownloadLocation.innerText = json.downloadLocation;
2023-06-03 16:25:04 +02:00
json.libraryManagers.forEach(lm => {
if(lm.libraryType == 0){
settingKomgaUrl.placeholder = lm.baseUrl;
2023-06-03 21:26:29 +02:00
settingKomgaUser.placeholder = "User";
2023-06-03 16:25:04 +02:00
settingKomgaPass.placeholder = "***";
settingKomgaConfigured.innerText = "✅";
2023-06-03 21:26:29 +02:00
} else if(lm.libraryType == 1){
2023-06-03 16:25:04 +02:00
settingKavitaUrl.placeholder = lm.baseUrl;
2023-06-03 21:26:29 +02:00
settingKavitaUser.placeholder = "User";
settingKavitaPass.placeholder = "***";
2023-06-03 16:25:04 +02:00
settingKavitaConfigured.innerText = "✅";
}
});
2023-06-15 18:38:47 +02:00
json.notificationManagers.forEach(nm => {
if(nm.notificationManagerType == 0){
settingGotifyConfigured.innerText = "✅";
} else if(nm.notificationManagerType == 1){
settingLunaseaConfigured.innerText = "✅";
}
2023-06-15 18:38:47 +02:00
});
2023-05-24 21:48:54 +02:00
});
2023-05-24 20:57:17 +02:00
2023-05-24 21:48:54 +02:00
GetKomgaTask().then(json => {
if(json.length > 0)
2023-06-03 16:25:04 +02:00
libraryUpdateTime.value = json[0].reoccurrence;
2023-05-24 21:48:54 +02:00
});
2023-05-24 20:57:17 +02:00
}
2023-06-03 16:25:04 +02:00
function UpdateLibrarySettings(){
if(settingKomgaUrl.value != "" && settingKomgaUser.value != "" && settingKomgaPass.value != ""){
2023-05-26 13:39:42 +02:00
var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`);
console.log(auth);
2023-06-15 18:38:47 +02:00
UpdateKomga(settingKomgaUrl.value, auth);
2023-06-03 16:25:04 +02:00
}
2023-06-03 21:26:29 +02:00
if(settingKavitaUrl.value != "" && settingKavitaUser.value != "" && settingKavitaPass.value != ""){
2023-06-15 18:38:47 +02:00
UpdateKavita(settingKavitaUrl.value, settingKavitaUser.value, settingKavitaPass.value);
2023-05-26 13:39:42 +02:00
}
2023-06-15 18:38:47 +02:00
if(settingGotifyUrl.value != "" && settingGotifyAppToken.value != ""){
UpdateGotify(settingGotifyUrl.value, settingGotifyAppToken.value);
}
if(settingLunaseaWebhook.value != ""){
UpdateLunaSea(settingLunaseaWebhook.value);
}
if(settingApiUri.value != ""){
apiUri = settingApiUri.value;
document.cookie = `apiUri=${apiUri};`;
}
2023-06-03 21:37:21 +02:00
setTimeout(() => GetSettingsClick(), 200);
2023-05-24 21:48:54 +02:00
}
function utf8_to_b64( str ) {
return window.btoa(unescape(encodeURIComponent( str )));
2023-05-24 20:57:17 +02:00
}
2023-05-31 22:16:14 +02:00
function FilterResults(){
if(searchBox.value.length > 0){
tasksContent.childNodes.forEach(publication => {
publication.childNodes.forEach(item => {
if(item.nodeName.toLowerCase() == "publication-information"){
item.childNodes.forEach(information => {
if(information.nodeName.toLowerCase() == "publication-name"){
if(!information.textContent.toLowerCase().includes(searchBox.value.toLowerCase())){
publication.style.display = "none";
}else{
publication.style.display = "initial";
}
}
});
}
});
});
}else{
tasksContent.childNodes.forEach(publication => publication.style.display = "initial");
}
}
function ShowTasksQueue(){
downloadTasksOutput.replaceChildren();
GetRunningTasks()
.then(json => {
tagTasksRunning.innerText = json.length;
json.forEach(task => {
2023-06-11 17:05:24 +02:00
if(task.task == 2 || task.task == 4) {
downloadTasksOutput.appendChild(CreateProgressChild(task));
2023-06-19 17:17:47 +02:00
document.querySelector(`#progress${GetValidSelector(task.taskId)}`).value = task.progress;
2023-06-11 17:05:24 +02:00
var finishedHours = task.executionApproximatelyRemaining.split(':')[0];
var finishedMinutes = task.executionApproximatelyRemaining.split(':')[1];
var finishedSeconds = task.executionApproximatelyRemaining.split(':')[2].split('.')[0];
2023-06-19 17:17:47 +02:00
document.querySelector(`#progressStr${GetValidSelector(task.taskId)}`).innerText = `${finishedHours}:${finishedMinutes}:${finishedSeconds}`;
2023-06-11 17:05:24 +02:00
}
});
});
GetQueue()
.then(json => {
tagTasksQueued.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
});
downloadTasksPopup.style.display = "flex";
}
function CreateProgressChild(task){
var child = document.createElement("div");
var img = document.createElement('img');
img.src = `imageCache/${task.publication.coverFileNameInCache}`;
child.appendChild(img);
var name = document.createElement("span");
name.innerText = task.publication.sortName;
name.className = "pubTitle";
child.appendChild(name);
var progress = document.createElement("progress");
2023-06-19 17:17:47 +02:00
progress.id = `progress${GetValidSelector(task.taskId)}`;
child.appendChild(progress);
2023-05-31 22:16:14 +02:00
var progressStr = document.createElement("span");
progressStr.innerText = " \t∞";
progressStr.className = "progressStr";
2023-06-19 17:17:47 +02:00
progressStr.id = `progressStr${GetValidSelector(task.taskId)}`;
child.appendChild(progressStr);
2023-05-31 22:16:14 +02:00
if(task.chapter != undefined){
var chapterNumber = document.createElement("span");
chapterNumber.className = "chapterNumber";
chapterNumber.innerText = `Vol.${task.chapter.volumeNumber} Ch.${task.chapter.chapterNumber}`;
child.appendChild(chapterNumber);
var chapterName = document.createElement("span");
chapterName.className = "chapterName";
chapterName.innerText = task.chapter.name;
child.appendChild(chapterName);
}
return child;
2023-05-31 22:16:14 +02:00
}
2023-05-24 20:17:50 +02:00
//Resets the tasks shown
2023-05-23 16:27:09 +02:00
ResetContent();
downloadTasksOutput.replaceChildren();
2023-05-24 20:17:50 +02:00
//Get Tasks and show them
2023-05-24 21:48:54 +02:00
GetDownloadTasks()
2023-05-23 16:27:09 +02:00
.then(json => json.forEach(task => {
var publication = CreatePublication(task.publication, task.connectorName);
publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, false));
2023-05-23 16:27:09 +02:00
tasksContent.appendChild(publication);
tasks.push(task);
2023-05-23 16:27:09 +02:00
}));
2023-05-23 14:44:59 +02:00
GetRunningTasks()
.then(json => {
tagTasksRunning.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
});
GetQueue()
.then(json => {
tagTasksQueued.innerText = json.length;
json.forEach(task => {
downloadTasksOutput.appendChild(CreateProgressChild(task));
});
})
2023-05-23 14:44:59 +02:00
setInterval(() => {
2023-05-24 20:17:50 +02:00
//Tasks from API
var cTasks = [];
2023-05-24 21:48:54 +02:00
GetDownloadTasks()
.then(json => json.forEach(task => cTasks.push(task)))
.then(() => {
2023-05-24 20:17:50 +02:00
//Only update view if tasks-amount has changed
if(tasks.length != cTasks.length) {
2023-05-24 20:17:50 +02:00
//Resets the tasks shown
ResetContent();
2023-05-24 20:17:50 +02:00
//Add all currenttasks to view
2023-05-23 18:19:46 +02:00
cTasks.forEach(task => {
var publication = CreatePublication(task.publication, task.connectorName);
publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, false));
2023-05-23 18:19:46 +02:00
tasksContent.appendChild(publication);
})
tasks = cTasks;
}
}
);
GetRunningTasks()
.then(json => {
tagTasksRunning.innerText = json.length;
});
GetQueue()
.then(json => {
tagTasksQueued.innerText = json.length;
});
}, 1000);
setInterval(() => {
GetRunningTasks().then((json) => {
json.forEach(task => {
2023-06-11 17:05:24 +02:00
if(task.task == 2 || task.task == 4){
2023-06-19 17:17:47 +02:00
document.querySelector(`#progress${GetValidSelector(task.taskId)}`).value = task.progress;
2023-06-11 17:05:24 +02:00
var finishedHours = task.executionApproximatelyRemaining.split(':')[0];
var finishedMinutes = task.executionApproximatelyRemaining.split(':')[1];
var finishedSeconds = task.executionApproximatelyRemaining.split(':')[2].split('.')[0];
2023-06-19 17:17:47 +02:00
document.querySelector(`#progressStr${GetValidSelector(task.taskId)}`).innerText = `${finishedHours}:${finishedMinutes}:${finishedSeconds}`;
2023-06-11 17:05:24 +02:00
}
});
});
2023-06-19 17:17:47 +02:00
},500);
function GetValidSelector(str){
var clean = [...str.matchAll(/[a-zA-Z0-9]*-*_*/g)];
return clean.join('');
}