Changed edit logic
This commit is contained in:
parent
a2260a8e32
commit
d568ca5271
|
@ -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.2.0.1
|
# Version: 0.2.0.2
|
||||||
Fixed deleted elment reference in memory issue.
|
Changed edit logic: If name is different, Editing will change the session name unless new session is checked.
|
||||||
|
|
||||||
# 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.2.0.1",
|
"version": "0.2.0.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": {
|
||||||
|
|
|
@ -3,7 +3,7 @@ const windowSys = browser.windows;
|
||||||
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
|
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
|
||||||
|
|
||||||
|
|
||||||
const saveSession = (elm = null, message = "[ Session Name ] Allowed: a-z, A-Z, -, _") => {
|
const saveSession = (elm = null, message = "Session Name\nAllowed: a-z, A-Z, 0-9, -, _") => {
|
||||||
let inputTag = document.createElement("INPUT");
|
let inputTag = document.createElement("INPUT");
|
||||||
inputTag.value = new Date().toLocaleString().split(',')[0].replace(/\//g, '-');
|
inputTag.value = new Date().toLocaleString().split(',')[0].replace(/\//g, '-');
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ const saveSession = (elm = null, message = "[ Session Name ] Allowed: a-z, A-Z,
|
||||||
|
|
||||||
if (enteryName) {
|
if (enteryName) {
|
||||||
if (enteryName.search(regexp) == -1) {
|
if (enteryName.search(regexp) == -1) {
|
||||||
saveSession("Please try again...\nAllowed: a-z, A-Z, -, _")
|
saveSession("Please try again...\nAllowed: a-z, A-Z, 0-9, -, _")
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,23 +59,19 @@ const saveSession = (elm = null, message = "[ Session Name ] Allowed: a-z, A-Z,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const editSession = (elm = null, message = "Editing selected session...\nAllowed: a-z, A-Z, -, _") => {
|
const editSession = (elm = null, message = "Editing selected session...\nAllowed: a-z, A-Z, 0-9, -, _") => {
|
||||||
let id = elm.innerText;
|
let id = elm.innerText;
|
||||||
let inputTag = document.createElement("INPUT");
|
let inputTag = document.createElement("INPUT");
|
||||||
let checkedTag = document.createElement("INPUT");
|
let checkedTag = document.createElement("INPUT");
|
||||||
let labelTag = document.createElement("LABEL");
|
let labelTag = document.createElement("LABEL");
|
||||||
let brTag = document.createElement("BR");
|
let brTag = document.createElement("BR");
|
||||||
|
|
||||||
inputTag.disabled = true;
|
|
||||||
inputTag.value = id;
|
inputTag.value = id;
|
||||||
checkedTag.type = "checkbox";
|
checkedTag.type = "checkbox";
|
||||||
checkedTag.id = "newOrOld";
|
checkedTag.id = "newSession";
|
||||||
|
checkedTag.checked = false;
|
||||||
labelTag.innerText = "Create New Session";
|
labelTag.innerText = "Create New Session";
|
||||||
labelTag.htmlFor = "newOrOld";
|
labelTag.htmlFor = "newSession";
|
||||||
|
|
||||||
checkedTag.onchange = function () {
|
|
||||||
inputTag.disabled = !inputTag.disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.get(id).then((storageResults) => {
|
storage.get(id).then((storageResults) => {
|
||||||
let json = JSON.parse(storageResults[id]);
|
let json = JSON.parse(storageResults[id]);
|
||||||
|
@ -96,22 +92,41 @@ const editSession = (elm = null, message = "Editing selected session...\nAllowed
|
||||||
|
|
||||||
if (newName) {
|
if (newName) {
|
||||||
if (newName.search(regexp) == -1) {
|
if (newName.search(regexp) == -1) {
|
||||||
editSession("Please try again...\nAllowed: a-z, A-Z, -, _")
|
editSession("Please try again...\nAllowed: a-z, A-Z, 0-9, -, _")
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
json = selectionData(container, keys, keysLength);
|
json = selectionData(container, keys, keysLength);
|
||||||
if (!checkedTag.checked) {
|
if (checkedTag.checked) { // if creating from collection new session
|
||||||
storage.get(id).then((storageResults) => {
|
if (newName !== elm.innerText) {
|
||||||
storage.remove(id);
|
let sessions = document.getElementById("savedSessions").querySelectorAll("li");
|
||||||
saveToStorage(newName, JSON.stringify(json), true);
|
console.log(sessions);
|
||||||
});
|
for (var i = 0; i < sessions.length; i++) {
|
||||||
elm.textContent = newName;
|
if (sessions[i].innerText === newName) {
|
||||||
} else {
|
let min = 1;
|
||||||
if (newName !== elm.textContent) {
|
let max = 200000;
|
||||||
|
var random = Math.floor(Math.random() * (+max - +min)) + +min;
|
||||||
|
newName += "-" + random + "-" + Math.floor(Math.random() * (+10 - +1)) + +1;
|
||||||
|
}
|
||||||
|
}
|
||||||
saveToStorage(newName, JSON.stringify(json), false);
|
saveToStorage(newName, JSON.stringify(json), false);
|
||||||
} else {
|
} else { // enforce unique name
|
||||||
editSession(elm, "Cannot have the same name as before...\nAllowed: a-z, A-Z, -, _")
|
let min = 1;
|
||||||
|
let max = 200000;
|
||||||
|
var random = Math.floor(Math.random() * (+max - +min)) + +min;
|
||||||
|
newName += "-" + random + "-" + Math.floor(Math.random() * (+10 - +1)) + +1;
|
||||||
|
saveToStorage(newName, JSON.stringify(json), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (newName !== elm.innerText) { // if not creating new session and diff name rename
|
||||||
|
storage.get(id).then((storageResults) => {
|
||||||
|
storage.remove(id);
|
||||||
|
saveToStorage(newName, JSON.stringify(json), true);
|
||||||
|
}).then(() => {
|
||||||
|
elm.textContent = newName;
|
||||||
|
});
|
||||||
|
} else { // just replace
|
||||||
|
saveToStorage(newName, JSON.stringify(json), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue