Revision: 8907
http://languagetool.svn.sourceforge.net/languagetool/?rev=8907&view=rev
Author: dnaber
Date: 2013-01-06 21:32:57 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
online check: prevent overlapping errors
Modified Paths:
--------------
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js
Modified:
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
===================================================================
---
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
2013-01-06 21:15:12 UTC (rev 8906)
+++
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
2013-01-06 21:32:57 UTC (rev 8907)
@@ -221,6 +221,8 @@
}
}
var newString = cleanNodeValue;
+ var previousSpanStart = -1;
+ // as we modify the string we work backwards so we don't mess with
the positions:
for (var suggestionIndex = parent.suggestions.length-1;
suggestionIndex >= 0; suggestionIndex--) {
var suggestion = parent.suggestions[suggestionIndex];
if (!suggestion.used) {
@@ -232,6 +234,12 @@
var spanStart = suggestionStart - currentNodeStart;
//console.log("pos: " + pos + ", spanStart: " +
suggestionStart + " - " + currentNodeStart + " + 1 => " + spanStart);
var spanEnd = suggestionEnd - currentNodeStart;
+ if (previousSpanStart != -1 && spanEnd >=
previousSpanStart) {
+ // overlapping errors - these are not supported by
our underline approach,
+ // as we would need overlapping <span>s for that,
so skip the error:
+ continue;
+ }
+ previousSpanStart = spanStart;
var urlAttribute = "";
if (suggestion.moreinfo) {
urlAttribute = ' url="' + suggestion.moreinfo +
'"';
@@ -245,7 +253,6 @@
else {
cssName = "hiddenGrammarError";
}
-
newString = newString.substring(0, spanStart)
+ '<span class="' + cssName + '" desc="' +
suggestion.description
+ '" suggestions="' + suggestion.suggestions +
'"'
Modified:
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js
===================================================================
--- trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js
2013-01-06 21:15:12 UTC (rev 8906)
+++ trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js
2013-01-06 21:32:57 UTC (rev 8907)
@@ -221,6 +221,8 @@
}
}
var newString = cleanNodeValue;
+ var previousSpanStart = -1;
+ // as we modify the string we work backwards so we don't mess with
the positions:
for (var suggestionIndex = parent.suggestions.length-1;
suggestionIndex >= 0; suggestionIndex--) {
var suggestion = parent.suggestions[suggestionIndex];
if (!suggestion.used) {
@@ -232,6 +234,12 @@
var spanStart = suggestionStart - currentNodeStart;
//console.log("pos: " + pos + ", spanStart: " +
suggestionStart + " - " + currentNodeStart + " + 1 => " + spanStart);
var spanEnd = suggestionEnd - currentNodeStart;
+ if (previousSpanStart != -1 && spanEnd >=
previousSpanStart) {
+ // overlapping errors - these are not supported by
our underline approach,
+ // as we would need overlapping <span>s for that,
so skip the error:
+ continue;
+ }
+ previousSpanStart = spanStart;
var urlAttribute = "";
if (suggestion.moreinfo) {
urlAttribute = ' url="' + suggestion.moreinfo +
'"';
@@ -245,7 +253,6 @@
else {
cssName = "hiddenGrammarError";
}
-
newString = newString.substring(0, spanStart)
+ '<span class="' + cssName + '" desc="' +
suggestion.description
+ '" suggestions="' + suggestion.suggestions +
'"'
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits