Skip to content

Commit

Permalink
Open tabs in new window (#51)
Browse files Browse the repository at this point in the history
* Added feature to open tabs in new window

* Refactored code

* Formatting

* Changed error logging to debug in new window function
  • Loading branch information
PrimalPimmy authored Jun 24, 2021
1 parent 95b5eb0 commit fb9b0cb
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions js/tab-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ function restore(groupID) {
});
}

function restoreToNewWindow(groupID) {
function onCreated() {
restore(groupID);
}

function onError(error) {
console.debug(`Error: ${error}`);
}

var creating = browser.windows.create();
creating.then(onCreated, onError);
}
let store = {};

function initialise() {
Expand Down Expand Up @@ -168,12 +180,9 @@ document.getElementById("group-list").addEventListener("click", (e) => {
if (e.target && e.target.matches("button.delete-tab")) {
let prop = e.target.getAttribute("prop");
let i = e.target.getAttribute("index");
//deletes the group when the last element is deleted
if (store[prop].tabList.length == 1){
return (
browser.storage.local.remove(prop).then(window.location.reload())
);

//deletes the group when the last element is deleted
if (store[prop].tabList.length == 1) {
return browser.storage.local.remove(prop).then(window.location.reload());
}
store[prop].tabList.splice(i, 1);
let out = {
Expand All @@ -197,6 +206,12 @@ document.getElementById("group-list").addEventListener("click", (e) => {
.catch((err) => console.debug(err));
}
});
document.getElementById("group-list").addEventListener("auxclick", (e) => {
if (e.target && e.target.matches("button.restore")) {
let prop = e.target.getAttribute("prop");
if (e.button == 1) return restoreToNewWindow(prop);
}
});

document.getElementById("clear-storage-btn").addEventListener("click", () => {
confirm("Yo homie ya ight?") &&
Expand Down

0 comments on commit fb9b0cb

Please sign in to comment.