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 @@ -419,13 +419,27 @@ oIBDAWG: null, load: async function () { let sJSON = await oFileHandler.loadFile("fr.personal.json"); + this._load(sJSON); + }, + + _load: function (sJSON, bSave=false) { if (sJSON) { - let oJSON = JSON.parse(sJSON); - this.oIBDAWG = new IBDAWG(oJSON); + try { + let oJSON = JSON.parse(sJSON); + this.oIBDAWG = new IBDAWG(oJSON); + } + catch (e) { + this.setDictData(0, "#Erreur. Voir la console."); + console.error(e); + return; + } + if (bSave) { + oFileHandler.saveFile("fr.personal.json", JSON.stringify(oJSON)); + } let lEntry = []; for (let aRes of this.oIBDAWG.select()) { lEntry.push(aRes); } oLexiconTable.fill(lEntry); @@ -440,20 +454,11 @@ import: function () { oFileHandler.loadAs(this._import.bind(this)); }, _import: function (sJSON) { - if (sJSON) { - let oJSON = JSON.parse(sJSON); - this.oIBDAWG = new IBDAWG(oJSON); - oFileHandler.saveFile("fr.personal.json", JSON.stringify(oJSON)); - let lEntry = []; - for (let aRes of this.oIBDAWG.select()) { - lEntry.push(aRes); - } - oLexiconTable.fill(lEntry); - } + this._load(sJSON, true); }, setDictData: function (nEntries, sDate) { document.getElementById("dic_num_entries").value = nEntries; document.getElementById("dic_save_date").value = sDate;