Grammalecte  Check-in [5bfb5a6c67]

Overview
Comment:[fx] recheck paragraph after applying suggestion
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext2
Files: files | file ages | folders
SHA3-256: 5bfb5a6c67fa581c66491c74ffb91ca5a3c61b47a3408e37299952b3bb45937a
User & Date: olr on 2017-08-22 09:34:26
Other Links: branch diff | manifest | tags
Context
2017-08-22
12:27
[fx] modify textarea content while typing check-in: a2a19392b6 user: olr tags: fx, webext2
09:34
[fx] recheck paragraph after applying suggestion check-in: 5bfb5a6c67 user: olr tags: fx, webext2
08:02
[fx] textarea control + small code refactoring check-in: 40e9aa097d user: olr tags: fx, webext2
Changes

Modified gc_lang/fr/webext/content_scripts/content_modifier.js from [4e0ba04476] to [c652fb3252].

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
function createGCPanel () {
    console.log("Correction grammaticale");
    if (oGCPanel !== null) {
        oGCPanelContent.clear();
        oGCPanel.show();
    } else {
        // create the panel
        oGCPanel = new GrammalectePanel("grammalecte_gc_panel", "Correcteur", 500, 700);
        oGCPanel.setContentNode(oGCPanelContent.init());
        oGCPanel.insertIntoPage();
    }
}


/*







|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
function createGCPanel () {
    console.log("Correction grammaticale");
    if (oGCPanel !== null) {
        oGCPanelContent.clear();
        oGCPanel.show();
    } else {
        // create the panel
        oGCPanel = new GrammalectePanel("grammalecte_gc_panel", "Grammalecte", 500, 700);
        oGCPanel.setContentNode(oGCPanelContent.init());
        oGCPanel.insertIntoPage();
    }
}


/*

Modified gc_lang/fr/webext/content_scripts/gc_content.js from [da49634b64] to [12bc7392df].

97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
        }
        catch (e) {
            showError(e);
        }
    },

    recheckParagraph: function (sParagraphNum) {
        //startWaitIcon();
        let sParagraphId = "grammalecte_paragraph" + sParagraphNum;
        let xParagraph = document.getElementById(sParagraphId);

        let sText = this.getPurgedTextOfParagraph(xParagraph.textContent);
        xPort.postMessage({
            sCommand: "parseAndSpellcheck1",
            dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
            dInfo: {sParagraphId: sParagraphId}
        });
        this.oTAC.setParagraph(parseInt(sParagraphNum), sText);
        this.oTAC.write();
        //stopWaitIcon();
    },

    refreshParagraph: function (sParagraphId, oResult) {
        try {
            let xParagraph = document.getElementById(sParagraphId);
            xParagraph.className = (oResult.aGrammErr.length || oResult.aSpellErr.length) ? "grammalecte_paragraph softred" : "grammalecte_paragraph";
            xParagraph.textContent = "";
            this._tagParagraph(xParagraph, oResult.sParagraph, sParagraphId.slice(21), oResult.aGrammErr, oResult.aSpellErr);

        }
        catch (e) {
            showError(e);
        }
    },

    _tagParagraph: function (xParagraph, sParagraph, sParaNum, aSpellErr, aGrammErr) {







<


>

















>







97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
        }
        catch (e) {
            showError(e);
        }
    },

    recheckParagraph: function (sParagraphNum) {

        let sParagraphId = "grammalecte_paragraph" + sParagraphNum;
        let xParagraph = document.getElementById(sParagraphId);
        this.blockParagraph(xParagraph);
        let sText = this.getPurgedTextOfParagraph(xParagraph.textContent);
        xPort.postMessage({
            sCommand: "parseAndSpellcheck1",
            dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
            dInfo: {sParagraphId: sParagraphId}
        });
        this.oTAC.setParagraph(parseInt(sParagraphNum), sText);
        this.oTAC.write();
        //stopWaitIcon();
    },

    refreshParagraph: function (sParagraphId, oResult) {
        try {
            let xParagraph = document.getElementById(sParagraphId);
            xParagraph.className = (oResult.aGrammErr.length || oResult.aSpellErr.length) ? "grammalecte_paragraph softred" : "grammalecte_paragraph";
            xParagraph.textContent = "";
            this._tagParagraph(xParagraph, oResult.sParagraph, sParagraphId.slice(21), oResult.aGrammErr, oResult.aSpellErr);
            this.freeParagraph(xParagraph);
        }
        catch (e) {
            showError(e);
        }
    },

    _tagParagraph: function (xParagraph, sParagraph, sParaNum, aSpellErr, aGrammErr) {
182
183
184
185
186
187
188











189
190
191
192
193
194
195
196
197
198
199
200

201
202
203
204
205
206
207
                xNodeErr.dataset.rule_id = oErr['sRuleId'];
            }
            xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");
        }
        xNodeErr.className = (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) ? "ignored" : "error " + oErr['sType'];
        return xNodeErr;
    },












    applySuggestion: function (sNodeSuggId) { // sugg
        try {
            console.log(sNodeSuggId);
            let sErrorId = document.getElementById(sNodeSuggId).dataset.error_id;
            //let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
            console.log("grammalecte_err"+sErrorId);
            let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
            xNodeErr.textContent = document.getElementById(sNodeSuggId).textContent;
            xNodeErr.className = "corrected";
            xNodeErr.removeAttribute("style");
            this.oTooltip.hide();

        }
        catch (e) {
            showError(e);
        }
    },

    ignoreError: function (sIgnoreButtonId) {  // ignore







>
>
>
>
>
>
>
>
>
>
>












>







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
                xNodeErr.dataset.rule_id = oErr['sRuleId'];
            }
            xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");
        }
        xNodeErr.className = (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) ? "ignored" : "error " + oErr['sType'];
        return xNodeErr;
    },

    blockParagraph: function (xParagraph) {
        xParagraph.style = "background-color: hsl(30, 100%, 80%)";
        xParagraph.disabled = true;
        xParagraph.contentEditable = "false";
    },

    freeParagraph: function (xParagraph) {
        xParagraph.style = "";
        xParagraph.contentEditable = "true";
    },

    applySuggestion: function (sNodeSuggId) { // sugg
        try {
            console.log(sNodeSuggId);
            let sErrorId = document.getElementById(sNodeSuggId).dataset.error_id;
            //let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
            console.log("grammalecte_err"+sErrorId);
            let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
            xNodeErr.textContent = document.getElementById(sNodeSuggId).textContent;
            xNodeErr.className = "corrected";
            xNodeErr.removeAttribute("style");
            this.oTooltip.hide();
            this.recheckParagraph(sErrorId.slice(0, sErrorId.indexOf("-")));
        }
        catch (e) {
            showError(e);
        }
    },

    ignoreError: function (sIgnoreButtonId) {  // ignore