diff --git a/index.js b/index.js
index 440da34..6cb6ab9 100644
--- a/index.js
+++ b/index.js
@@ -404,6 +404,12 @@ let ContainerService = {
// FIXME: icon and color conversion based on FF version.
const identity = ContextualIdentityService.create(args.name, args.icon, args.color);
+
+ this._identitiesState[identity.userContextId] = {
+ hiddenTabUrls: [],
+ openTabs: 0
+ };
+
return Promise.resolve(this._convert(identity));
},
diff --git a/webextension/js/popup.js b/webextension/js/popup.js
index 0fdc0d1..359d567 100644
--- a/webextension/js/popup.js
+++ b/webextension/js/popup.js
@@ -29,6 +29,8 @@ function log(...args) {
let Logic = {
_identities: [],
_currentIdentity: null,
+ _currentPanel: null,
+ _previousPanel: null,
_panels: {},
init() {
@@ -62,6 +64,9 @@ let Logic = {
throw("Something really bad happened. Unknown panel: " + panel + "\n");
}
+ this._previousPanel = this._currentPanel;
+ this._currentPanel = panel;
+
this._currentIdentity = currentIdentity;
// Initialize the panel before showing it.
@@ -73,6 +78,14 @@ let Logic = {
});
},
+ showPreviousPanel() {
+ if (!this._previousPanel) {
+ throw "Current panel not set!";
+ }
+
+ this.showPanel(this._previousPanel, this._currentIdentity);
+ },
+
registerPanel(panelName, panelObject) {
this._panels[panelName] = panelObject;
panelObject.initialize();
@@ -140,7 +153,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
// This method is called when the object is registered.
initialize() {
- document.querySelector(".add-container-link").addEventListener("click", () => {
+ document.querySelector("#container-add-link").addEventListener("click", () => {
Logic.showPanel(P_CONTAINER_EDIT, {});
});
@@ -167,7 +180,6 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
fragment.appendChild(tr);
tr.classList.add("container-panel-row");
tr.classList.add("clickable");
- tr.setAttribute("data-identity-cookie-store-id", identity.userContextId);
tr.innerHTML = `
{
- Logic.showPanel(P_CONTAINERS_LIST);
+ Logic.showPreviousPanel();
});
document.querySelector("#container-info-hideorshow").addEventListener("click", e => {
@@ -303,6 +315,10 @@ Logic.registerPanel(P_CONTAINERS_EDIT, {
// This method is called when the object is registered.
initialize() {
+ document.querySelector("#edit-containers-add-link").addEventListener("click", () => {
+ Logic.showPanel(P_CONTAINER_EDIT, {});
+ });
+
document.querySelector("#exit-edit-mode-link").addEventListener("click", () => {
Logic.showPanel(P_CONTAINERS_LIST);
});
@@ -314,7 +330,6 @@ Logic.registerPanel(P_CONTAINERS_EDIT, {
Logic.identities().forEach(identity => {
let tr = document.createElement("tr");
fragment.appendChild(tr);
- tr.setAttribute("data-identity-cookie-store-id", identity.userContextId);
tr.classList.add("clickable");
tr.innerHTML = `
@@ -327,16 +342,12 @@ Logic.registerPanel(P_CONTAINERS_EDIT, {
|
|
@@ -367,18 +378,38 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
// This method is called when the object is registered.
initialize() {
document.querySelector("#edit-container-panel-back-arrow").addEventListener("click", () => {
- Logic.showPanel(P_CONTAINERS_EDIT);
+ Logic.showPreviousPanel();
});
document.querySelector("#edit-container-cancel-link").addEventListener("click", () => {
- Logic.showPanel(P_CONTAINERS_EDIT);
+ Logic.showPreviousPanel();
+ });
+
+ document.querySelector("#edit-container-ok-link").addEventListener("click", () => {
+ // FIXME: if the name is empty?
+
+ let identity = Logic.currentIdentity();
+ browser.runtime.sendMessage({
+ method: identity.userContextId ? "updateIdentity" : "createIdentity",
+ userContextId: identity.userContextId || 0,
+ name: document.getElementById("edit-container-panel-name-input").value,
+ icon: identity.image || "fingerprint",
+ color: identity.color || "green",
+ }).then(() => {
+ return Logic.refreshIdentities();
+ }).then(() => {
+ Logic.showPreviousPanel();
+ });
});
},
// This method is called when the panel is shown.
prepare() {
let identity = Logic.currentIdentity();
- document.querySelector("#edit-container-panel-name-input").value = identity.name;
+ document.querySelector("#edit-container-panel-name-input").value = identity.name || "";
+
+ // FIXME: color and icon must be set. But we need the UI first.
+
return Promise.resolve(null);
},
});
@@ -392,7 +423,7 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
// This method is called when the object is registered.
initialize() {
document.querySelector("#delete-container-cancel-link").addEventListener("click", () => {
- Logic.showPanel(P_CONTAINERS_EDIT);
+ Logic.showPreviousPanel();
});
document.querySelector("#delete-container-ok-link").addEventListener("click", () => {
@@ -402,7 +433,7 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
}).then(() => {
return Logic.refreshIdentities();
}).then(() => {
- Logic.showPanel(P_CONTAINERS_EDIT);
+ Logic.showPreviousPanel();
});
});
},
diff --git a/webextension/popup.html b/webextension/popup.html
index e3dbf2c..2c961ce 100644
--- a/webextension/popup.html
+++ b/webextension/popup.html
@@ -41,7 +41,7 @@
Edit Containers
@@ -84,7 +84,7 @@
< Exit Edit Mode
@@ -126,7 +126,7 @@
Cancel
| |