/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellerStyle.css |
---|
46,4 → 46,4 |
width:200px; |
margin-top:2; |
font-size:8pt; |
} |
} |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/wordWindow.js |
---|
12,7 → 12,7 |
this._adjustIndexes = _adjustIndexes; |
this._isWordChar = _isWordChar; |
this._lastPos = _lastPos; |
// public properties |
this.wordChar = /[a-zA-Z]/; |
this.windowType = "wordWindow"; |
69,7 → 69,7 |
break; |
} else { |
total_words++; |
} |
} |
} |
} |
return total_words; |
115,17 → 115,17 |
var oldText = word.value; |
// update the text given the index of the string |
beginStr = this.textInputs[textIndex].substring( 0, pos ); |
endStr = this.textInputs[textIndex].substring( |
pos + oldText.length, |
this.textInputs[textIndex].length |
endStr = this.textInputs[textIndex].substring( |
pos + oldText.length, |
this.textInputs[textIndex].length |
); |
this.textInputs[textIndex] = beginStr + newText + endStr; |
// adjust the indexes on the stack given the differences in |
// length between the new word and old word. |
// adjust the indexes on the stack given the differences in |
// length between the new word and old word. |
var lengthDiff = newText.length - oldText.length; |
this._adjustIndexes( textIndex, wordIndex, lengthDiff ); |
word.size = newText.length; |
word.value = newText; |
this.removeFocus( textIndex, wordIndex ); |
140,39 → 140,39 |
d.open(); |
// iterate through each text input. |
for( var txtid = 0; txtid < this.textInputs.length; txtid++ ) { |
for( var txtid = 0; txtid < this.textInputs.length; txtid++ ) { |
var end_idx = 0; |
var begin_idx = 0; |
var begin_idx = 0; |
d.writeln( '<form name="textInput'+txtid+'">' ); |
var wordtxt = this.textInputs[txtid]; |
this.indexes[txtid] = []; |
if( wordtxt ) { |
if( wordtxt ) { |
var orig = this.originalSpellings[txtid]; |
if( !orig ) break; |
//!!! plain text, or HTML mode? |
d.writeln( '<div class="plainText">' ); |
// iterate through each occurrence of a misspelled word. |
// iterate through each occurrence of a misspelled word. |
for( var i = 0; i < orig.length; i++ ) { |
// find the position of the current misspelled word, |
// starting at the last misspelled word. |
// starting at the last misspelled word. |
// and keep looking if it's a substring of another word |
do { |
begin_idx = wordtxt.indexOf( orig[i], end_idx ); |
end_idx = begin_idx + orig[i].length; |
// word not found? messed up! |
if( begin_idx == -1 ) break; |
// look at the characters immediately before and after |
if( begin_idx == -1 ) break; |
// look at the characters immediately before and after |
// the word. If they are word characters we'll keep looking. |
var before_char = wordtxt.charAt( begin_idx - 1 ); |
var after_char = wordtxt.charAt( end_idx ); |
} while ( |
this._isWordChar( before_char ) |
} while ( |
this._isWordChar( before_char ) |
|| this._isWordChar( after_char ) |
); |
// keep track of its position in the original text. |
// keep track of its position in the original text. |
this.indexes[txtid][i] = begin_idx; |
// write out the characters before the current misspelled word |
181,17 → 181,17 |
d.write( this.printForHtml( wordtxt.charAt( j ))); |
} |
// write out the misspelled word. |
// write out the misspelled word. |
d.write( this._wordInputStr( orig[i] )); |
// if it's the last word, write out the rest of the text |
if( i == orig.length-1 ){ |
d.write( printForHtml( wordtxt.substr( end_idx ))); |
} |
} |
} |
d.writeln( '</div>' ); |
} |
d.writeln( '</form>' ); |
} |
200,8 → 200,8 |
// for( var k = 0; k < d.forms[j].elements.length; k++ ) { |
// alert( d.forms[j].elements[k].name + ": " + d.forms[j].elements[k].value ); |
// } |
//} |
//} |
// set the _forms property |
this._forms = d.forms; |
d.close(); |
217,7 → 217,7 |
function printForHtml( n ) { |
return n ; // by FredCK |
/* |
var htmlstr = n; |
if( htmlstr.length == 1 ) { |
// do simple case statement if it's just one character |
239,6 → 239,7 |
htmlstr = htmlstr.replace( /\n/g, '<br/>' ); |
return htmlstr; |
} |
*/ |
} |
function _isWordChar( letter ) { |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js |
---|
19,7 → 19,6 |
// this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; // by FredCK |
this.popUpProps = null ; // by FredCK |
// this.spellCheckScript = '/speller/server-scripts/spellchecker.php'; // by FredCK |
this.spellCheckScript = 'server-scripts/spellchecker.php'; // by FredCK |
//this.spellCheckScript = '/cgi-bin/spellchecker.pl'; |
// values used to keep track of what happened to a word |
37,7 → 36,7 |
this.controlWin = null; |
this.wordWin = null; |
this.textArea = textObject; // deprecated |
this.textInputs = arguments; |
this.textInputs = arguments; |
// private methods |
this._spellcheck = _spellcheck; |
97,7 → 96,7 |
// set properties from args |
this.wordWin = wordWindowObj; |
this.controlWin = controlWindowObj; |
// reset properties |
this.wordWin.resetForm(); |
this.controlWin.resetForm(); |
112,7 → 111,7 |
// start |
this._spellcheck(); |
return true; |
} |
132,6 → 131,7 |
this.currentWordIndex++; |
this._spellcheck(); |
} |
return true; |
} |
function ignoreAll() { |
148,7 → 148,7 |
return false; |
} |
// set this word as an "ignore all" word. |
// set this word as an "ignore all" word. |
this._setAsIgnored( ti, wi, this.ignrAllFlag ); |
// loop through all the words after this word |
156,7 → 156,7 |
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
if(( i == ti && j > wi ) || i > ti ) { |
// future word: set as "from ignore all" if |
// 1) do not already have a flag and |
// 1) do not already have a flag and |
// 2) have the same value as current word |
if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) |
&& ( !this.wordFlags[i][j] )) { |
169,6 → 169,7 |
// finally, move on |
this.currentWordIndex++; |
this._spellcheck(); |
return true; |
} |
function replaceWord() { |
183,7 → 184,7 |
return false; |
} |
if( !this.controlWin.replacementText ) { |
return; |
return false ; |
} |
var txt = this.controlWin.replacementText; |
if( txt.value ) { |
193,6 → 194,7 |
this._spellcheck(); |
} |
} |
return true; |
} |
function replaceAll() { |
208,10 → 210,10 |
return false; |
} |
var txt = this.controlWin.replacementText; |
if( !txt.value ) return; |
if( !txt.value ) return false; |
var newspell = new String( txt.value ); |
// set this word as a "replace all" word. |
// set this word as a "replace all" word. |
this._setWordText( ti, wi, newspell, this.replAllFlag ); |
// loop through all the words after this word |
219,7 → 221,7 |
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
if(( i == ti && j > wi ) || i > ti ) { |
// future word: set word text to s_word_to_repl if |
// 1) do not already have a flag and |
// 1) do not already have a flag and |
// 2) have the same value as s_word_to_repl |
if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) |
&& ( !this.wordFlags[i][j] )) { |
228,10 → 230,11 |
} |
} |
} |
// finally, move on |
this.currentWordIndex++; |
this._spellcheck(); |
return true; |
} |
function terminateSpell() { |
286,12 → 289,12 |
function undo() { |
// skip if this is the first word! |
var ti = this.currentTextIndex; |
var wi = this.currentWordIndex |
var wi = this.currentWordIndex; |
if( this.wordWin.totalPreviousWords( ti, wi ) > 0 ) { |
this.wordWin.removeFocus( ti, wi ); |
// go back to the last word index that was acted upon |
// go back to the last word index that was acted upon |
do { |
// if the current word index is zero then reset the seed |
if( this.currentWordIndex == 0 && this.currentTextIndex > 0 ) { |
303,30 → 306,31 |
this.currentWordIndex--; |
} |
} |
} while ( |
} while ( |
this.wordWin.totalWords( this.currentTextIndex ) == 0 |
|| this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromIgnrAll |
|| this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromReplAll |
); |
); |
var text_idx = this.currentTextIndex; |
var idx = this.currentWordIndex; |
var preReplSpell = this.wordWin.originalSpellings[text_idx][idx]; |
// if we got back to the first word then set the Undo button back to disabled |
if( this.wordWin.totalPreviousWords( text_idx, idx ) == 0 ) { |
this.controlWin.disableUndo(); |
} |
var i, j, origSpell ; |
// examine what happened to this current word. |
switch( this.wordFlags[text_idx][idx] ) { |
// replace all: go through this and all the future occurances of the word |
// replace all: go through this and all the future occurances of the word |
// and revert them all to the original spelling and clear their flags |
case this.replAllFlag : |
for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { |
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { |
for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
if(( i == text_idx && j >= idx ) || i > text_idx ) { |
var origSpell = this.wordWin.originalSpellings[i][j]; |
origSpell = this.wordWin.originalSpellings[i][j]; |
if( origSpell == preReplSpell ) { |
this._setWordText ( i, j, origSpell, undefined ); |
} |
334,22 → 338,22 |
} |
} |
break; |
// ignore all: go through all the future occurances of the word |
// ignore all: go through all the future occurances of the word |
// and clear their flags |
case this.ignrAllFlag : |
for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { |
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { |
for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { |
if(( i == text_idx && j >= idx ) || i > text_idx ) { |
var origSpell = this.wordWin.originalSpellings[i][j]; |
origSpell = this.wordWin.originalSpellings[i][j]; |
if( origSpell == preReplSpell ) { |
this.wordFlags[i][j] = undefined; |
this.wordFlags[i][j] = undefined; |
} |
} |
} |
} |
break; |
// replace: revert the word to its original spelling |
case this.replWordFlag : |
this._setWordText ( text_idx, idx, preReplSpell, undefined ); |
357,7 → 361,7 |
} |
// For all four cases, clear the wordFlag of this word. re-start the process |
this.wordFlags[text_idx][idx] = undefined; |
this.wordFlags[text_idx][idx] = undefined; |
this._spellcheck(); |
} |
} |
364,13 → 368,13 |
function _spellcheck() { |
var ww = this.wordWin; |
// check if this is the last word in the current text element |
if( this.currentWordIndex == ww.totalWords( this.currentTextIndex) ) { |
this.currentTextIndex++; |
this.currentWordIndex = 0; |
// keep going if we're not yet past the last text element |
if( this.currentTextIndex < this.wordWin.textInputs.length ) { |
if( this.currentTextIndex < this.wordWin.textInputs.length ) { |
this._spellcheck(); |
return; |
} else { |
378,7 → 382,7 |
return; |
} |
} |
// if this is after the first one make sure the Undo button is enabled |
if( this.currentWordIndex > 0 ) { |
this.controlWin.enableUndo(); |
404,10 → 408,10 |
// add suggestion in list for each suggested word. |
// get the array of suggested words out of the |
// three-dimensional array containing all suggestions. |
var a_suggests = this.wordWin.suggestions[text_num][word_num]; |
var a_suggests = this.wordWin.suggestions[text_num][word_num]; |
if( a_suggests ) { |
// got an array of suggestions. |
for( var ii = 0; ii < a_suggests.length; ii++ ) { |
for( var ii = 0; ii < a_suggests.length; ii++ ) { |
this.controlWin.addSuggestion( a_suggests[ii] ); |
} |
} |
449,10 → 453,9 |
for( var i = 0; i < document.forms.length; i++ ) { |
for( var j = 0; j < document.forms[i].elements.length; j++ ) { |
if( document.forms[i].elements[j].type.match( inputPattern )) { |
inputs[inputs.length] = document.forms[i].elements[j]; |
} |
inputs[inputs.length] = document.forms[i].elements[j]; |
} |
} |
} |
return inputs; |
} |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controls.html |
---|
1,8 → 1,8 |
<html> |
<head> |
<link rel="stylesheet" type="text/css" href="spellerStyle.css" /> |
<script src="controlWindow.js"></script> |
<script> |
<script type="text/javascript" src="controlWindow.js"></script> |
<script type="text/javascript"> |
var spellerObject; |
var controlWindowObj; |
138,7 → 138,7 |
disabled> |
</td> |
<td> </td> |
<td> |
<td> |
<!-- by FredCK |
<input class="buttonDefault" type="button" value="Close" onClick="end_spell();"> |
--> |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellchecker.html |
---|
26,8 → 26,8 |
function encodeForPost( str ) { |
var s = new String( str ); |
s = encodeURIComponent( s ); |
// additionally encode single quotes to evade any PHP |
// magic_quotes_gpc setting (it inserts escape characters and |
// additionally encode single quotes to evade any PHP |
// magic_quotes_gpc setting (it inserts escape characters and |
// therefore skews the btye positions of misspelled words) |
return s.replace( /\'/g, '%27' ); |
} |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.cfm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/branches/livraison_aha/api/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php |
---|
1,17 → 1,20 |
<?php |
header('Content-type: text/html; charset=utf-8'); |
//$spellercss = '/speller/spellerStyle.css'; // by FredCK |
$spellercss = '../spellerStyle.css'; // by FredCK |
//$word_win_src = '/speller/wordWindow.js'; // by FredCK |
$word_win_src = '../wordWindow.js'; // by FredCK |
$textinputs = $_POST['textinputs']; # array |
//$aspell_prog = 'aspell'; // by FredCK (for Linux) |
$aspell_prog = '"C:\Program Files\Aspell\bin\aspell.exe"'; // by FredCK (for Windows) |
$lang = 'en_US'; |
//$aspell_opts = "-a --lang=$lang --encoding=utf-8"; // by FredCK |
$aspell_opts = "-a --lang=$lang --encoding=utf-8 -H"; // by FredCK |
$tempfiledir = "./"; |
// The following variables values must reflect your installation needs. |
$aspell_prog = '"C:\Program Files\Aspell\bin\aspell.exe"'; // by FredCK (for Windows) |
//$aspell_prog = 'aspell'; // by FredCK (for Linux) |
$lang = 'en_US'; |
$aspell_opts = "-a --lang=$lang --encoding=utf-8 -H --rem-sgml-check=alt"; // by FredCK |
$tempfiledir = "./"; |
$spellercss = '../spellerStyle.css'; // by FredCK |
$word_win_src = '../wordWindow.js'; // by FredCK |
$textinputs = $_POST['textinputs']; # array |
$input_separator = "A"; |
# set the JavaScript variable to the submitted text. |
59,7 → 62,7 |
# handle a server-side error. |
function error_handler( $err ) { |
echo "error = '" . escape_quote( $err ) . "';\n"; |
echo "error = '" . preg_replace( "/['\\\\]/", "\\\\$0", $err ) . "';\n"; |
} |
## get the list of misspelled words. Put the results in the javascript words array |
79,6 → 82,10 |
if( $fh = fopen( $tempfile, 'w' )) { |
for( $i = 0; $i < count( $textinputs ); $i++ ) { |
$text = urldecode( $textinputs[$i] ); |
// Strip all tags for the text. (by FredCK - #339 / #681) |
$text = preg_replace( "/<[^>]+>/", " ", $text ) ; |
$lines = explode( "\n", $text ); |
fwrite ( $fh, "%\n" ); # exit terse mode |
fwrite ( $fh, "^$input_separator\n" ); |
190,4 → 197,3 |
</body> |
</html> |