Grammalecte  Check-in [96809cd8cd]

Overview
Comment:[fx][js] gc_panel revamping (part 2)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | kill_innerHTML
Files: files | file ages | folders
SHA3-256: 96809cd8cd69b244da98e8492c6a519215ee8e8aedb8a0ec31fa1fda9a0febff
User & Date: olr on 2017-07-13 17:30:18
Other Links: branch diff | manifest | tags
Context
2017-07-14
06:47
[fx][js] test_panel: remove innerHTML check-in: acf176c4b5 user: olr tags: fx, kill_innerHTML
2017-07-13
17:30
[fx][js] gc_panel revamping (part 2) check-in: 96809cd8cd user: olr tags: fx, kill_innerHTML
16:44
[fx][js] gc_panel revamping (part 1) check-in: a83903f529 user: olr tags: fx, kill_innerHTML
Changes

Modified gc_lang/fr/xpi/data/gc_panel.js from [6a9e1bc61d] to [1ad4be13a8].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
125
126
127
128
129
130
131
132
133
134

135
136
137

138
139
140
141
142
143
144
145
...
154
155
156
157
158
159
160













161
162
163
164
165
166
167
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
    addMessage(sClass, sText);
});

self.port.on("addParagraph", function (sText, iParagraph, sJSON) {
	addParagraph(sText, iParagraph, sJSON);
});

self.port.on("refreshParagraph", function (sIdParagr, sHtml) {
	document.getElementById("paragr"+sIdParagr).innerHTML = sHtml;
	let sClassName = (sHtml.includes('<u id="err')) ? "paragraph softred" : "paragraph softgreen";
	document.getElementById("paragr"+sIdParagr).className = sClassName;
});

self.port.on("showMessage", function (sText) {
	document.getElementById("message").textContent = sText;
	document.getElementById("messagebox").style.display = "block";
	window.setTimeout(closeMessageBox, 20000);
});
................................................................................
function addParagraph (sText, iParagraph, sJSON) {
	try {
		let xNodeDiv = document.createElement("div");
		xNodeDiv.className = "paragraph_block";
		// paragraph
		let xParagraph = document.createElement("p");
		xParagraph.id = "paragr" + iParagraph.toString();
		xParagraph.className = (true) ? "paragraph" : "paragraph softred";
		xParagraph.lang = "fr";
		xParagraph.style.spellchecker = "false";

		let oErrors = JSON.parse(sJSON);
		let aSpellErr = oErrors.aSpellErr;
		let aGrammErr = oErrors.aGrammErr;

		_tagParagraph(sText, xParagraph, iParagraph, aGrammErr, aSpellErr);
		xNodeDiv.appendChild(xParagraph);
		// actions
		let xDivActions = document.createElement("div");
		xDivActions.className = "actions";
		let xDivClose = document.createElement("div");
		xDivClose.id = "end" + iParagraph.toString();
		xDivClose.className = "button red";
................................................................................
		xDivCheck.textContent = "Réanalyser";
		xDivActions.appendChild(xDivClose);
		xDivActions.appendChild(xDivEdit);
		xDivActions.appendChild(xDivCheck);
		xNodeDiv.appendChild(xDivActions);
		document.getElementById("errorlist").appendChild(xNodeDiv);
	}













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

function _tagParagraph (sParagraph, xParagraph, iParagraph, aSpellErr, aGrammErr) {
	try {
................................................................................
	return xNodeErr;
}

function _getGrammarTooltip (oErr) {
	let xSpan = document.createElement("span");
	xSpan.id = "tooltip" + oErr['sId'];
	xSpan.className = "tooltip";
	xSpan.setAttribute("contenteditable", "false");
	xSpan.appendChild(document.createTextNode(oErr["sMessage"]+" "));
	xSpan.appendChild(_createIgnoreButton(oErr["sId"]));
	if (oErr["URL"] !== "") {
		xSpan.appendChild(_createInfoLink(oErr["URL"]));
	}
	if (oErr["aSuggestions"].length > 0) {
		xSpan.appendChild(document.createElement("br"));







|
|
<
<







 







<

<
>

<
<
>
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







41
42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
...
123
124
125
126
127
128
129

130

131
132


133
134
135
136
137
138
139
140
141
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    addMessage(sClass, sText);
});

self.port.on("addParagraph", function (sText, iParagraph, sJSON) {
	addParagraph(sText, iParagraph, sJSON);
});

self.port.on("refreshParagraph", function (sText, sIdParagr, sJSON) {
	refreshParagraph(sText, sIdParagr, sJSON);


});

self.port.on("showMessage", function (sText) {
	document.getElementById("message").textContent = sText;
	document.getElementById("messagebox").style.display = "block";
	window.setTimeout(closeMessageBox, 20000);
});
................................................................................
function addParagraph (sText, iParagraph, sJSON) {
	try {
		let xNodeDiv = document.createElement("div");
		xNodeDiv.className = "paragraph_block";
		// paragraph
		let xParagraph = document.createElement("p");
		xParagraph.id = "paragr" + iParagraph.toString();

		xParagraph.lang = "fr";

		xParagraph.setAttribute("spellcheck", false);
		let oErrors = JSON.parse(sJSON);


		xParagraph.className = (oErrors.aGrammErr.length || oErrors.aSpellErr.length) ? "paragraph softred" : "paragraph";
		_tagParagraph(sText, xParagraph, iParagraph, oErrors.aGrammErr, oErrors.aSpellErr);
		xNodeDiv.appendChild(xParagraph);
		// actions
		let xDivActions = document.createElement("div");
		xDivActions.className = "actions";
		let xDivClose = document.createElement("div");
		xDivClose.id = "end" + iParagraph.toString();
		xDivClose.className = "button red";
................................................................................
		xDivCheck.textContent = "Réanalyser";
		xDivActions.appendChild(xDivClose);
		xDivActions.appendChild(xDivEdit);
		xDivActions.appendChild(xDivCheck);
		xNodeDiv.appendChild(xDivActions);
		document.getElementById("errorlist").appendChild(xNodeDiv);
	}
	catch (e) {
		showError(e);
	}
}

function refreshParagraph (sText, sIdParagr, sJSON) {
	try {
		let xParagraph = document.getElementById("paragr"+sIdParagr);
		let oErrors = JSON.parse(sJSON);
		xParagraph.className = (oErrors.aGrammErr.length || oErrors.aSpellErr.length) ? "paragraph softred" : "paragraph softgreen";
		xParagraph.textContent = "";
		_tagParagraph(sText, xParagraph, sIdParagr, oErrors.aGrammErr, oErrors.aSpellErr);
	}
	catch (e) {
		showError(e);
	}
}

function _tagParagraph (sParagraph, xParagraph, iParagraph, aSpellErr, aGrammErr) {
	try {
................................................................................
	return xNodeErr;
}

function _getGrammarTooltip (oErr) {
	let xSpan = document.createElement("span");
	xSpan.id = "tooltip" + oErr['sId'];
	xSpan.className = "tooltip";
	xSpan.setAttribute("contenteditable", false);
	xSpan.appendChild(document.createTextNode(oErr["sMessage"]+" "));
	xSpan.appendChild(_createIgnoreButton(oErr["sId"]));
	if (oErr["URL"] !== "") {
		xSpan.appendChild(_createInfoLink(oErr["URL"]));
	}
	if (oErr["aSuggestions"].length > 0) {
		xSpan.appendChild(document.createElement("br"));

Modified gc_lang/fr/xpi/gce_worker.js from [b9ee777056] to [ca6bb30dca].

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

function parseAndSpellcheck (sText, sLang, bDebug, bContext) {
    let aGrammErr = gce.parse(sText, sLang, bDebug, bContext);
    let aSpellErr = oTokenizer.getSpellingErrors(sText, oDict);
    return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr });
}

function parseAndTag (sText, iParagraph, sLang, bDebug) {
    sText = text.addHtmlEntities(sText);
    let aGrammErr = gce.parse(sText, sLang, bDebug);
    let aSpellErr = oTokenizer.getSpellingErrors(sText, oDict);
    let sHtml = text.tagParagraph(sText, iParagraph, aGrammErr, aSpellErr);
    return sHtml;
}

function parseAndGenerateParagraph (sText, iParagraph, sLang, bDebug) {
    return text.createHTMLBlock(parseAndTag(sText, iParagraph, sLang, bDebug), iParagraph);
}

function getOptions () {
    return gce.getOptions()._toString();
}

function getDefaultOptions () {
    return gce.getDefaultOptions()._toString();
}







<
<
<
<
<
<
<
<
<
<
<
<







86
87
88
89
90
91
92












93
94
95
96
97
98
99

function parseAndSpellcheck (sText, sLang, bDebug, bContext) {
    let aGrammErr = gce.parse(sText, sLang, bDebug, bContext);
    let aSpellErr = oTokenizer.getSpellingErrors(sText, oDict);
    return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr });
}













function getOptions () {
    return gce.getOptions()._toString();
}

function getDefaultOptions () {
    return gce.getDefaultOptions()._toString();
}

Modified gc_lang/fr/xpi/ui.js from [f61d089690] to [14a4e0411e].

345
346
347
348
349
350
351
352
353
354

355
356
357
358
359
360
361
362
    if (sText.includes("<!-- err_end -->") || sText.includes('<span id="tooltip') || sText.includes('<u id="err')) {
        return false;
    }
    return true;
}

function checkAndSendToPanel (sIdParagraph, sText) {
    let xPromise = xGCEWorker.post('parseAndTag', [sText, parseInt(sIdParagraph), "FR", false]);
    xPromise.then(
        function (aVal) {

            xGCPanel.port.emit("refreshParagraph", sIdParagraph, aVal);
        },
        function (aReason) {
            console.error('Promise rejected - ', aReason);
        }
    ).catch(
        function (aCaught) {
            console.error('Promise Error - ', aCaught);







|


>
|







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
    if (sText.includes("<!-- err_end -->") || sText.includes('<span id="tooltip') || sText.includes('<u id="err')) {
        return false;
    }
    return true;
}

function checkAndSendToPanel (sIdParagraph, sText) {
    let xPromise = xGCEWorker.post('parseAndSpellcheck', [sText, "FR", false, false]);
    xPromise.then(
        function (aVal) {
            sText = text.addHtmlEntities(sText);
            xGCPanel.port.emit("refreshParagraph", sText, sIdParagraph, aVal);
        },
        function (aReason) {
            console.error('Promise rejected - ', aReason);
        }
    ).catch(
        function (aCaught) {
            console.error('Promise Error - ', aCaught);