2020-02-01 02:43:21 +00:00
|
|
|
getSavedSessionIDs();
|
2019-04-06 03:36:25 +00:00
|
|
|
|
2018-11-11 09:04:55 +00:00
|
|
|
document.addEventListener("click", (e) => {
|
|
|
|
if (e.button == 0) { // Left click
|
2020-02-29 21:30:44 +00:00
|
|
|
const target = e.target;
|
2020-03-02 02:59:26 +00:00
|
|
|
const action = target.getAttribute("name");
|
|
|
|
|
2019-04-06 03:36:25 +00:00
|
|
|
|
2020-02-01 04:25:41 +00:00
|
|
|
// Set selection first before doing any actions...
|
|
|
|
if (target.tagName == "LI" && target.className.includes("sessionLI")) {
|
2018-11-11 09:04:55 +00:00
|
|
|
if (selectedItem) {
|
2020-02-01 04:25:41 +00:00
|
|
|
if (selectedItem == target && selectedItem.className == "sessionLI selected") {
|
2019-04-06 03:36:25 +00:00
|
|
|
selectedItem.setAttribute("class", "sessionLI");
|
2019-03-19 21:19:18 +00:00
|
|
|
selectedItem = null;
|
2018-11-11 09:04:55 +00:00
|
|
|
} else {
|
2019-04-06 03:36:25 +00:00
|
|
|
selectedItem.setAttribute("class", "sessionLI");
|
2020-02-01 04:25:41 +00:00
|
|
|
selectedItem = target;
|
2019-04-06 03:36:25 +00:00
|
|
|
selectedItem.setAttribute("class", "sessionLI selected");
|
2018-11-11 09:04:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-02-01 04:25:41 +00:00
|
|
|
selectedItem = target;
|
2019-04-06 03:36:25 +00:00
|
|
|
selectedItem.setAttribute("class", "sessionLI selected");
|
2018-11-11 09:04:55 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-01 04:25:41 +00:00
|
|
|
|
|
|
|
const selectedItemName = (selectedItem !== null) ? selectedItem.getAttribute("name") : "";
|
2020-02-29 21:30:44 +00:00
|
|
|
|
|
|
|
// Modals
|
|
|
|
if (/(saveModalLauncher|editModalLauncher|deleteModalLauncher|downloadModalLauncher)/.test(action)) {
|
|
|
|
if (action == "saveModalLauncher") {
|
|
|
|
preSaveSession(selectedItem, selectedItemName);
|
|
|
|
showModal("saveModal");
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2020-02-01 04:25:41 +00:00
|
|
|
if (selectedItem) {
|
2020-02-29 21:30:44 +00:00
|
|
|
if (action == "editModalLauncher") {
|
|
|
|
preEditSession(selectedItem, selectedItemName);
|
|
|
|
showModal("editModal");
|
|
|
|
} else if (action == "deleteModalLauncher") {
|
|
|
|
document.getElementsByName("toDeleteName")[0].innerText = selectedItemName;
|
|
|
|
showModal("deleteModal");
|
|
|
|
} else if (action == "downloadModalLauncher") {
|
|
|
|
preDownloadSession(selectedItemName);
|
|
|
|
showModal("downloadModal");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
messageWindow("warning", "Select a session first...");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/(closeSave|closeEdit|closeDownload|closeDelete|closeConfirm|closeLoad)/.test(action)) {
|
|
|
|
if (action.includes("closeSave")) {
|
|
|
|
hideModal("saveModal");
|
|
|
|
} else if (action.includes("closeEdit")) {
|
|
|
|
hideModal("editModal");
|
|
|
|
} else if (action.includes("closeDownload")) {
|
|
|
|
hideModal("downloadModal");
|
|
|
|
} else if (action.includes("closeDelete")) {
|
|
|
|
hideModal("deleteModal");
|
|
|
|
} else if (action.includes("closeConfirm")) {
|
|
|
|
hideModal("confModal");
|
|
|
|
} else if (action.includes("closeLoad")) {
|
|
|
|
hideModal("loadModal");
|
|
|
|
}
|
|
|
|
}
|
2020-04-13 17:02:30 +00:00
|
|
|
else if (action.includes("deselectAll")) {
|
2020-08-25 00:44:52 +00:00
|
|
|
let container = document.getElementById("editSelectionContainer");
|
2020-04-13 17:02:30 +00:00
|
|
|
deselectAll(container);
|
|
|
|
}
|
2020-02-29 21:30:44 +00:00
|
|
|
|
|
|
|
// Actions
|
|
|
|
if (/(download|delete|edit|load)/.test(action)) {
|
|
|
|
if (selectedItem) {
|
|
|
|
if (action == "download") {
|
2020-02-01 04:25:41 +00:00
|
|
|
downloadSession(selectedItemName);
|
2020-02-29 21:30:44 +00:00
|
|
|
} else if (action == "delete") {
|
2020-02-01 06:59:29 +00:00
|
|
|
deleteFromStorage(selectedItem, selectedItemName);
|
2020-02-29 21:30:44 +00:00
|
|
|
hideModal("deleteModal");
|
|
|
|
} else if (action == "edit") {
|
2020-02-01 04:25:41 +00:00
|
|
|
editSession(selectedItem, selectedItemName);
|
2020-02-29 21:30:44 +00:00
|
|
|
} else if (action == "load") {
|
|
|
|
startLoadSession();
|
|
|
|
}
|
2020-02-01 04:25:41 +00:00
|
|
|
}
|
|
|
|
} else if (action == "save") {
|
|
|
|
saveSession(selectedItem, selectedItemName);
|
2020-02-29 21:30:44 +00:00
|
|
|
} else if (action == "confirm") {
|
|
|
|
confirmSessionOverwrite();
|
2020-02-01 04:25:41 +00:00
|
|
|
} else if (action == "import") {
|
|
|
|
importSession();
|
|
|
|
} else if (action == "donate") {
|
|
|
|
doUrlAction("https://www.paypal.me/ITDominator",);
|
|
|
|
}
|
2018-11-11 09:04:55 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-29 21:30:44 +00:00
|
|
|
|
2018-11-11 09:04:55 +00:00
|
|
|
document.addEventListener("dblclick", (e) => {
|
|
|
|
if (e.button == 0) { // Left click
|
2019-04-06 03:36:25 +00:00
|
|
|
if (e.target.tagName == "LI" && e.target.className.includes("sessionLI")) {
|
|
|
|
selectedItem = e.target;
|
2020-02-01 06:59:29 +00:00
|
|
|
const id = selectedItem.getAttribute("name");
|
2019-04-06 03:36:25 +00:00
|
|
|
selectedItem.setAttribute("class", "sessionLI selected");
|
2020-02-01 02:43:21 +00:00
|
|
|
preLoadSession(id);
|
2018-11-11 09:04:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|