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