
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for an in-class exercise where students are required to write javascript code to create a search highlighter for text files using php and html. The exercise involves setting up the html file, pair-programming, and implementing the javascript code to highlight all occurrences of a clicked word in the text. Students are encouraged to look through chapter 9 or do internet searches to find the appropriate dom concepts and methods to use.
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

The PHP code that I provide creates a form that allows a user to select a file from a small collection of text files. When the form is submitted, it sends back the contents of the selected file. Each line of the file becomes a paragraph in the HTML file that the server provides to the browser. Once the page has loaded, the JavaScript code that you are to write will set things up so that when the user clicks on any word in the text, all occurrences of that word (even those that include punctuation or a different upper/lowercase configuration) are highlighted.
Unlike other in-class exercises, this one is required. It should be good practice with JavaScript for next Friday’s exam.
You and your in-class partner should do it as a pair-programming exercise. In a couple of cases, I will add “partnerless” students as a third person in a group. There should be adequate time to work on it in Monday’s and Thursday’s classes. You should not have to work on it outside of class time.
Implementation notes.
You and your partner should pair program on a single computer. I recommend having the partner who feels least confident about JavaScript programming be the driver.
word (except that there may be punctuation).
methods to use.
wrote five functions. The longest is 12 lines long if I do not count blank lines or lines that are only comments or closing braces.
and I have 74 lines.
and then eliminate the original div.