CD-443Appendix F . Examples from (Florida web design) Parts III and

CD-443Appendix F . Examples from Parts III and IV 0 items found and replaced.

ARTICLE I

Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the government for a redress of grievances.

[The rest of the text is snipped for printing here, but it is on the CD-ROM version.]
Having a search and replace function available in a document is only one-half of the battle The other half is offering the facilities to undo the changes. To that end, Listing 19-11 includes an undo buffer that accurately undoes only the changes made in the initial replacement actions. The undo buffer stores its data in two global variables. The first, origSearchString, is simply the string used to perform the original search. This variable is the string that has to be put back in the places where it had been replaced. The second global variable is an array that stores TextRangebookmarks (see getBookmark()later in this chapter). These references are string values that don t mean much to humans, but the browser can use them to recreate a range with its desired start and end point. Values for both the global search string and bookmark specifications are stored in calls to the pushUndoNew() method each time text is replaced. A perhaps unexpected action of setting the text property of a text range is that the start and end points collapse to the end of the new text. Because the stored bookmark must include the replaced text as part of its specification, the start point of the current range must be adjusted back to the beginning of the replacement text before the bookmark can be saved. Thus, the pushUndoNew() function receives the replacement text string so that the moveStart()method can be adjusted by the number of characters matching the length of the replacement string. After all of the bookmarks are stored in the array, the undo action can do its job in a rather simple for loop inside the undoReplace()function. After verifying that the TextRange.findText()
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Leave a Reply