A B C D E F G H I J K L M N O P Q R S T U V W X-Y-Z
$() function, 225
$(document).ready handler, 233
$F() function, 225
&& (logical AND), 96
+ operator, 29
! character, 79
accessing
browser history, 55
classes with className property, 192-193
JSON data
native browser support, 154
ActiveX objects, creating, 264
adding comments to code, 24-25
addTax() function, testing, 365-366
advantages
of OOP, 106
asynchronous requests, 265-266
browser support, 264
client-server interaction, 262-263
implementing with jQuery, 266-270
ajax() method, 268
get() method, 267
post() method, 267
XMLHttpRequest object, 263
ajax() method, 268
building an application, 305-308
filters, 304
scopes, 302
animate() function, 173
animation
fading, 237
anonymous functions, 110-111, 289-290
arguments
for constructor functions, 113-114
multiple arguments, passing to functions, 41
+ operator, 29
incrementing/decrementing value of variables, 27-28
modulus division operator, 27
precedence, 28
arrays
associative arrays, simulating, 158-159
creating, 81
length property, 82
<article> tag (HTML5), 168
<aside> tag (HTML5), 168
assigning values to variables, 25-26
associative arrays, simulating, 158-159
asynchronous requests (Ajax), 265-266
attaching event handlers to elements, 239-243
attr() method, 235
attributes (HTML5)
of <video> tag, 169
background-origin property (CSS3), 208
background-size property (CSS3), 207
multiple background images, 208-209
banner-cycling script, writing, 347-351
beginPath() method, 173
best practices for writing JavaScript code, 325-326, 329
progressive enhancement, 330-331
writing unobtrusively, 331-333
negation operator, 79
border-radius property (CSS3), 206-207
box-shadow property (CSS3), 205
break command, 99
breakpoints, 353
browsers
Ajax support, 264
document.cookie property, 274
domain attribute, 276
escaping and unescaping data, 275
expires date, 276
limitations of, 274
path attribute, 276
reading, 280
secure flag, 276
value, 276
ECMAScript 6 compatibility, 287
Google Chrome extensions, writing, 312-316
launching the extension, 315
history, accessing, 55
Mozilla Firefox, DOM Inspector, 134-147
child nodes, manipulating, 136-141
dynamic menu creation, 142-147
loading JavaScript files, 141-147
native browser support, accessing JSON data, 154
reloading current page, 57
building
AngularJS application, 305-308
built-in objects, extending, 117-118
calculations, simplifying with Math object, 62-66
finding minimum and maximum, 62-63
rounding, 62
CamelCase convention, 25
canPlayType() method, 170
capabilities of JavaScript, 7
CDNs (Content Delivery Networks), jQuery, 232
Celsius, converting to Fahrenheit, 29-30
Changing Classes Using className listing, 192
character strings, assigning as value of variable, 26
child nodes, manipulating, 136-141
classes, 288
accessing with className property, 192-193
className property, accessing classes, 192-193
clearRect() method, 174
client-side scripting, 6
closePath() method, 173
code
debugging, 341
alert() method, 343
breakpoints, 353
conditional breakpoints, 354-355
watch expressions, 355
libraries
Dojo, 223
MooTools, 223
Prototype Framework, 223
purpose of, 222
refactoring, 363
writing, best practices, 325-326, 329
progressive enhancement, 330-331
writing unobtrusively, 331-333
combining
conditions, 96
JavaScript statements, 24
comparison operators, 90
concatenating strings, 29
conditional breakpoints, 354-355
conditional statements
comparison operators, 90
libraries, Yahoo! UI library, 223
logical operators, 96
testing multiple conditions, 95
confirm() method, 52
constructor functions, 111-114
for-of construct, 294
content, separating from style with CSS, 186
controllers, 298
controlling lighting effects, 214-217
converting
CSS3 property names to JavaScript, 214
data serialization, 155
strings to numbers, 71
document.cookie property, 274
domain attribute, 276
escaping and unescaping data, 275
expires date, 276
limitations of, 274
path attribute, 276
reading, 280
secure flag, 276
value, 276
retrieving, 283
setting multiple values, 284
creating
arrays, 81
date object
with current date and time, 60
with given date and time, 60
gradients
constructor functions, 111-114
CSS (Cascading Style Sheets)
DOM nodes
naming conventions, 191
separating style and content, 186
style declarations
CSS3
background-origin property, 208
background-size property, 207
multiple background images, 208-209
border-radius property, 206-207
box-shadow property, 205
gradients, creating
lighting effects, controlling, 214-217
properties
converting to JavaScript, 214
setting with vendor prefixes, 215-218
text effects
text shadow, 212
word wrap, 213
data serialization, 155
data types
floating-point numbers, 70
integers, 70
NaN, 71
empty strings, 72
dataTransfer property (HTML5), 176
Date object, 276
creating with current date and time, 60
creating with given date and time, 60
editing dates and times, 61
methods, 377
debugging
browser debugging tools, 344-347
code, 341
alert() method, 343
breakpoints, 353
conditional breakpoints, 354-355
watch expressions, 355
extensions, 315
Firebug, 371
JSLint, 371
decrementing value of variables, 27-28
detecting browser features, 119-120
directives (AngularJS), 302-304
disabling stylesheets (DOM object), 194-195
do...while statement, 98
document object (DOM), 11
document.cookie property, 274
document.write() method, 15-16
Dojo, 223
DOM (Document Object Model), 10-13
browser support for, 11
methods, 377
document object, 11
document.write() method, 15-16
getComputedStyle() method, 214-217
history object, 55
finding minimum and maximum, 62-63
generating random numbers, 63
with keyword, 64
mathematical constants, 64
properties, 376
rounding, 62
nodeName property, 130
parentNode property, 129
scripting, 123
window object, 11
child nodes, manipulating, 136-141
dynamically loading JavaScript files, 141-147
editing element attributes, 141
DOM Level 0, 10
DOM nodes
stylesheets, 194
enabling, disabling, switching, 194-195
downloading
drag and drop
draggable attribute (HTML5), 175
drawing with <canvas> tag (HTML5), 172-175
dynamic menu, creating, 142-147
ECMA (European Computer Manufacturers Association), 8
ECMAScript 6, 287
editor program, selecting, 369-370
elements
attributes
editing, 141
selecting
with getElementsByTagName() method, 130-132
empty strings, 72
enabling stylesheets (DOM object), 194-195
escape() function, 275
events
mouse events, creating image rollovers, 33-35
expires date (cookies), 276
exponential notation, 70
extending
objects with prototype, 114-115
extensions
debugging, 315
Google Chrome extensions, writing, 312-316
launching, 315
packaging, 321
external stylesheets (CSS), referencing, 187-188
externalizing scripts, 363
fading elements, 237
“falsy” values, 76
faulty program logic, 342
feature detection, 119-120, 333-334
<figcaption> tag (HTML5), 168
<figure> tag (HTML5), 168
fill() method, 173
filters (AngularJS), 304
Firebug, 371
flickr.com, 153
floating-point numbers, 70
<footer> tag (HTML5), 168
for loops, 98
for-of construct, 294
frameworks, 297-298. See also libraries
building an application, 305-308
filters, 304
scopes, 302
MVC architecture, 298
example of, 298
functions, 37
$(), 225
$F(), 225
constructor functions, 111-114
escape(), 275
getCss3Property(), 218
jsonParse(), 156
parseFloat(), 71
parseInt(), 71
multiple arguments, 41
simplicity in, 363
storing JavaScript in head section, 39-40
syntax, 38
variables
global, 47
local, 46
wrapper function (jQuery), 233-234
Geany, 370
generating random numbers, 63
get() method, 267
getComputedStyle() method, 214-217
getCss3Property() function, 218
getData() method, 176
getElementsByTagName() method, 130-132
global variables, 47
Google Ajax API CDN, 232
Google Chrome extensions, writing, 312-316
launching the extension, 315
packaging the extension, 321
gradients, creating
<header> tag (HTML5), 168
hide() method, 236
history object, 55
HTML (Hypertext Markup Language), 5
separating style and content with CSS, 186
html() method, 234
HTML5, 167
element attributes, reading, 133-134
tags
<article>, 168
<aside>, 168
<figcaption>, 168
<figure>, 168
<footer>, 168
<header>, 168
<nav>, 168
new tags, 168
<section>, 168
<summary>, 168
HTML5 Drag and Drop listing, 176
image rollovers, creating, 33-35
implementing Ajax with jQuery, 266-270
ajax() method, 268
get() method, 267
post() method, 267
incrementing value of variables, 27-28
installing
QUnit test suite, 363
instances, 106
integers, 70
Interacting with the Local File System listing, 181
resize, 251
interpreted languages, 9
JavaScript
adding to HTML documents, 22-23
capabilities of, 7
dynamically loading files, 141-147
new features
classes, 288
for-of construct, 294
modules, 290
combining, 24
storing in head section, 39-40
validating, 356
jEdit, 369
join() method, 83
jQuery, 224, 231. See also jQuery UI
$(document).ready handler, 233
fading elements, 237
attr() method, 235
hide() method, 236
html() method, 234
page elements, selecting, 233-234
remote versions, 232
show() method, 236
resize, 251
ThemeRoller, 246
JSLint, 371
JSON (JavaScript Object Notation), 151
accessing data
native browser support, 154
associative arrays, simulating, 158-159
data serialization, 155
objects
parameter/value pairs, 152
security, 163
website, 151
jsonParse() function, 156
JSON.parse() method, 154
JSON.stringify() method, 155
keywords
function, 38
null, 79
object literals, 79
prototype keyword
return, 42
undefined, 79
var, 25
with, 64
launching Google Chrome extensions, 315
length property, 82
libraries
Dojo, 223
versus frameworks, 298
$(document).ready handler, 233
attr() method, 235
hide() method, 236
html() method, 234
page elements, selecting, 233-234
remote versions, 232
show() method, 236
MooTools, 223
Prototype Framework, 223
$() function, 225
$F() function, 225
Form object, 226
purpose of, 222
Yahoo! UI library, 223
lighting effects, controlling, 214-217
limitations of cookies, 274
listings
Changing Classes Using className, 192
HTML5 Drag and Drop, 176
Interacting with the Local File System, 181
Moving a Ball Using <canvas>, 174
Selecting Stylesheets by Title, 197
Styling Using the DOM style Object, 190
Toggling Between Stylesheets Using the styleSheets Property, 199
local files, accessing in HTML5, 179-182
local storage in HTML5, 178-179
local variables, 46
logical operators, 96
loops
do...while statement, 98
for loop, 98
terminating, 99
while statement, 97
loosely typed languages, 69
manifest.json file for Google Chrome extension, 316-317
manipulating
markup languages, 5
finding minimum and maximum, 62-63
generating random numbers, 63
with keyword, 64
mathematical constants, 64
properties, 376
rounding, 62
messages, sending with functions, 41-43
methods
ajax(), 268
attr(), 235
confirm(), 52
for Date object, 377
document.write() method, 15-16
get(), 267
getElementsByTagName(), 130-132
hide(), 236
html(), 234
join(), 83
JSON.parse(), 154
JSON.stringify(), 155
on(), 243
post(), 267
replace(), 74
serialize(), 226
setTimeout(), 101
show(), 236
simplicity in, 363
slice(), 84
sort(), 84
string methods, 375
substr(), 75
toLowerCase(), 75
toString(), 83
toUpperCase(), 75
Microsoft CDN, 232
minimum and maximum, finding, 62-63
models, 298
modules, 290
modulus division operator, 27
MooTools, 223
mouse events
image rollovers, creating, 33-35
Moving a Ball Using <canvas> listing, 174
Mozilla Firefox, DOM Inspector, 134-147
attributes, editing, 141
dynamically loading JavaScript files, 141-147
nodes
child nodes, manipulating, 136-141
multiline comments, adding to statements, 24-25
multiple arguments, passing to functions, 41
multiple conditions
testing, 95
MVC (Model-View-Controller) architecture, 298
example of, 298
naming conventions
CSS (Cascading Style Sheets), 191
naming variables, 26
NaN (not a number), 71
native browser support, accessing JSON data, 154
<nav> tag (HTML5), 168
navigating with location object, 56
negation operator, 79
nodeName property, 130
child nodes, manipulating, 136-141
nodeName property, 130
parentNode property, 129
Notepad++, 369
null keyword, 79
floating-point numbers, 70
integers, 70
NaN, 71
object-oriented languages, 106
objects
ActiveX, creating, 264
constructor functions, 111-114
Date object, 276
methods, 377
date object
creating with current date and time, 60
editing dates and times, 61
extending with prototype, 114-115
Form, 226
history object, 55
instances, 106
finding minimum and maximum, 62-63
generating random numbers, 63
with keyword, 64
mathematical constants, 64
properties, 376
rounding, 62
serializing, 155
XMLHttpRequest object, 263
on() method, 243
onMouseOut event handler, 32-33
onMouseOver event handler, 32-33
OOP (object-oriented programming), 105-106
advantages of, 106
opening
opening JavaScript console, 344
OpenOffice.org, 312
incrementing/decrementing value of variables, 27-28
modulus division operator, 27
comparison operators, 90
logical operators, 96
negation operator, 79
precedence, 28
packaging Google Chrome extension, 321
parameters
for box-shadow property (CSS), 205
JSON, 152
parentNode property, 129
parseFloat() function, 71
parseInt() function, 71
passing arguments to functions, 40-43
multiple arguments, 41
pause() command, 170
play() command, 170
playing
sound, <audio> tag (HTML5), 171-172
videos
pause() and play() commands, 170
post() method, 267
precedence rules for operators, 28
procedural programming, 105
progressive enhancement, 330-331
properties
of arrays, length, 82
background-origin property (CSS3), 208
background-size property (CSS3), 207
border-radius property (CSS3), 206-207
box-shadow property (CSS3), 205
CSS3
setting with vendor prefixes, 215-218
CSS3, converting to JavaScript, 214
document.cookie property, 274
of Math object, 376
nodeName property, 130
parentNode property, 129
prefixed versions, 205
text-shadow (CSS3), 212
word-wrap (CSS3), 213
of XMLHttpRequest object, 264-265
properties (HTML5). See attributes (HTML5)
Prototype Framework library, 223
prototype keyword
$() function, 225
$F() function, 225
Form object, 226
purpose of libraries, 222
addTax() function, testing, 365-366
installing, 363
radial gradients, creating, 210-212
random numbers, generating, 63
reading
cookies, 280
properties of document object, 16-17
refactoring code, 363
referencing external stylesheets (CSS), 187-188
reloading current browser page, 57
remote versions of jQuery, 232
replace() method, 74
resize interaction, 251
return keyword, 42
returning values from functions, 42-45
rounding with Math object, 62
runtime errors, 342
SciTE, 370
scopes (AngularJS), 302
scripts, 6
array manipulation script, 84-86
banner-cycling script, writing, 347-351
client-side scripting, 6
DOM, 123
externalizing, 363
server-side scripting, 6
<section> tag (HTML5), 168
security, JSON, 163
selecting
elements
with getElementsByTagName() method, 130-132
stylesheets (DOM object), 195-199
Selecting Stylesheets by Title listing, 197
selectors (jQuery), 234
sending messages with functions, 41-43
separating style and content with CSS, 186
serialization, 155
serialize() method, 226
server-side scripting, 6
setData() method, 176
setInterval() method, 101-102, 174
setTimeout() method, 101
setting up
show() method, 236
simulating associative arrays, 158-159
slice() method, 84
sort() method, 84
spam detector function, 76-78, 91-93
combining, 24
conditional statements
testing multiple conditions, 95
do...while statement, 98
while statement, 97
storing
JavaScript in head section, 39-40
concatenating, 29
converting to numbers, 71
empty strings, 72
JSON strings, parsing, 155-157
stroke() method, 173
style, separating from content with CSS, 186
style declarations (CSS)
style property (DOM nodes), 188-191
stylesheets (DOM object), 194
enabling, disabling, switching, 194-195
Styling Using the DOM style Object listing, 190
substr() method, 75
<summary> tag (HTML5), 168
switching stylesheets (DOM object), 194-195
syntax
CamelCase convention, 25
errors, 341
functions, 38
tags, HTML5
<article>, 168
<aside>, 168
<figcaption>, 168
<figure>, 168
<footer>, 168
<header>, 168
<nav>, 168
new tags, 168
<section>, 168
<summary>, 168
terminating loops, 99
testing
multiple conditions, 95
unit testing
refactoring code, 363
video format support, canPlayType() method, 170
text effects
text shadow, 212
word wrap, 213
text-shadow property (CSS3), 212
ThemeRoller, 246
timers
setTimeout() method, 101
Toggling Between Stylesheets Using the styleSheets Property listing, 199
toLowerCase() method, 75
toString() method, 83
toUpperCase() method, 75
“truthy” values, 76
undefined keyword, 79
unescaping data, 275
unit testing
addTax() function, testing, 365-366
installing, 363
refactoring code, 363
validating JavaScript, 356
validators, 370
values
of cookies, 276
retrieving, 283
setting multiple values, 284
“falsy,” 76
returning from functions, 42-45
“truthy,” 76
var keyword, 25
arrays
associative arrays, simulating, 158-159
creating, 81
length property, 82
global variables, 47
incrementing/decrementing value of, 27-28
local variables, 46
naming, 26
vendor prefixes, setting CSS3 properties, 215-218
videos
playing
pause() and play() commands, 170
testing format support, canPlayType() method, 170
views, 298
W3C (World Wide Web Consortium), 8
validation services, 370
watch expressions, 355
WDG (Web Design Group), 370
web apps, MVC architecture, 299-300
WebM website, 169
websites
CDNs, 232
Dojo, 223
flickr.com, 153
jQuery, 224
JSON, 151
MooTools, 223
Prototype Framework, 223
prototype.js, 224
ThemeRoller, 246
Yahoo! UI library, 223
while statement, 97
window object (DOM), 11
with keyword, 64
word wrap, 213
word-wrap property (CSS3), 213
writing
banner-cycling script, 347-351
code, best practices, 311-312, 329
progressive enhancement, 330-331
writing unobtrusively, 331-333
Google Chrome extensions, 312-316
packaging the extension, 321
XHTML, 167
XMLHttpRequest object, 263
Yahoo! UI library, 223