Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -144,36 +144,36 @@ function setSpellingDictionaries (oData) { if (oData.hasOwnProperty("oPersonalDictionary")) { // deprecated console.log("personal dictionary migration"); - browser.storage.local.set({ "oDictionaries": { "__personal__": oData["oPersonalDictionary"] } }); + browser.storage.local.set({ "dictionaries": { "__personal__": oData["oPersonalDictionary"] } }); setDictionary("personal", oData["oPersonalDictionary"]); browser.storage.local.remove("oPersonalDictionary"); } - if (oData.hasOwnProperty("oDictionaries")) { - if (oData.oDictionaries.hasOwnProperty("__personal__")) { - setDictionary("personal", oData.oDictionaries["__personal__"]); + if (oData.hasOwnProperty("dictionaries")) { + if (oData.dictionaries.hasOwnProperty("__personal__")) { + setDictionary("personal", oData.dictionaries["__personal__"]); } - if (oData.oDictionaries.hasOwnProperty("__community__")) { - setDictionary("personal", oData.oDictionaries["__community__"]); + if (oData.dictionaries.hasOwnProperty("__community__")) { + setDictionary("personal", oData.dictionaries["__community__"]); } } } function init () { if (bChrome) { browser.storage.local.get("gc_options", initGrammarChecker); browser.storage.local.get("ui_options", initUIOptions); - browser.storage.local.get("oDictionaries", setSpellingDictionaries); + browser.storage.local.get("dictionaries", setSpellingDictionaries); browser.storage.local.get("oPersonalDictionary", setSpellingDictionaries); // deprecated browser.storage.local.get("sc_options", initSCOptions); return; } browser.storage.local.get("gc_options").then(initGrammarChecker, showError); browser.storage.local.get("ui_options").then(initUIOptions, showError); - browser.storage.local.get("oDictionaries").then(setSpellingDictionaries, showError); + browser.storage.local.get("dictionaries").then(setSpellingDictionaries, showError); browser.storage.local.get("oPersonalDictionary").then(setSpellingDictionaries, showError); // deprecated browser.storage.local.get("sc_options").then(initSCOptions, showError); } init(); Index: gc_lang/fr/webext/panel/lex_editor.css ================================================================== --- gc_lang/fr/webext/panel/lex_editor.css +++ gc_lang/fr/webext/panel/lex_editor.css @@ -48,10 +48,15 @@ h3 { margin: 3px 0 2px 0; color: hsl(210, 50%, 50%); font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; } + +#dic_selector { + color: hsl(210, 50%, 50%); + font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; +} details { font-size: 11px; font-variant: small-caps; color: hsl(210, 50%, 50%); @@ -65,10 +70,11 @@ } details.inline { padding: 3px; width: 260px; } + /* Main buttons */ @@ -247,11 +253,11 @@ box-shadow: 0 0 2px hsl(150, 60%, 50%); } #lexicon_page { - + } /* Search page Index: gc_lang/fr/webext/panel/lex_editor.html ================================================================== --- gc_lang/fr/webext/panel/lex_editor.html +++ gc_lang/fr/webext/panel/lex_editor.html @@ -12,12 +12,18 @@

Éditeur lexical

-

Dictionnaire personnel

-
Date :
+

Dictionnaire

+
+ +
+
[]
0 entrées
Index: gc_lang/fr/webext/panel/lex_editor.js ================================================================== --- gc_lang/fr/webext/panel/lex_editor.js +++ gc_lang/fr/webext/panel/lex_editor.js @@ -125,12 +125,15 @@ clear () { while (this.xTable.firstChild) { this.xTable.removeChild(this.xTable.firstChild); } + this.lEntry = []; + this.nEntry = 0; this.iEntryIndex = 0; this._createHeader(); + this.showEntryNumber(); } fill (lFlex) { this.clear(); if (lFlex.length > 0) { @@ -495,60 +498,62 @@ const oDictHandler = { oDictionaries: null, loadDictionaries: function () { if (bChrome) { - browser.storage.local.get("oDictionaries", this._loadDictionaries.bind(this)); + browser.storage.local.get("dictionaries", this._loadDictionaries.bind(this)); return; } - let xPromise = browser.storage.local.get("oDictionaries"); + let xPromise = browser.storage.local.get("dictionaries"); xPromise.then(this._loadDictionaries.bind(this), showError); }, _loadDictionaries: function (oResult) { - if (!oResult.hasOwnProperty("oDictionaries")) { + if (!oResult.hasOwnProperty("dictionaries")) { return; } - this.oDictionaries = oResult.oDictionaries; + this.oDictionaries = oResult.dictionaries; oBinaryDict.load("__personal__"); }, getDictionary: function (sName) { - console.log("load "+sName); if (this.oDictionaries && this.oDictionaries.hasOwnProperty(sName)) { - console.log(this.oDictionaries[sName]); + //console.log(this.oDictionaries[sName]); return this.oDictionaries[sName]; } return null; }, saveDictionary: function (sName, oJSON) { this.oDictionaries[sName] = oJSON; if (sName == "__personal__") { browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "personal", oDict: oJSON}, dInfo: {} }); - } else { - // rebuild now? - //browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "community", oDict: oJSON}, dInfo: {} }); + } + else if (sName == "__community__") { + browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "community", oDict: oJSON}, dInfo: {} }); + } + else { + // TODO: merge sub-dictionaries } this.storeDictionaries(); }, storeDictionaries: function () { - browser.storage.local.set({ "oDictionaries": this.oDictionaries }); + browser.storage.local.set({ "dictionaries": this.oDictionaries }); } } const oBinaryDict = { oIBDAWG: null, sName: null, - load: function (sName="__personal__") { + load: function (sName) { + console.log("lexicon editor, load: " + sName); this.sName = sName; let oJSON = oDictHandler.getDictionary(sName); if (oJSON) { - console.log("parse"); this.parseDict(oJSON); } else { oLexiconTable.clear(); this.setDictData(0, "[néant]"); } @@ -602,20 +607,21 @@ showElement("export_button"); } }, listen: function () { + document.getElementById("dic_selector").addEventListener("change", () => {this.load(document.getElementById("dic_selector").value)}, false); document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false); document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false); document.getElementById("import_input").addEventListener("change", () => { this.import(); }, false); }, build: function () { let xProgressNode = document.getElementById("wait_progress"); let lEntry = oLexiconTable.getEntries(); if (lEntry.length > 0) { - let oDAWG = new DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel", xProgressNode); + let oDAWG = new DAWG(lEntry, "S", "fr", "Français", this.sName, xProgressNode); let oJSON = oDAWG.createBinaryJSON(1); oDictHandler.saveDictionary(this.sName, oJSON); this.oIBDAWG = new IBDAWG(oJSON); this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate); } else {