Improved download options plus set warning on certain actions.
This commit is contained in:
parent
c84579000b
commit
7d6719510e
|
@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or
|
|||
# Download
|
||||
https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/
|
||||
|
||||
# Version: 0.1.0
|
||||
Improved look of action messages. (Save, Delete, Edit, etc...)
|
||||
# Version: 0.1.2
|
||||
Improved download options plus set warning on certain actions when nothing selected.
|
||||
|
||||
# Images
|
||||
![1 Default interface with no sessions. ](images/pic1.png)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": " Easy Session Manager",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.2",
|
||||
"description": " Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
|
||||
|
||||
"applications": {
|
||||
|
|
|
@ -2,6 +2,7 @@ let selectedItem = null;
|
|||
|
||||
document.addEventListener("click", (e) => {
|
||||
if (e.button == 0) { // Left click
|
||||
let name = e.target.name;
|
||||
if (e.target.tagName == "LI") {
|
||||
if (selectedItem) {
|
||||
if (selectedItem == e.target && selectedItem.className == "selected") {
|
||||
|
@ -15,17 +16,21 @@ document.addEventListener("click", (e) => {
|
|||
selectedItem = e.target;
|
||||
selectedItem.setAttribute("class", "selected");
|
||||
}
|
||||
} else if (e.target.name == "save") {
|
||||
} else if (name == "save") {
|
||||
saveSession();
|
||||
} else if (e.target.name == "import") {
|
||||
} else if (name == "import") {
|
||||
importSession();
|
||||
} else if (selectedItem) {
|
||||
if (e.target.name == "download")
|
||||
if (name == "download")
|
||||
downloadSession();
|
||||
else if (e.target.name == "delete")
|
||||
else if (name == "delete")
|
||||
deleteFromStorage();
|
||||
else if (e.target.name == "edit")
|
||||
else if (name == "edit")
|
||||
editSession();
|
||||
} else if (/(download|delete|edit)/.test(name)) {
|
||||
swal("Select a session first...", {
|
||||
icon: "warning",
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -146,10 +146,33 @@ const importSession = () => {
|
|||
}
|
||||
|
||||
const downloadSession = () => {
|
||||
let pTag = document.createElement("P");
|
||||
let inputTag = document.createElement("INPUT");
|
||||
let chkBoxTag = document.createElement("INPUT");
|
||||
let lblTag = document.createElement("LABEL");
|
||||
let brTag = document.createElement("BR");
|
||||
var dlAnchorElem = document.getElementById('downloadAnchorElem');
|
||||
let text = document.createTextNode("Append Date?");
|
||||
let id = selectedItem.innerHTML;
|
||||
let fileName = "session:" + id + ".json";
|
||||
chkBoxTag.type = "checkbox";
|
||||
inputTag.value = fileName;
|
||||
chkBoxTag.id = "chkbx";
|
||||
lblTag.htmlFor = "chkbx";
|
||||
lblTag.append(text);
|
||||
pTag.append(lblTag);
|
||||
pTag.append(chkBoxTag);
|
||||
pTag.append(brTag);
|
||||
pTag.append(inputTag);
|
||||
|
||||
swal("Download Session?", {
|
||||
content: pTag,
|
||||
buttons: true,
|
||||
}).then((willDl) => { if (willDl) {
|
||||
if (chkBoxTag.checked) {
|
||||
fileName = "session:" + id + ":" +
|
||||
new Date().toLocaleString().split(',')[0].replace(/\//g, "-") + ".json";
|
||||
}
|
||||
|
||||
storage.get(id).then((storageResults) => {
|
||||
let json = JSON.parse(storageResults[id]);
|
||||
|
@ -158,7 +181,8 @@ const downloadSession = () => {
|
|||
dlAnchorElem.setAttribute("download", fileName);
|
||||
dlAnchorElem.click();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const loadSession = (id = null) => {
|
||||
|
|
Loading…
Reference in New Issue