Grammalecte  Check-in [657ac428bc]

Overview
Comment:[tb] lexicon editor: import dictionary (handle errors)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | multid
Files: files | file ages | folders
SHA3-256: 657ac428bc535949d76cc4357a6d844ac78eda23876a4115be1e59380e3daa8c
User & Date: olr on 2018-03-28 13:34:04
Other Links: branch diff | manifest | tags
Context
2018-03-28
18:35
[fx] lexicon editor: import dictionary check-in: b9f0eaf6cb user: olr tags: fx, multid
13:34
[tb] lexicon editor: import dictionary (handle errors) check-in: 657ac428bc user: olr tags: multid, tb
13:15
[tb] lexicon editor: import dictionary check-in: 81f4f65958 user: olr tags: multid, tb
Changes

Modified gc_lang/fr/tb/content/lex_editor.js from [f6cd059092] to [c35df544df].

417
418
419
420
421
422
423




424

425
426









427
428
429
430
431
432
433
...
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");
................................................................................
    },

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

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