UMass Lowell Dept. of Computer Science

91.461 GUI Programming I

Fall 2015 Semester, Section 201

Prof. Jesse M. Heines

Notes for Class No. 17

HTML5 Input Types

Thursday, October 29, 2015

A video of this classis (or will be) posted at:   http://echo360.uml.edu/heines201516/guiprogramming1.html


Handouts and Materials

Assignment No. 7 is now posted


Openings / Announcements / Reminders

Academic Calendar Note:  Enrollment opens for Spring 2016 courses per enrollment appointments shown on SiS on Monday, November 2

$.getJSON() challenge


Class Notes

Related reading for this class:  JS&jQ:TMM Ch. 9


Anonymous Functions  (JS&jQ:TMM, pp. 148-150)

As noted earlier, anonymous functions are critical in places that expect (in C/C++ terms) pointers to functions

We have seen anonymous functions before, and they will be even more important when we look at events next week (JS&jQ:TMM Ch. 5)

The textbook uses the each() function to demonstrate how anonymous functions are used with jQuery

JS & jQ: TMM fig. 4-6, p. 148
[figure source:  JavaScript & jQuery: The Missing Manual, by McFarland, fig. 4-6, p. 148]

Figure Caption:  jQuery’s each() function lets you loop through a selection of page elements and perform a series of tasks on each elemement.  The key to using the function is understanding anonymous functions.

N.B.  In the example at the bottom of page 148, the author uses the alert() function:

$('img').each( function() {
  alert( 'I found an image' ) ;
});


HTML5 Input Types

Reference:  HTML5: The Missing Manual by Matthew MacDonald, Chapter 4

New type attributes for the input tag

Browser support for these types is all over the map

Sample programs to explore on your own  (PDF containing all code listings)

Important Note:  Only a few of these work in Firefox.  Use Google Chrome or Opera.

Dynamic Progress Bar Demo

JavaScript timers in this demo — www.w3schools.com/js/js_timing.asp

  1. Declare a variable that will hold the timer instance.

    var myTimer ;

  2. Define a function that will be called each time the time “pulses.”

    var TimerPulse = function() {
      // do whatever you want here
    }

  3. Initiate the timer with a statement of the form:

    myTimer = window.setInterval( TimerPulse, 500 ) ; 
    // window. is optional, 2nd parameter is in milliseconds

  4. Cancel the timer with a statement of the form:

    window.clearInterval( myTimer ) ; 
    // window. is optional


Hiding and revealing elements with jQuery

Source:  jQuery: Novice to Ninja, by Castledine & Sharkie, pp. 32-37



This is document http://jesseheines.com:8080/~heines/91.461/91.461-2015-16f/461-lecs/lecture17.jsp.  It was last modified on Friday, August 26, 2022 at 4:09 PM.
Copyright © 2022 by Jesse M. Heines.  All rights reserved.  May be freely copied or excerpted for educational purposes with credit to the author.