added free session memory button.
This commit is contained in:
parent
e2014e25e7
commit
5adf3cbb66
|
@ -21,7 +21,9 @@
|
||||||
<li><button name="saveModalLauncher" class="button-primary" type="button">Save</button></li>
|
<li><button name="saveModalLauncher" class="button-primary" type="button">Save</button></li>
|
||||||
<li><button name="editModalLauncher" class="button-primary" type="button">Edit</button></li>
|
<li><button name="editModalLauncher" class="button-primary" type="button">Edit</button></li>
|
||||||
<li><button name="deleteModalLauncher" class="button-danger" type="button">Delete</button></li>
|
<li><button name="deleteModalLauncher" class="button-danger" type="button">Delete</button></li>
|
||||||
<br/><br/><br/>
|
<br/><br/>
|
||||||
|
<li><button name="freeSessionMeory" class="button-info" type="button">Free Memory</button></li>
|
||||||
|
<br/><br/>
|
||||||
<li><button name="import" class="button-primary" type="button">Import</button></li>
|
<li><button name="import" class="button-primary" type="button">Import</button></li>
|
||||||
<li><button name="downloadModalLauncher" class="button-primary" type="button">Download</button></li>
|
<li><button name="downloadModalLauncher" class="button-primary" type="button">Download</button></li>
|
||||||
<li><button name="donate" class="button-warning" type="button">Donate</button></li>
|
<li><button name="donate" class="button-warning" type="button">Donate</button></li>
|
||||||
|
@ -232,10 +234,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="../scripts/utils.js"></script>
|
<script src="../scripts/session-manager.js"></script>
|
||||||
<script src="../scripts/actions.js"></script>
|
<script src="../scripts/utils.js"></script>
|
||||||
<script src="../scripts/session-manager.js"></script>
|
<script src="../scripts/actions.js"></script>
|
||||||
<script src="../scripts/events.js"></script>
|
<script src="../scripts/events.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const message2 = "Name too long or none provided; or, unacceptable character used.";
|
const message2 = "Name too long or none provided; or, unacceptable character used.";
|
||||||
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
|
const regexp = /^[a-zA-Z0-9-_]+$/; // Alphanumeric, dash, underscore
|
||||||
|
|
||||||
let data = null;
|
let data = null;
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +17,6 @@ const processor = () => {
|
||||||
|
|
||||||
if (enteryName.length < 0 || enteryName.length > 54 || enteryName.search(regexp) == -1) {
|
if (enteryName.length < 0 || enteryName.length > 54 || enteryName.search(regexp) == -1) {
|
||||||
messageWindow("danger", message2, "modal-gutter");
|
messageWindow("danger", message2, "modal-gutter");
|
||||||
// prePprocessor(obj, "", message2);
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,18 @@ document.addEventListener("click", (e) => {
|
||||||
const selectedItemName = (selectedItem !== null) ? selectedItem.getAttribute("name") : "";
|
const selectedItemName = (selectedItem !== null) ? selectedItem.getAttribute("name") : "";
|
||||||
|
|
||||||
// Modals
|
// Modals
|
||||||
if (/(saveModalLauncher|editModalLauncher|deleteModalLauncher|downloadModalLauncher)/.test(action)) {
|
if (/(saveModalLauncher|freeSessionMeory|editModalLauncher|deleteModalLauncher|downloadModalLauncher)/.test(action)) {
|
||||||
if (action == "saveModalLauncher") {
|
if (action == "saveModalLauncher") {
|
||||||
preSaveSession(selectedItem, selectedItemName);
|
preSaveSession(selectedItem, selectedItemName);
|
||||||
showModal("saveModal");
|
showModal("saveModal");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action == "freeSessionMeory") {
|
||||||
|
freeSessionMeory();
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedItem) {
|
if (selectedItem) {
|
||||||
if (action == "editModalLauncher") {
|
if (action == "editModalLauncher") {
|
||||||
preEditSession(selectedItem, selectedItemName);
|
preEditSession(selectedItem, selectedItemName);
|
||||||
|
|
|
@ -215,7 +215,7 @@ const loadSession = (json = null, replaceTabs = false) => {
|
||||||
let keys = Object.keys(json);
|
let keys = Object.keys(json);
|
||||||
let keysLength = Object.keys(json).length;
|
let keysLength = Object.keys(json).length;
|
||||||
try {
|
try {
|
||||||
browser.windows.getAll().then(windows => {
|
windowApi.getAll().then(windows => {
|
||||||
windowApi.getCurrent({populate: true}).then(currentWindow => {
|
windowApi.getCurrent({populate: true}).then(currentWindow => {
|
||||||
let wasCurrentTabId = null;
|
let wasCurrentTabId = null;
|
||||||
|
|
||||||
|
@ -268,6 +268,21 @@ const loadSession = (json = null, replaceTabs = false) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const freeSessionMeory = () => {
|
||||||
|
windowApi.getAll({populate: true}).then(windows => {
|
||||||
|
for (let i = 0; i < windows.length; i++) {
|
||||||
|
windows[i].tabs.forEach(tab => {
|
||||||
|
let discarding = tabsApi.discard(tab.id);
|
||||||
|
discarding.then(onDiscarded, onError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
messageWindow("success", "Freed session memory...");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const confirmSessionOverwrite = () => {
|
const confirmSessionOverwrite = () => {
|
||||||
storageApi.set({[holderName]: holderData});
|
storageApi.set({[holderName]: holderData});
|
||||||
holderElm = document.getElementsByName(holderName)[0];
|
holderElm = document.getElementsByName(holderName)[0];
|
||||||
|
@ -276,3 +291,13 @@ const confirmSessionOverwrite = () => {
|
||||||
messageWindow("warning", "Overwrote session...");
|
messageWindow("warning", "Overwrote session...");
|
||||||
resetArgs("confModal");
|
resetArgs("confModal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function onDiscarded() {
|
||||||
|
console.log(`Discarded`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onError(error) {
|
||||||
|
console.log(`Error: ${error}`);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue