Grammalecte  Diff

Differences From Artifact [f6cd059092]:

To Artifact [c35df544df]:


417
418
419
420
421
422
423




424

425
426









427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

const oBinaryDict = {
    
    oIBDAWG: null,

    load: async function () {
        let sJSON = await oFileHandler.loadFile("fr.personal.json");




        if (sJSON) {

            let oJSON = JSON.parse(sJSON);
            this.oIBDAWG = new IBDAWG(oJSON);









            let lEntry = [];
            for (let aRes of this.oIBDAWG.select()) {
                lEntry.push(aRes);
            }        
            oLexiconTable.fill(lEntry);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            enableElement("export_button");
        } else {
            this.setDictData(0, "[néant]");
            disableElement("export_button");
        }
    },

    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);
        }
    },

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },








>
>
>
>

>
|
|
>
>
>
>
>
>
>
>
>


















|
<
<
<
<
<
<
<
<
<







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459









460
461
462
463
464
465
466

const oBinaryDict = {
    
    oIBDAWG: null,

    load: async function () {
        let sJSON = await oFileHandler.loadFile("fr.personal.json");
        this._load(sJSON);
    },

    _load: function (sJSON, bSave=false) {
        if (sJSON) {
            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);
            this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
            enableElement("export_button");
        } else {
            this.setDictData(0, "[néant]");
            disableElement("export_button");
        }
    },

    import: function () {
        oFileHandler.loadAs(this._import.bind(this));
    },

    _import: function (sJSON) {
        this._load(sJSON, true);









    },

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },