Added empty session alerts where needed.
This commit is contained in:
parent
9b940f1d7a
commit
48b0ef340d
@ -20,9 +20,7 @@ document.addEventListener("click", (e) => {
|
||||
else if (name == "edit")
|
||||
editSession(selectedItem);
|
||||
} else {
|
||||
swal("Select a session first...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Select a session first...");
|
||||
}
|
||||
} else if (name == "save") {
|
||||
saveSession(selectedItem);
|
||||
@ -81,9 +79,7 @@ document.addEventListener("dblclick", (e) => {
|
||||
if (keysLength > 0) {
|
||||
loadSession(json, replaceTabs.checked);
|
||||
} else {
|
||||
swal("Canceled operation; no tabs were selected...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled operation; no tabs were selected...");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -46,14 +46,10 @@ const saveSession = (elm = null, message = "Session Name\nAllowed: a-z, A-Z, 0-9
|
||||
sessionData = selectionData(container, keys, keysLength);
|
||||
saveToStorage(enteryName, JSON.stringify(sessionData));
|
||||
} else {
|
||||
swal("Canceled save...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled save...");
|
||||
}
|
||||
} else {
|
||||
swal("Canceled save...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled save...");
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -122,14 +118,10 @@ const editSession = (elm = null, message = "Editing selected session...\nAllowed
|
||||
}
|
||||
}
|
||||
} else {
|
||||
swal("Canceled edit...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled edit...");
|
||||
}
|
||||
} else {
|
||||
swal("Canceled edit...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled edit...");
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -195,9 +187,7 @@ const loadSession = (json = null, replaceTabs = false) => {
|
||||
|
||||
if (replaceTabs) { // Clear all windows but main then load...
|
||||
if (keysLength == 0) {
|
||||
swal("Canceled operation; no tabs in session...", {
|
||||
icon: "error",
|
||||
});
|
||||
messageWindow("error", "Canceled operation; no tabs in session...");
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -232,9 +222,7 @@ const loadSession = (json = null, replaceTabs = false) => {
|
||||
if (keysLength == 1) {
|
||||
windowMaker(0, keysLength, keys, json)
|
||||
} else if (keysLength == 0) {
|
||||
swal("Canceled operation; no tabs in session...", {
|
||||
icon: "error",
|
||||
});
|
||||
messageWindow("error", "Canceled operation; no tabs in session...");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,3 +1,7 @@
|
||||
const messageWindow = (type = "warning", message = "No message passed in...") => {
|
||||
swal(message, { icon: type, });
|
||||
}
|
||||
|
||||
const getSavedSessionIDs = () => {
|
||||
console.log("Getting saved sessions...");
|
||||
storage.get(null).then((storageResults) => {
|
||||
@ -48,19 +52,13 @@ const saveToStorage = (name, data, fromEdit = false) => {
|
||||
let json = null;
|
||||
try {
|
||||
json = JSON.parse(storageResults[name]);
|
||||
swal("Overwrote session...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Overwrote session...");
|
||||
} catch (e) {
|
||||
if (fromEdit) { // minor logic fix
|
||||
swal("Overwrote session...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Overwrote session...");
|
||||
} else {
|
||||
appendToSavedSessionsList(name);
|
||||
swal("Saved session...", {
|
||||
icon: "success",
|
||||
});
|
||||
messageWindow("success", "Saved session...");
|
||||
}
|
||||
} finally {
|
||||
storage.set({[name]: data});
|
||||
@ -81,13 +79,9 @@ const deleteFromStorage = (elm = null) => {
|
||||
elm.parentElement.removeChild(elm);
|
||||
});
|
||||
selectedItem = null; // reset selectedItem
|
||||
swal("Deleted session successfully...", {
|
||||
icon: "success",
|
||||
});
|
||||
messageWindow("success", "Deleted session successfully...");
|
||||
} else {
|
||||
swal("Canceled deletion...", {
|
||||
icon: "warning",
|
||||
});
|
||||
messageWindow("warning", "Canceled deletion...");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user