Index: gc_lang/fr/tb/content/lex_editor.js ================================================================== --- gc_lang/fr/tb/content/lex_editor.js +++ gc_lang/fr/tb/content/lex_editor.js @@ -5,10 +5,15 @@ const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker."); +var FileUtils = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils + + + + /* Common functions */ @@ -44,14 +49,10 @@ } else { console.log("HTML node named <" + sElemId + "> not found.") } } - - -document.getElementById("save_button").addEventListener("click", () => { oBinaryDict.build(); }, false); - class Table { constructor (sNodeId, lColumn, lColumnWidth, sProgressBarId, sResultId="") { @@ -341,11 +342,13 @@ for (let [sFlexion, sFlexTags] of conj_generator.conjugate(this.sLemma, sVerbTag, bVarPpas)) { this.lFlexion.push([sFlexion, sFlexTags]); } } else { // copie du motif d’un autre verbe : utilisation du conjugueur + console.log("pattern: " + sVerbPattern); if (conj.isVerb(sVerbPattern)) { + console.log("yes"); let oVerb = new Verb(this.sLemma, sVerbPattern); for (let [sTag1, dFlex] of oVerb.dConj.entries()) { if (sTag1 !== ":Q") { for (let [sTag2, sConj] of dFlex.entries()) { if (sTag2.startsWith(":") && sConj !== "") { @@ -455,15 +458,16 @@ enableElement("export_button"); } }, setDictData: function (nEntries, sDate) { - document.getElementById("dic_num_entries").textContent = nEntries; - document.getElementById("dic_save_date").textContent = sDate; + document.getElementById("dic_num_entries").value = nEntries; + document.getElementById("dic_save_date").value = sDate; }, listen: function () { + document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false); document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false); //document.getElementById("import_button").addEventListener("click", () => { this.import(); }, false); }, build: function () { @@ -473,23 +477,27 @@ let oDAWG = new DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel", xProgressNode); let oJSON = oDAWG.createBinaryJSON(1); prefs.setCharPref("oPersonalDictionary", JSON.stringify(oJSON)); this.oIBDAWG = new IBDAWG(oJSON); this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate); - browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sType: "personal", oDict: oJSON}, dInfo: {} }); + //browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sType: "personal", oDict: oJSON}, dInfo: {} }); } enableElement("export_button"); }, import: function () { console.log("import"); }, export: function () { - let xBlob = new Blob([ JSON.stringify(this.oIBDAWG.getJSON()) ], {type: 'application/json'}); - let sURL = URL.createObjectURL(xBlob); - browser.downloads.download({ filename: "fr.personal.json", url: sURL, saveAs: true }); + let sJSON = JSON.stringify(this.oIBDAWG.getJSON()); + let xFile = new FileUtils.File("D:\\fr.personal.json"); + xFile.createUnique(FileUtils.NORMAL_FILE_TYPE, 555); + console.log(xFile); + let xFile2 = new File([ sJSON ], "D:\\fr.test.personal.json", {type: 'text/plain'}); + let sURL = URL.createObjectURL(xFile2); + console.log(xFile2); } } const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10],"progress_lexicon", "num_entries"); Index: gc_lang/fr/tb/content/lex_editor.xul ================================================================== --- gc_lang/fr/tb/content/lex_editor.xul +++ gc_lang/fr/tb/content/lex_editor.xul @@ -9,21 +9,20 @@ title="&window.title;" orient="vertical" buttons="cancel" buttonlabelcancel="&button.cancel.label;" ondialogcancel="return;" - defaultButton="cancel" width="500" onload="document.getElementById('grammalecte-lexicon-editor-window').centerWindowOnScreen();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">