Added on save grab selected item name if applicable. Fixed clearing of selected item.
This commit is contained in:
parent
7d6719510e
commit
8ea3c95100
|
@ -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.2
|
||||
Improved download options plus set warning on certain actions when nothing selected.
|
||||
# Version: 0.1.4
|
||||
Added on save grab selected item name if applicable. Fixed clearing of selected item.
|
||||
|
||||
# Images
|
||||
![1 Default interface with no sessions. ](images/pic1.png)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": " Easy Session Manager",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"description": " Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
|
||||
|
||||
"applications": {
|
||||
|
|
|
@ -30,7 +30,7 @@ body, html {
|
|||
</span>
|
||||
|
||||
|
||||
<script src="../scripts/sweetalert.min.js"></script>
|
||||
<script src="../scripts/sweetalert.js"></script>
|
||||
<script src="../scripts/background.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
<script src="../scripts/events.js"></script>
|
||||
<script src="../scripts/sweetalert.min.js"></script>
|
||||
<script src="../scripts/sweetalert.js"></script>
|
||||
<script src="../scripts/sessionManager.js"></script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -7,6 +7,7 @@ document.addEventListener("click", (e) => {
|
|||
if (selectedItem) {
|
||||
if (selectedItem == e.target && selectedItem.className == "selected") {
|
||||
selectedItem.setAttribute("class", "");
|
||||
selectedItem = null;
|
||||
} else {
|
||||
selectedItem.setAttribute("class", "");
|
||||
selectedItem = e.target;
|
||||
|
@ -17,16 +18,16 @@ document.addEventListener("click", (e) => {
|
|||
selectedItem.setAttribute("class", "selected");
|
||||
}
|
||||
} else if (name == "save") {
|
||||
saveSession();
|
||||
saveSession(selectedItem);
|
||||
} else if (name == "import") {
|
||||
importSession();
|
||||
} else if (selectedItem) {
|
||||
if (name == "download")
|
||||
downloadSession();
|
||||
downloadSession(selectedItem);
|
||||
else if (name == "delete")
|
||||
deleteFromStorage();
|
||||
deleteFromStorage(selectedItem);
|
||||
else if (name == "edit")
|
||||
editSession();
|
||||
editSession(selectedItem);
|
||||
} else if (/(download|delete|edit)/.test(name)) {
|
||||
swal("Select a session first...", {
|
||||
icon: "warning",
|
||||
|
|
|
@ -3,16 +3,20 @@ const windowSys = browser.windows;
|
|||
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
|
||||
|
||||
|
||||
const saveSession = (message = "What is this session's name? Allowed: a-z, A-Z, -, _") => {
|
||||
const saveSession = (elm = null, message = "What is this session's name? Allowed: a-z, A-Z, -, _") => {
|
||||
let inputTag = document.createElement("INPUT");
|
||||
inputTag.value = new Date().toLocaleString().split(',')[0].replace(/\//g, '-');
|
||||
|
||||
if (elm !== null)
|
||||
inputTag.value = elm.innerHTML;
|
||||
|
||||
swal(message, {
|
||||
content: inputTag,
|
||||
buttons: true,
|
||||
}).then((value) => {
|
||||
if (value) {
|
||||
let enteryName = inputTag.value.replace(/ /g, "_");
|
||||
|
||||
if (enteryName) {
|
||||
if (enteryName.search(regexp) == -1) {
|
||||
saveSession("Please try again...\nAllowed: a-z, A-Z, -, _")
|
||||
|
@ -53,8 +57,8 @@ const saveSession = (message = "What is this session's name? Allowed: a-z, A-Z,
|
|||
});
|
||||
}
|
||||
|
||||
const editSession = (message = "Editing selected session... Allowed: a-z, A-Z, -, _") => {
|
||||
let id = selectedItem.innerHTML;
|
||||
const editSession = (elm = null, message = "Editing selected session... Allowed: a-z, A-Z, -, _") => {
|
||||
let id = elm.innerHTML;
|
||||
let inputTag = document.createElement("INPUT");
|
||||
inputTag.value = id;
|
||||
|
||||
|
@ -77,7 +81,7 @@ const editSession = (message = "Editing selected session... Allowed: a-z, A-Z, -
|
|||
saveToStorage(newName, JSON.stringify(json), true);
|
||||
});
|
||||
|
||||
selectedItem.textContent = newName;
|
||||
elm.textContent = newName;
|
||||
} else {
|
||||
swal("Canceled edit...", {
|
||||
icon: "warning",
|
||||
|
@ -115,17 +119,17 @@ const saveToStorage = (name, data, fromEdit = false) => {
|
|||
});
|
||||
}
|
||||
|
||||
const deleteFromStorage = () => {
|
||||
const deleteFromStorage = (elm = null) => {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Do you wish to delete session:\n" + selectedItem.innerHTML + "?",
|
||||
text: "Do you wish to delete session:\n" + elm.innerHTML + "?",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
}).then((willDelete) => {
|
||||
if (willDelete) {
|
||||
storage.remove(selectedItem.innerHTML).then(() => {
|
||||
selectedItem.parentElement.removeChild(selectedItem);
|
||||
storage.remove(elm.innerHTML).then(() => {
|
||||
elm.parentElement.removeChild(elm);
|
||||
});
|
||||
swal("Deleted session successfully...", {
|
||||
icon: "success",
|
||||
|
@ -145,7 +149,7 @@ const importSession = () => {
|
|||
});
|
||||
}
|
||||
|
||||
const downloadSession = () => {
|
||||
const downloadSession = (elm = null) => {
|
||||
let pTag = document.createElement("P");
|
||||
let inputTag = document.createElement("INPUT");
|
||||
let chkBoxTag = document.createElement("INPUT");
|
||||
|
@ -153,7 +157,7 @@ const downloadSession = () => {
|
|||
let brTag = document.createElement("BR");
|
||||
var dlAnchorElem = document.getElementById('downloadAnchorElem');
|
||||
let text = document.createTextNode("Append Date?");
|
||||
let id = selectedItem.innerHTML;
|
||||
let id = elm.innerHTML;
|
||||
let fileName = "session:" + id + ".json";
|
||||
chkBoxTag.type = "checkbox";
|
||||
inputTag.value = fileName;
|
||||
|
|
Loading…
Reference in New Issue