Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -381,17 +381,17 @@ /* Tabs */ let nTabLexiconEditor = null; let nTabDictionaries = null; +let nTabConjugueur = null; browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) { - if (nTabId === nTabLexiconEditor) { - nTabLexiconEditor = null; - } - else if (nTabId === nTabDictionaries) { - nTabDictionaries = null; + switch (nTabId) { + case nTabLexiconEditor: nTabLexiconEditor = null; break; + case nTabDictionaries: nTabDictionaries = null; break; + case nTabConjugueur: nTabConjugueur = null; break; } }); /* @@ -421,14 +421,16 @@ let xLexEditor = browser.tabs.create({ url: browser.extension.getURL("panel/lex_editor.html") }); xLexEditor.then(onLexiconEditorOpened, onError); } + else { + browser.tabs.update(nTabLexiconEditor, {active: true}); + } } function onLexiconEditorOpened (xTab) { - //console.log(xTab); nTabLexiconEditor = xTab.id; } function openDictionaries () { if (nTabDictionaries === null) { @@ -441,28 +443,39 @@ let xLexEditor = browser.tabs.create({ url: browser.extension.getURL("panel/dictionaries.html") }); xLexEditor.then(onDictionariesOpened, onError); } + else { + browser.tabs.update(nTabDictionaries, {active: true}); + } } function onDictionariesOpened (xTab) { - //console.log(xTab); nTabDictionaries = xTab.id; } function openConjugueurTab () { - if (bChrome) { - browser.tabs.create({ + if (nTabDictionaries === null) { + if (bChrome) { + browser.tabs.create({ + url: browser.extension.getURL("panel/conjugueur.html") + }, onConjugueurOpened); + return; + } + let xConjTab = browser.tabs.create({ url: browser.extension.getURL("panel/conjugueur.html") }); - return; + xConjTab.then(onConjugueurOpened, onError); + } + else { + browser.tabs.update(nTabConjugueur, {active: true}); } - let xConjTab = browser.tabs.create({ - url: browser.extension.getURL("panel/conjugueur.html") - }); - xConjTab.then(onCreated, onError); +} + +function onConjugueurOpened (xTab) { + nTabConjugueur = xTab.id; } function openConjugueurWindow () { if (bChrome) { browser.windows.create({ @@ -477,16 +490,11 @@ url: browser.extension.getURL("panel/conjugueur.html"), type: "popup", width: 710, height: 980 }); - xConjWindow.then(onCreated, onError); } -function onCreated (xWindowInfo) { - //console.log(`Created window: ${xWindowInfo.id}`); -} - -function onError (error) { - console.log(error); +function onError (e) { + console.error(e); }