Revision: 8902
http://languagetool.svn.sourceforge.net/languagetool/?rev=8902&view=rev
Author: dnaber
Date: 2013-01-06 18:26:02 +0000 (Sun, 06 Jan 2013)
Log Message:
-----------
more cleanup
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 17:53:40 UTC (rev 8901)
+++
trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/editor_plugin.js
2013-01-06 18:26:02 UTC (rev 8902)
@@ -1,9 +1,12 @@
/*
* atd.core.js - A building block to create a front-end for AtD
- * Author : Raphael Mudge, Automattic
+ * Author : Raphael Mudge, Automattic; Daniel Naber, LanguageTool.org
* License : LGPL
* Project : http://www.afterthedeadline.com/developers.slp
* Contact : [email protected]
+ *
+ * Note: this has been simplified for use with LanguageTool - it now assumes
there's no markup
+ * anymore in the text field (not even bold etc)!
*/
/* EXPORTED_SYMBOLS is set so this file can be a JavaScript Module */
@@ -11,14 +14,13 @@
function AtDCore() {
/* these are the categories of errors AtD should ignore */
- this.ignore_types = ['Bias Language', 'Cliches', 'Complex Expression',
'Diacritical Marks', 'Double Negatives', 'Hidden Verbs', 'Jargon Language',
'Passive voice', 'Phrases to Avoid', 'Redundant Expression'];
+ this.ignore_types = [];
/* these are the phrases AtD should ignore */
this.ignore_strings = {};
/* Localized strings */
this.i18n = {};
-
};
/*
@@ -162,7 +164,7 @@
// source: http://simonwillison.net/2006/Jan/20/escape/ (modified to not
escape \s)
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
-}
+};
AtDCore.prototype.processXML = function(responseXML) {
@@ -220,12 +222,12 @@
else
errorStruct = undefined;
- console.log("######" + errorStruct);
- console.log("######" + this.suggestions);
- console.log("######ecount: " + ecount);
+ //console.log("######" + errorStruct);
+ //console.log("######" + this.suggestions);
+ //console.log("######ecount: " + ecount);
return { errors: errorStruct, count: ecount, suggestions: this.suggestions
};
-}
+};
// Wrapper code by James Padolsey
// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/
@@ -241,7 +243,7 @@
var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' :
'|\\S+?(\\s|$)');
return str.match( RegExp(regex, 'g') ).join( brk );
-}
+};
// End of wrapper code by James Padolsey
AtDCore.prototype.findSuggestion = function(element) {
@@ -351,20 +353,13 @@
var nodeValue = n.nodeValue;
//console.log("##------------------------------");
//console.log("##nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ", type: " + n.nodeType + ")");
-
var i;
var cleanNodeValue = "";
for (i = 0; i < nodeValue.length; i++) {
- if (nodeValue.charCodeAt(i) != 65279) {
+ if (nodeValue.charCodeAt(i) != 65279) { // cursor has its
own node, ignore it
cleanNodeValue += nodeValue.charAt(i);
}
}
- //console.log("#>nodeValue: '" + cleanNodeValue + "' (len: " +
cleanNodeValue.length + ")");
- //console.log("##nodeValue: " + nodeValue + ", pos=" + pos + ",
result " + result);
- //console.log("##suggestions.length: " +
parent.suggestions.length);
- //console.log("##errors.length: " + errors.length);
-
- //var newNode;
var newString = cleanNodeValue;
for (var suggestionIndex = parent.suggestions.length-1;
suggestionIndex >= 0; suggestionIndex--) {
var suggestion = parent.suggestions[suggestionIndex];
@@ -373,19 +368,10 @@
var currentNodeEnd = pos + nodeValue.length;
var suggestionStart = parseInt(suggestion.offset);
var suggestionEnd = suggestionStart +
parseInt(suggestion.errorlength);
- //console.log("##suggestion desc: " +
suggestion.description);
- //console.log("##suggestion offset: " + suggestion.offset
+ ", len: " + suggestion.errorlength);
- //console.log("##currentNodeStart/currentNodeEnd: " +
currentNodeStart + ", " + currentNodeEnd);
- //console.log("##: " + suggestion.offset + ">=" +
currentNodeStart + " ... " + suggestionEnd +"<="+ currentNodeEnd);
if (suggestionStart >= currentNodeStart && suggestionEnd
<= currentNodeEnd) {
var spanStart = suggestionStart - currentNodeStart;
//console.log("pos: " + pos + ", spanStart: " +
suggestionStart + " - " + currentNodeStart + " + 1 => " + spanStart);
var spanEnd = suggestionEnd - currentNodeStart;
- //console.log("##spanStart/end: " + spanStart + ", " +
spanEnd);
- /*if (newNode) {
- console.log("##newNode: " + newNode.nodeValue);
- }*/
- //console.log("#################: " +
suggestion.moreinfo);
var urlAttribute = "";
if (suggestion.moreinfo) {
urlAttribute = ' url="' + suggestion.moreinfo +
'"';
@@ -406,21 +392,9 @@
var newNode = parent.create(newString, false);
//console.log("##newString: '" + newString + "'");
parent.replaceWith(n, newNode);
-
- /*for (var key in errors) {
- var error = errors[key];
- if (!error.used) {
- error.used = true;
- console.log("##error: " + error.offset + ", l: " +
error.errorlength);
- }
- }*/
- //console.log("##nodeValue: " + nodeValue + ", pos=" + pos);
- //pos += nodeValue.length;
pos += cleanNodeValue.length;
- //console.log("##POS: " + pos + " len " + nodeValue.length + " for
'" + nodeValue + "' w/ code " + nodeValue.charCodeAt());
- //var newNode = parent.create(nodeValue.replace(regExp, '<span
class="hiddenGrammarError">$&</span>'), false);
} else {
- console.log("##IGNORED nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ")");
+ //console.log("##IGNORED nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ")");
}
});
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 17:53:40 UTC (rev 8901)
+++ trunk/website/www/online-check/tiny_mce/plugins/atd-tinymce/src/atd.core.js
2013-01-06 18:26:02 UTC (rev 8902)
@@ -1,9 +1,12 @@
/*
* atd.core.js - A building block to create a front-end for AtD
- * Author : Raphael Mudge, Automattic
+ * Author : Raphael Mudge, Automattic; Daniel Naber, LanguageTool.org
* License : LGPL
* Project : http://www.afterthedeadline.com/developers.slp
* Contact : [email protected]
+ *
+ * Note: this has been simplified for use with LanguageTool - it now assumes
there's no markup
+ * anymore in the text field (not even bold etc)!
*/
/* EXPORTED_SYMBOLS is set so this file can be a JavaScript Module */
@@ -11,14 +14,13 @@
function AtDCore() {
/* these are the categories of errors AtD should ignore */
- this.ignore_types = ['Bias Language', 'Cliches', 'Complex Expression',
'Diacritical Marks', 'Double Negatives', 'Hidden Verbs', 'Jargon Language',
'Passive voice', 'Phrases to Avoid', 'Redundant Expression'];
+ this.ignore_types = [];
/* these are the phrases AtD should ignore */
this.ignore_strings = {};
/* Localized strings */
this.i18n = {};
-
};
/*
@@ -162,7 +164,7 @@
// source: http://simonwillison.net/2006/Jan/20/escape/ (modified to not
escape \s)
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
-}
+};
AtDCore.prototype.processXML = function(responseXML) {
@@ -220,12 +222,12 @@
else
errorStruct = undefined;
- console.log("######" + errorStruct);
- console.log("######" + this.suggestions);
- console.log("######ecount: " + ecount);
+ //console.log("######" + errorStruct);
+ //console.log("######" + this.suggestions);
+ //console.log("######ecount: " + ecount);
return { errors: errorStruct, count: ecount, suggestions: this.suggestions
};
-}
+};
// Wrapper code by James Padolsey
// Source: http://james.padolsey.com/javascript/wordwrap-for-javascript/
@@ -241,7 +243,7 @@
var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' :
'|\\S+?(\\s|$)');
return str.match( RegExp(regex, 'g') ).join( brk );
-}
+};
// End of wrapper code by James Padolsey
AtDCore.prototype.findSuggestion = function(element) {
@@ -351,20 +353,13 @@
var nodeValue = n.nodeValue;
//console.log("##------------------------------");
//console.log("##nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ", type: " + n.nodeType + ")");
-
var i;
var cleanNodeValue = "";
for (i = 0; i < nodeValue.length; i++) {
- if (nodeValue.charCodeAt(i) != 65279) {
+ if (nodeValue.charCodeAt(i) != 65279) { // cursor has its
own node, ignore it
cleanNodeValue += nodeValue.charAt(i);
}
}
- //console.log("#>nodeValue: '" + cleanNodeValue + "' (len: " +
cleanNodeValue.length + ")");
- //console.log("##nodeValue: " + nodeValue + ", pos=" + pos + ",
result " + result);
- //console.log("##suggestions.length: " +
parent.suggestions.length);
- //console.log("##errors.length: " + errors.length);
-
- //var newNode;
var newString = cleanNodeValue;
for (var suggestionIndex = parent.suggestions.length-1;
suggestionIndex >= 0; suggestionIndex--) {
var suggestion = parent.suggestions[suggestionIndex];
@@ -373,19 +368,10 @@
var currentNodeEnd = pos + nodeValue.length;
var suggestionStart = parseInt(suggestion.offset);
var suggestionEnd = suggestionStart +
parseInt(suggestion.errorlength);
- //console.log("##suggestion desc: " +
suggestion.description);
- //console.log("##suggestion offset: " + suggestion.offset
+ ", len: " + suggestion.errorlength);
- //console.log("##currentNodeStart/currentNodeEnd: " +
currentNodeStart + ", " + currentNodeEnd);
- //console.log("##: " + suggestion.offset + ">=" +
currentNodeStart + " ... " + suggestionEnd +"<="+ currentNodeEnd);
if (suggestionStart >= currentNodeStart && suggestionEnd
<= currentNodeEnd) {
var spanStart = suggestionStart - currentNodeStart;
//console.log("pos: " + pos + ", spanStart: " +
suggestionStart + " - " + currentNodeStart + " + 1 => " + spanStart);
var spanEnd = suggestionEnd - currentNodeStart;
- //console.log("##spanStart/end: " + spanStart + ", " +
spanEnd);
- /*if (newNode) {
- console.log("##newNode: " + newNode.nodeValue);
- }*/
- //console.log("#################: " +
suggestion.moreinfo);
var urlAttribute = "";
if (suggestion.moreinfo) {
urlAttribute = ' url="' + suggestion.moreinfo +
'"';
@@ -406,21 +392,9 @@
var newNode = parent.create(newString, false);
//console.log("##newString: '" + newString + "'");
parent.replaceWith(n, newNode);
-
- /*for (var key in errors) {
- var error = errors[key];
- if (!error.used) {
- error.used = true;
- console.log("##error: " + error.offset + ", l: " +
error.errorlength);
- }
- }*/
- //console.log("##nodeValue: " + nodeValue + ", pos=" + pos);
- //pos += nodeValue.length;
pos += cleanNodeValue.length;
- //console.log("##POS: " + pos + " len " + nodeValue.length + " for
'" + nodeValue + "' w/ code " + nodeValue.charCodeAt());
- //var newNode = parent.create(nodeValue.replace(regExp, '<span
class="hiddenGrammarError">$&</span>'), false);
} else {
- console.log("##IGNORED nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ")");
+ //console.log("##IGNORED nodeValue: '" + nodeValue + "' (len: " +
nodeValue.length + ")");
}
});
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