A video of this class is (or will be) posted at: http://echo360.uml.edu/heines201516/guiprogramming1.html
Related reading for this class: JS&jQ:TMM Ch. 4, 5 & 9
Object
reference page extremely useful: http://msdn.microsoft.com/en-us/library/htbw4ywd(VS.85).aspxReference: Deitel, P.J. & Deitel, H.M. Internet & World Wide Web How To Program, 4th edition. pp. 345-346.
Global
FunctionDescription escape
Takes a string argument and returns a string in which all spaces, punctuation, accent characters and any other character that is not in the ASCII character set are encoded in a hexadecimal format that can be represented on all platforms. unescape
Takes a string as its argument and returns a string in which all characters previously encoded with escape are decoded. eval
Takes a string argument representing JavaScript code to execute. The JavaScript interpreter evaluates the code and executes it when the eval function is called. This function allows JavaScript code to be stored as strings and executed dynamically. Note: It is considered a serious security risk to use eval
to process any data entered by a user because a malicious user could exploit this to run dangerous code.isFinite
Takes a numeric argument and returns true
if the value of the argument is notNaN
,Number.POSITIVE_INFINITY
orNumber.NEGATIVE_INFINITY
(values that are not numbers or numbers outside the range that JavaScript supports)—otherwise, the function returnsfalse
.isNaN
Takes a numeric argument and returns true
if the value of the argument is not a number; otherwise, it returnsfalse
. The function is commonly used with the return value ofparseInt
orparseFloat
to determine whether the result is a proper numeric value.parseFloat
Takes a string argument and attempts to convert the beginning of the string into a floating-point value. If the conversion is unsuccessful, the function returns NaN
; otherwise, it returns the converted value (e.g.,parseFloat("abc123.45")
returnsNaN
, andparseFloat("123.45abc")
returns the value123.45
).parseInt
Takes a string argument and attempts to convert the beginning of the string into an integer value. If the conversion is unsuccessful, the function returns NaN
; otherwise, it returns the converted value (e.g.,parseInt("abc123")
returnsNaN
, andparseInt("123abc")
returns the integer value 123). This function takes an optional second argument, from 2 to 36, specifying the radix (or base) of the number. Base 2 indicates that the first argument string is in binary format, base 8 indicates that the first argument string is in octal format and base 16 indicates that the first argument string is in hexadecimal format.
HTML5 CSS3 JavaScript jQuery
Photo Credits
- Building Scaffolding — http://blog.fieldid.com/wp-content/uploads/scaffolding_example.jpg
- Pine Tree — http://www.northshoregarden.com/wp-content/uploads/2011/12/pine_tree-11921.jpg
- Child Decorating Christmas Tree — http://www.wallcoo.net/holiday/2008_family_christmas_fun_1920x1200/images/Family_Christmas_fun_094_008.jpg
- Christmas Celebration — http://www.wallcoo.net/holiday/2008_Family_Christmas_celebration_1920x1200/wallpapers/1920x1200/Family_Christmas_Celebration_FAN2019853.jpg
- Lots & Lots of Presents — http://blogs.babble.com/being-pregnant/files/2011/12/stxmco001christmas_tree_and_presents1.jpg
As you surely realize by now, JavaScript is no longer your father’s (or your grandfather’s) toy language for making little things happen change on web pages
The key to using JavaScript, however, is not the language itself
[figure source: jQuery: Novice to Ninja, by Castledine & Sharkie, p. 12]
The following examples and page references in orange are from jQuery: Novice to Ninja, by Castledine & Sharkie
Examples in jQuery: Novice to Ninja and JS&jQ:TMM Ch. 4
$(document).ready( function() { ... } ) ; //
pp. 18-19console.log( $('#celebs tr').length) ) ; //
p. 23console.log( $('#celebs tbody tr').length) ) ; //
adding semantics for specificity, p. 23console.log( $('#celebs tbody tr:even').length) ) //
using a filter, p. 24var fontSize = $('#celebs tbody tr:first').css('font-size') ; //
p. 25
$('#celebs tbody tr:even').css('background-color', '#dddddd') ; //
p. 26
$('#celebs tbody tr:even').css('background-color', '#dddddd') ; //
p. 27$('#celebs tbody tr:even').css('color', '#66666') ;
backgroundColor
instead of background-color
$('#celebs tbody tr:even').css('background-color', '#dddddd')
.css('color', '#66666') ;
$('#celebs tbody tr:even').css( // p. 28 { 'background-color' : '#dddddd', 'color' : '#666666' } ) ;
Adding and removing classes (pp. 30-31)
$('div').addClass('class_name') ;
$('div').addClass('class_name1 class_name2 class_name3') ;
.zebra { /* a class for zebra striping */ background-color: #dddddd ; color: #666666 ; }
$('#celebs tr:even').addClass('zebra') ;
$('#celebs tr.zebra').removeClass('zebra') ;
submit
— triggered when the form is submitted
focus
— triggered when a control gains focus
blur
— triggered when a control loses focusclick
— triggered when a control is clickedchange
— triggered whenever a control is changed
Using the jQuery submit()
event handler
1 $(document).ready( function() { 2 tblInitializer.initialize() ; 3 tblGenerator.populateMultiplicationTable_jQuery( "#placeholder", true ) ; 4 $('#frm').submit( function() { // trap the submit event *before* the action is executed 5 return validateForm() ; // true = allow action to proceed, false = inhibit action 6 } ) ; 7 } ) ; // end ready
Writing validation tests
val()
functionhtml()
functionisNaN()
functionreturn
statement efficiently
$( '#' + str )
trickRemember the three pillars of good error messages:
Initializing form fields
isNaN()
function? xBegin <= xEnd
and yBegin <= yEnd
developed with student Alan Szmyt, Fall 2015 semester
Note addition to line 60 from what’s on the handout:
60 if ( parameters !== null && parameters !== "" ) {