Added invalid url detection

This commit is contained in:
2024-05-07 22:46:38 -05:00
parent b433161d72
commit 6ea60a0723
5 changed files with 57 additions and 29 deletions

View File

@@ -5,7 +5,6 @@ document.addEventListener("click", (e) => {
const target = e.target;
const action = target.getAttribute("name");
// Set selection first before doing any actions...
if (target.tagName == "LI" && target.className.includes("sessionLI")) {
if (selectedItem) {
@@ -56,6 +55,8 @@ document.addEventListener("click", (e) => {
return ;
}
if (!action) return;
if (/(closeSave|closeEdit|closeDownload|closeDelete|closeConfirm|closeLoad)/.test(action)) {
if (action.includes("closeSave")) {
hideModal("saveModal");
@@ -70,8 +71,7 @@ document.addEventListener("click", (e) => {
} else if (action.includes("closeLoad")) {
hideModal("loadModal");
}
}
else if (action.includes("deselectAll")) {
} else if (action.includes("deselectAll")) {
let container = document.getElementById("editSelectionContainer");
deselectAll(container);
}

View File

@@ -40,28 +40,33 @@ const loadContainer = (sessionData, keys, keysLength, divID) => {
/* Selection Process */
const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
let container = document.createElement("DIV");
let ulTemplate = document.querySelector('#ulTemplate');
let liTemplate = document.querySelector('#liTemplate');
let invalidURLsMessage = document.createElement("P")
let container = document.createElement("DIV");
let ulTemplate = document.querySelector('#ulTemplate');
let liTemplate = document.querySelector('#liTemplate');
invalidURLsMessage.innerText = "The Session has invalid URLs (highlighted for convenience). They might break loading of a session...";
invalidURLsMessage.classList.add("warning");
for (let i = 0; i < keysLength; i++) {
let ulClone = document.importNode(ulTemplate.content, true);
let ulTag = ulClone.querySelector('.collection');
let h2Tag = ulClone.querySelector('.ulHeader');
let h2Txt = document.createTextNode("Window: " + (i + 1));
let ulClone = document.importNode(ulTemplate.content, true);
let ulTag = ulClone.querySelector('.collection');
let h2Tag = ulClone.querySelector('.ulHeader');
let h2Txt = document.createTextNode("Window: " + (i + 1));
let selAll = ulClone.querySelector('.selAll');
let titleAll = ulClone.querySelector('.titleAll');
let ulLblTag = ulClone.querySelector('.selAllLbl');
let ulLblTag2 = ulClone.querySelector('.titleAllLbl');
let store = json[keys[i]];
let j = 0;
let selAll = ulClone.querySelector('.selAll');
let titleAll = ulClone.querySelector('.titleAll');
let ulLblTag = ulClone.querySelector('.selAllLbl');
let ulLblTag2 = ulClone.querySelector('.titleAllLbl');
let store = json[keys[i]];
let j = 0;
let hasInvalidURLs = false;
container.id = "editSelectionContainer";
selAll.id = "selectAllWin" + i;
titleAll.id = "selectAllTitle" + i;
ulLblTag.htmlFor = "selectAllWin" + i;
ulLblTag2.htmlFor = "selectAllTitle" + i;
container.id = "editSelectionContainer";
selAll.id = "selectAllWin" + i;
titleAll.id = "selectAllTitle" + i;
ulLblTag.htmlFor = "selectAllWin" + i;
ulLblTag2.htmlFor = "selectAllTitle" + i;
selAll.addEventListener("click", function (eve) {
toggleSelect(eve.target, "Win" + i);
@@ -72,12 +77,12 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
toggleTitles(eve.target, "Win" + i);
});
h2Tag.prepend(h2Txt);
store.forEach(tab => {
let liClone = document.importNode(liTemplate.content, true);
let liTag = liClone.querySelector("li");
let inptTag = liClone.querySelector("input");
// link lbl
let lblTag = liClone.querySelector(".linkLbl");
let labelTxt = document.createTextNode(tab.link);
@@ -94,6 +99,13 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
inptTag.setAttribute("name", "Win" + i); // Used for toggle select all
if (/(file:\/\/|ws:\/\/|wss:\/\/|moz-extension:\/\/|about:)/.test(tab.link)) {
liTag.classList.add("error-bg");
lblTag.classList.add("error");
lblTag2.classList.add("error");
hasInvalidURLs = true;
}
lblTag.appendChild(labelTxt);
lblTag2.appendChild(labelTxt2);
@@ -102,6 +114,10 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
j++;
});
if (hasInvalidURLs) {
container.appendChild(invalidURLsMessage);
}
container.appendChild(ulClone);
}