Grammalecte  Diff

Differences From Artifact [83999992e4]:

To Artifact [2251620d6f]:


558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590


591
592
593
594
595
596

597
598
599
600
601
602
603
604
605




606
607
608
609
610
611


612
613
614
615
616
617
618
619

620
621
622
623
624
625
558
559
560
561
562
563
564

565
566
567
568
569
570

571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586


587
588
589
590
591
592
593

594
595
596
597
598
599
600
601


602
603
604
605
606
607
608
609


610
611
612
613
614
615
616
617
618

619
620
621
622
623
624
625







-






-
















-
-
+
+





-
+







-
-
+
+
+
+




-
-
+
+







-
+






    save: function () {
        oWidgets.hideElement("save_button");
        this.lFlexion = this.lFlexion.filter((e) => e !== null);
        oBinaryDict.build(this.lFlexion);
        this.resetModif();
        oWidgets.displayTable(this.lFlexion);
        oWidgets.updateData();
        oWidgets.setDictData(this.lFlexion.length, this._getDate());
    }
}


const oBinaryDict = {
    
    oJSON: null,
    oIBDAWG: null,

    load: function () {
        if (bChrome) {
            browser.storage.local.get("oDictionary", this._load);
            return;
        }
        let xPromise = browser.storage.local.get("oDictionary");
        xPromise.then(this._load.bind(this), showError);
    },

    _load: function (oResult) {
        if (!oResult.hasOwnProperty("oDictionary")) {
            oWidgets.hideElement("export_button");
            return;
        }
        this.oJSON = oResult.oDictionary;
        this.oIBDAWG = new IBDAWG(this.oJSON);
        let oJSON = oResult.oDictionary;
        this.oIBDAWG = new IBDAWG(oJSON);
        let lEntry = [];
        for (let s of this.oIBDAWG.select()) {
            lEntry.push(s.split("\t"));
        }        
        oLexicon.set(lEntry);
        oWidgets.setDictData(lEntry.length, oJSON.sDate);
        oWidgets.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
        oWidgets.showElement("export_button");
    },

    build: function (lEntry) {
        oWidgets.showElement("build_progress");
        let xProgressNode = document.getElementById("build_progress");
        let oDAWG = new DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel", xProgressNode);
        this.oJSON = oDAWG.createBinary(1);
        this.save();
        let oJSON = oDAWG.createBinaryJSON(1);
        this.save(oJSON);
        this.oIBDAWG = new IBDAWG(oJSON);
        oWidgets.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate);
        oWidgets.hideElement("build_progress");
        oWidgets.showElement("export_button");
    },

    save: function () {
        browser.storage.local.set({ "oDictionary": this.oJSON });
    save: function (oJSON) {
        browser.storage.local.set({ "oDictionary": oJSON });
    },

    import: function () {
        // TO DO
    },

    export: function () {
        let xBlob = new Blob([ JSON.stringify(this.oJSON) ], {type: 'application/json'}); 
        let xBlob = new Blob([ JSON.stringify(this.oIBDAWG.getJSON()) ], {type: 'application/json'}); 
        let sURL = URL.createObjectURL(xBlob);
        browser.downloads.download({ filename: "grammalecte_dictionnaire_personnel.json", url: sURL, saveAs: true });
    }
}

oBinaryDict.load();