Project 65 Augment the validation functionality in ActiveModel which we met in

Project 65 augment the validation functionality in

This preview shows page 251 - 253 out of 517 pages.

Project 6.5. Augment the validation functionality in ActiveModel (which we met in Chapter 5 ) to automatically generate JavaScript code that validates form inputs before the form is submitted. For example, given RottenPotatoes’ Movie model asserts that a movie must have a nonblank title, JavaScript code should prevent the “Add New Movie” form from being submitted if the validation is not met, displays a helpful message to the user, and highlights the field(s) that had validation problems. Handle at least the built-in validations such as nonblank, minimum/maximum string lengths, numerical values with range constraints, and for bonus points, validations based on regular expressions. Project 6.6. Following the approach of the jQuery example in Section 6.5 , use JavaScript to implement a set of checkboxes for the list of movies page, one for each rating (G, PG, and so on), which when checked allow movies with that rating to stay in the list. When the page first loads, all should be checked; unchecking any of them should hide the movies with that rating. Project 6.7. Extend the example of Section 6.6 so that if the user repeatedly expands and collapses the same row in the movies table, a request to the server for that movie’s info is only made the first time. In other words, implement client-side JavaScript caching for the movie info retrieved on each AJAX call. Project 6.8. If you visit twitter.com and the page takes more than a few seconds to load, a popup appears apologizing for the delay and suggesting you try reloading the page. Explain how you would implement this behavior using JavaScript. Hint: Remember that JavaScript code can begin executing as soon as it’s loaded, whereas the document.ready function won’t run until the document has been completely loaded and parsed. Project 6.9. Use the JSON and jQuery techniques in this chapter to use BDD to develop the following single-page app (SPA) counterpart to RottenPotatoes, which we call LocalPotatoes. When the user enters her US
Image of page 251
postal code (called “zip code” in the US), LocalPotatoes uses the RSS feed (Really Simple Syndication) provided free by the Fandango movie fan site to retrieve the names and locations of nearby movie theaters and the titles of movies playing there. This data is returned in XML, so you’ll need to do some minimal XML parsing in your JavaScript code to extract the theater names and movie names. A list of theaters is displayed on the client page; when the user clicks on a theater name, the Google Maps JavaScript API is used to center the map on that theater’s location, and the movies showing at that theater are listed in the Movies box. Clicking on the name of a movie looks up information about it using the free Open Movie Database API , which can return basic results in either JSON or XML, and displays the movie’s promotional artwork and overall rating by Internet Movie Database users.
Image of page 252
Image of page 253

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors