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 ) { |