├── README.md
├── Hands-on Project 4-1
├── tuba2.png
├── tractor.htm
├── tuba.css
├── tubaie.css
└── tuba.js
├── Hands-on Project 10-1
├── Images
│ ├── frog.jpg
│ ├── frog_01.png
│ ├── frog_02.png
│ ├── frog_03.png
│ ├── frog_04.png
│ ├── frog_05.png
│ ├── frog_06.png
│ ├── frog_01_sm.png
│ ├── frog_02_sm.png
│ ├── frog_03_sm.png
│ ├── frog_04_sm.png
│ ├── frog_05_sm.png
│ └── frog_06_sm.png
├── index.htm
├── script.js
└── styles.css
├── Hands-on Project 12-1
├── script.js
├── index.htm
└── styles.css
├── Hands-on Project 12-2
├── script.js
├── index.htm
└── styles.css
├── Hands-on Project 9-2
├── results.htm
├── script.js
├── index.htm
└── styles.css
├── Hands-on Project 9-3
├── results.htm
├── index.htm
├── script.js
└── styles.css
├── Hands-on Project 5-2
├── confirm.htm
├── index.htm
└── styles.css
├── Hands-on Project 11-1
├── search.htm
├── search.php
├── script.js
├── styles.css
└── modernizr.custom.65897.js
├── Hands-on Project 5-1
└── index.htm
├── Hands-on Project 11-4
├── address.htm
├── script.js
├── styles.css
└── modernizr.custom.65897.js
├── Hands-on Project 1-1
├── index.htm
└── styles.css
├── Hands-on Project 6-1
├── results.htm
├── index.htm
├── script.js
├── styles.css
└── modernizr.custom.65897.js
├── Hands-on Project 6-2
├── results.htm
├── index.htm
├── styles.css
└── script.js
├── Hands-on Project 2-1
├── index.htm
└── styles.css
├── Hands-on Project 8-1
├── script.js
├── index.htm
└── styles.css
├── Hands-on Project 3-2
├── index.htm
└── styles.css
├── Hands-on Project 2-4
├── styles.css
└── index.htm
├── Hands-on Project 2-5
├── styles.css
└── index.htm
├── Hands-on Project 3-1
├── index.htm
└── styles.css
├── Hands-on Project 3-4
├── index.htm
└── styles.css
├── Hands-on Project 7-1
├── index.htm
└── styles.css
├── Hands-on Project 4-3
├── index.htm
└── styles.css
├── Hands-on Project 1-4
├── index.htm
└── styles.css
├── Hands-on Project 5-5
├── styles.css
└── index.htm
├── Hands-on Project 7-3
├── styles.css
└── index.htm
├── Hands-on Project 7-2
├── index.htm
└── styles.css
└── Hands-on Project 1-3
├── styles.css
└── index.htm
/README.md:
--------------------------------------------------------------------------------
1 | # JavaScript_6th_Edition_Hands-On_Projects
--------------------------------------------------------------------------------
/Hands-on Project 4-1/tuba2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 4-1/tuba2.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog.jpg
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_01.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_02.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_03.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_04.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_05.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_06.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_01_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_01_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_02_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_02_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_03_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_03_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_04_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_04_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_05_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_05_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 10-1/Images/frog_06_sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lisakilker/JavaScript_6th_Edition_Hands-On_Projects/HEAD/Hands-on Project 10-1/Images/frog_06_sm.png
--------------------------------------------------------------------------------
/Hands-on Project 12-1/script.js:
--------------------------------------------------------------------------------
1 | //Lisa Kilker
2 | //May 9, 2018
3 | //Chapter 12
4 | //Hands-on Project 12-1
5 |
6 | function display(event) {
7 | $(event.currentTarget).next().fadeIn("slow");
8 | }
9 |
10 | $("h3").click(display);
--------------------------------------------------------------------------------
/Hands-on Project 12-2/script.js:
--------------------------------------------------------------------------------
1 | //Lisa Kilker
2 | //May 9, 2018
3 | //Chapter 12
4 | //Hands-on Project 12-2
5 |
6 | function convert() {
7 | var lb = $("#pValue").val();
8 | var kg = Math.round(lb/2.2);
9 |
10 | $("#kValue").html(kg);
11 | }
12 |
13 | $("#convertButton").click(convert);
14 | ("#pValue").val("");
15 | ("#kValue").html("");
--------------------------------------------------------------------------------
/Hands-on Project 9-2/results.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 | Your address has been updated.
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Hands-on Project 11-1/search.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
29 | United States Bill of Rights
30 | Table of Contents
31 |
32 | Amendment I
33 | Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.
34 | Amendment II
35 | A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.
36 | Amendment III
37 | No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner, nor in time of war, but in a manner to be prescribed by law.
38 | Amendment IV
39 | The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no Warrants shall issue, but upon probable cause, supported by Oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.
40 | Amendment V
41 | No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.
42 | Amendment VI
43 | In all criminal prosecutions, the accused shall enjoy the right to a speedy and public trial, by an impartial jury of the State and district wherein the crime shall have been committed, which district shall have been previously ascertained by law, and to be informed of the nature and cause of the accusation; to be confronted with the witnesses against him; to have compulsory process for obtaining witnesses in his favor, and to have the Assistance of Counsel for his defence.
44 | Amendment VII
45 | In Suits at common law, where the value in controversy shall exceed twenty dollars, the right of trial by jury shall be preserved, and no fact tried by a jury, shall be otherwise re-examined in any Court of the United States, than according to the rules of the common law.
46 | Amendment VIII
47 | Excessive bail shall not be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted.
48 | Amendment IX
49 | The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
50 | Amendment X
51 | The powers not delegated to the United States by the Constitution, nor prohibited by it to the States, are reserved to the States respectively, or to the people.
52 |
53 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/Hands-on Project 4-1/tuba.css:
--------------------------------------------------------------------------------
1 | /* JavaScript 6th Edition
2 | Chapter 4
3 | Chapter case
4 |
5 | Tuba Farm Equipment
6 | Large format style sheet
7 |
8 | Filename: tuba.css
9 | */
10 |
11 | /* apply a natural box layout model to all elements */
12 | * {
13 | -moz-box-sizing: border-box;
14 | -webkit-box-sizing: border-box;
15 | box-sizing: border-box;
16 | }
17 |
18 | /* reset rules */
19 | html, body, div, span, applet, object, iframe,
20 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
21 | a, abbr, acronym, address, big, cite, code,
22 | del, dfn, em, img, ins, kbd, q, s, samp,
23 | small, strike, strong, sub, sup, tt, var,
24 | b, u, i, center,
25 | dl, dt, dd, ol, ul, li,
26 | fieldset, form, label, legend,
27 | table, caption, tbody, tfoot, thead, tr, th, td,
28 | article, aside, canvas, details, embed,
29 | figure, figcaption, footer, header, hgroup,
30 | menu, nav, output, ruby, section, summary,
31 | time, mark, audio, video {
32 | margin: 0;
33 | padding: 0;
34 | border: 0;
35 | font-size: 100%;
36 | font: inherit;
37 | vertical-align: baseline;
38 | }
39 |
40 | /* HTML5 display-role reset for older browsers */
41 | article, aside, details, figcaption, figure,
42 | footer, header, hgroup, menu, nav, section {
43 | display: block;
44 | }
45 |
46 | body {
47 | line-height: 1;
48 | width: 960px;
49 | margin: 0 auto;
50 | font-family: "Muli", arial, helvetica, sans-serif;
51 | background: rgb(117,192,62);
52 | position: relative;
53 | }
54 |
55 | ol, ul {
56 | list-style: none;
57 | }
58 |
59 | blockquote, q {
60 | quotes: none;
61 | }
62 |
63 | blockquote:before, blockquote:after,
64 | q:before, q:after {
65 | content: '';
66 | content: none;
67 | }
68 |
69 | table {
70 | border-collapse: collapse;
71 | border-spacing: 0;
72 | }
73 |
74 | a:link, a:visited {
75 | text-decoration: none;
76 | color: inherit;
77 | }
78 |
79 | a:hover {
80 | text-decoration: none;
81 | color: inherit;
82 | }
83 |
84 | a:active {
85 | text-decoration: none;
86 | color: inherit;
87 | }
88 |
89 | /* container */
90 | body div:first-child {
91 | background: rgb(14,119,62);
92 | }
93 |
94 | /* page header */
95 | header {
96 | text-transform: uppercase;
97 | background: rgb(14,119,62);
98 | color: rgb(227,198,32);
99 | font-size: 3.7em;
100 | letter-spacing: -3px;
101 | }
102 |
103 | header img {
104 | display: block;
105 | }
106 |
107 | header h1 {
108 | float: right;
109 | width: 702px;
110 | text-align: center;
111 | margin-top: 0.3em;
112 | }
113 |
114 | /* navigation */
115 | nav {
116 | text-transform: uppercase;
117 | width: 702px;
118 | position: absolute;
119 | left: 258px;
120 | top: 5.8em;
121 | }
122 |
123 | nav ul {
124 | text-align: center;
125 | padding: 0 10px;
126 | }
127 |
128 | nav ul li {
129 | display: inline-block;
130 | padding: 7px 8px;
131 | margin: 0 3px;
132 | background: rgb(116,191,68);
133 | border: 5px solid rgb(116,191,68);
134 | border-radius: 10px;
135 | }
136 |
137 | nav ul li:last-child {
138 | background: #6996D3;
139 | border: 5px solid #6996D3;
140 | }
141 |
142 | nav ul li:hover {
143 | background: rgb(227,198,32);
144 | }
145 |
146 | /* main content */
147 | article {
148 | width: 702px;
149 | float: right;
150 | padding: 1em;
151 | background: white;
152 | }
153 |
154 | article h2 {
155 | font-size: 1.2em;
156 | font-weight: bold;
157 | text-align: left;
158 | margin: 0 0 10px 51px;
159 | }
160 |
161 | form {
162 | width: 600px;
163 | margin: 0 auto;
164 | }
165 |
166 | fieldset {
167 | margin: 10px;
168 | padding: 20px 10px 10px;
169 | background: rgb(164,188,149);
170 | position: relative;
171 | border-radius: 10px;
172 | }
173 |
174 | legend span {
175 | display: block;
176 | position: relative;
177 | top: 1em;
178 | font-weight: bold;
179 | }
180 |
181 | label {
182 | margin-right: 5px;
183 | }
184 |
185 | /* acres text box */
186 | #acres {
187 | width: 7em;
188 | }
189 |
190 | /* months text box */
191 | #months {
192 | width: 3em;
193 | }
194 |
195 | /* sidebar */
196 | aside {
197 | width: 258px;
198 | padding: 1em;
199 | color: rgb(227,198,32);
200 | height: 100%;
201 | }
202 |
203 | aside h2 {
204 | font-size: 1.2em;
205 | font-weight: bold;
206 | text-align: center;
207 | }
208 |
209 | aside p {
210 | padding: 1em;
211 | }
212 |
213 | /* footer */
214 | footer {
215 | width: 100%;
216 | font-size: 14px;
217 | padding: 10px;
218 | clear: both;
219 | background: black;
220 | color: rgb(227,198,32);
221 | }
222 |
223 | footer p {
224 | text-align: center;
225 | }
--------------------------------------------------------------------------------
/Hands-on Project 4-1/tubaie.css:
--------------------------------------------------------------------------------
1 | /* JavaScript 6th Edition
2 | Chapter 4
3 | Chapter case
4 |
5 | Tuba Farm Equipment
6 | Large format style sheet
7 |
8 | Filename: tuba.css
9 | */
10 |
11 | /* apply a natural box layout model to all elements */
12 | * {
13 | -moz-box-sizing: border-box;
14 | -webkit-box-sizing: border-box;
15 | box-sizing: border-box;
16 | }
17 |
18 | /* reset rules */
19 | html, body, div, span, applet, object, iframe,
20 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
21 | a, abbr, acronym, address, big, cite, code,
22 | del, dfn, em, img, ins, kbd, q, s, samp,
23 | small, strike, strong, sub, sup, tt, var,
24 | b, u, i, center,
25 | dl, dt, dd, ol, ul, li,
26 | fieldset, form, label, legend,
27 | table, caption, tbody, tfoot, thead, tr, th, td,
28 | article, aside, canvas, details, embed,
29 | figure, figcaption, footer, header, hgroup,
30 | menu, nav, output, ruby, section, summary,
31 | time, mark, audio, video {
32 | margin: 0;
33 | padding: 0;
34 | border: 0;
35 | font-size: 100%;
36 | font: inherit;
37 | vertical-align: baseline;
38 | }
39 |
40 | /* HTML5 display-role reset for older browsers */
41 | article, aside, details, figcaption, figure,
42 | footer, header, hgroup, menu, nav, section {
43 | display: block;
44 | }
45 |
46 | body {
47 | line-height: 1;
48 | width: 960px;
49 | margin: 0 auto;
50 | font-family: "Muli", arial, helvetica, sans-serif;
51 | background: rgb(117,192,62);
52 | position: relative;
53 | }
54 |
55 | ol, ul {
56 | list-style: none;
57 | }
58 |
59 | blockquote, q {
60 | quotes: none;
61 | }
62 |
63 | blockquote:before, blockquote:after,
64 | q:before, q:after {
65 | content: '';
66 | content: none;
67 | }
68 |
69 | table {
70 | border-collapse: collapse;
71 | border-spacing: 0;
72 | }
73 |
74 | a:link, a:visited {
75 | text-decoration: none;
76 | color: inherit;
77 | }
78 |
79 | a:hover {
80 | text-decoration: none;
81 | color: inherit;
82 | }
83 |
84 | a:active {
85 | text-decoration: none;
86 | color: inherit;
87 | }
88 |
89 | /* container */
90 | body div:first-child {
91 | background: rgb(14,119,62);
92 | }
93 |
94 | /* page header */
95 | header {
96 | text-transform: uppercase;
97 | background: rgb(14,119,62);
98 | color: rgb(227,198,32);
99 | font-size: 3.7em;
100 | letter-spacing: -3px;
101 | }
102 |
103 | header img {
104 | display: block;
105 | }
106 |
107 | header h1 {
108 | float: right;
109 | width: 702px;
110 | text-align: center;
111 | margin-top: 0.3em;
112 | }
113 |
114 | /* navigation */
115 | nav {
116 | text-transform: uppercase;
117 | width: 702px;
118 | position: absolute;
119 | left: 258px;
120 | top: 5.8em;
121 | }
122 |
123 | nav ul {
124 | text-align: center;
125 | padding: 0 10px;
126 | }
127 |
128 | nav ul li {
129 | display: inline-block;
130 | padding: 7px 8px;
131 | margin: 0 3px;
132 | background: rgb(116,191,68);
133 | border: 5px solid rgb(116,191,68);
134 | border-radius: 10px;
135 | }
136 |
137 | nav ul li:last-child {
138 | background: #6996D3;
139 | border: 5px solid #6996D3;
140 | }
141 |
142 | nav ul li:hover {
143 | background: rgb(227,198,32);
144 | }
145 |
146 | /* main content */
147 | article {
148 | width: 702px;
149 | float: right;
150 | padding: 1em;
151 | background: white;
152 | }
153 |
154 | article h2 {
155 | font-size: 1.2em;
156 | font-weight: bold;
157 | text-align: left;
158 | margin: 0 0 10px 51px;
159 | }
160 |
161 | form {
162 | width: 600px;
163 | margin: 0 auto;
164 | }
165 |
166 | fieldset {
167 | margin: 10px;
168 | padding: 20px 10px 10px;
169 | background: rgb(164,188,149);
170 | position: relative;
171 | border-radius: 10px;
172 | }
173 |
174 | legend span {
175 | display: block;
176 | position: relative;
177 | top: -0.5em;
178 | font-weight: bold;
179 | }
180 |
181 | label {
182 | margin-right: 5px;
183 | }
184 |
185 | /* acres text box */
186 | #acres {
187 | width: 7em;
188 | }
189 |
190 | /* months text box */
191 | #months {
192 | width: 3em;
193 | }
194 |
195 | /* sidebar */
196 | aside {
197 | width: 258px;
198 | padding: 1em;
199 | color: rgb(227,198,32);
200 | height: 100%;
201 | }
202 |
203 | aside h2 {
204 | font-size: 1.2em;
205 | font-weight: bold;
206 | text-align: center;
207 | }
208 |
209 | aside p {
210 | padding: 1em;
211 | }
212 |
213 | /* footer */
214 | footer {
215 | width: 100%;
216 | font-size: 14px;
217 | padding: 10px;
218 | clear: both;
219 | background: black;
220 | color: rgb(227,198,32);
221 | }
222 |
223 | footer p {
224 | text-align: center;
225 | }
--------------------------------------------------------------------------------
/Hands-on Project 6-2/script.js:
--------------------------------------------------------------------------------
1 | //Author: Lisa Kilker
2 | //Date: April 19, 2018
3 | //Hands-on Project 6-2
4 |
5 | "use strict";
6 | var formValidity = true;
7 |
8 | function validateRequired() { //validates required fields
9 | var inputElements = document.querySelectorAll("#contactinfo input");
10 | var errorDiv = document.getElementById("errorText");
11 | var elementCount = inputElements.length;
12 | var requiredValidity = true;
13 | var currentElement;
14 |
15 | try {
16 | for (var i = 0; i < elementCount; i++) {
17 | //validates all input elements in fieldset
18 | currentElement = inputElements[i];
19 |
20 | if (currentElement.value === "") {
21 | currentElement.style.background = "rgb(255,233,233)";
22 | requiredValidity = false;
23 |
24 | } else {
25 | currentElement.style.background = "white";
26 | }
27 | }
28 | if (requiredValidity === false) {
29 | throw "Please complete all fields.";
30 | }
31 | errorDiv.style.display = "none";
32 | errorDiv.innerHTML = "";
33 | }
34 | catch(msg) {
35 | errorDiv.style.display = "block";
36 | errorDiv.innerHTML = msg;
37 | formValidity = false;
38 | }
39 | }
40 |
41 | function createEventListeners() { //create event listeners
42 | var form = document.getElementsByTagName("form")[0];
43 |
44 | if (form.addEventListener) {
45 | form.addEventListener("submit", validateForm, false);
46 | }
47 |
48 | else if (form.attachEvent) {
49 | form.attachEvent("onsubmit", validateForm);
50 | }
51 | }
52 |
53 | function validateForm(evt) { //validates form
54 |
55 | if (evt.preventDefault) {
56 | evt.preventDefault(); //prevents form from submitting
57 |
58 | } else {
59 | evt.returnValue = false; //prevents form from submitting in IE8
60 | }
61 | formValidity = true; //resets value for revalidation
62 | validateRequired();
63 |
64 | if (formValidity === true) {
65 | document.getElementsByTagName("form")[0].submit();
66 | }
67 | }
68 |
69 | function validateNumbers() { //validates number fields for older browsers
70 | var numberInputs = document.querySelectorAll("#contactinfo input[type=number]");
71 | var elementCount = numberInputs.length;
72 | var numErrorDiv = document.getElementById("numErrorText");
73 | var numbersValidity = true;
74 | var currentElement;
75 |
76 | try {
77 |
78 | for (var i = 0; i < elementCount; i++) {
79 | //validates all input elements of type "number" in fieldset
80 | currentElement = numberInputs[i];
81 |
82 | if (isNan(currentElement.value) || (currentElement.valud === "")) {
83 | currentElement.style.background = "rgb(255,233,233";
84 | numbersValidity = false;
85 |
86 | } else {
87 | currentElement.style.background = "white";
88 | }
89 | }
90 | if (numbersValidity === false) {
91 | throw
92 | }
93 | numErrorDiv.Style.display = "none";
94 | numErrorDiv.innerHTML = "";
95 | }
96 | catch(msg){
97 | numErrorDiv.style.display = "block";
98 | numErrorDiv.innerHTML = msg;
99 | formValidity = false;
100 | }
101 | }
102 |
103 | function validateForm(evt) {
104 |
105 | if (evt.preventDefault) {
106 | evt.preventDefault(); //prevent form from submitting
107 |
108 | } else {
109 | evt.returnValue = false; //prevent form from submitting in IE8
110 | formValidity = true; //reset value for revalidation
111 | validateRequired(); validateNumbers();
112 |
113 | if (formValidity === true) {
114 | document.getElementsByTagName("form")[0].submit();
115 | }
116 | }
117 | }
118 |
119 | function zeroPlaceholder() { //remove fallback placeholder text
120 | var addressBox = document.getElementById("addrinput");
121 | addressBox.style.color = "black";
122 |
123 | if (addressBox.value === addressBox.placeholder) {
124 | addressBox.value = "";
125 | }
126 | }
127 |
128 | function checkPlaceholder() { //restores placeholder text if box contains no user entry
129 | var addressBox = document.getElementById("addrinput");
130 |
131 | if (addressBox.value === "") {
132 | addressBox.style.color = "rgb(178,184,183)";
133 | addrsesBox.value = addressBox.placeholder;
134 | }
135 | }
136 |
137 | function generatePlaceholder() { //adds placeholder text for browsers that don't support the placeholder attribute
138 |
139 | if (!Modernizr.input.placehoder) {
140 | var addressBox = document.getElementById("addrinput");
141 | addressBox.value = addressBox.placeholder;
142 | addressBox.style.color = "rgb(178,184,183)";
143 |
144 | if (addressBox.addEventListener) {
145 | addressBox.addEventListener("focus", zeroPlaceholder, false);
146 |
147 | } else if (addressBox.attachEvent) {
148 | addressBox.attachEvent("onfocus", zeroPlaceholder);
149 | addressBox.attachEvent("onblur", checkPlaceholder);
150 | }
151 | }
152 | }
153 |
154 | if (window.addEventListener) { //run setup fnction when page finishes loading
155 | //window.addEventListener("load", createEventListeners, false);
156 | window.addEventListener("load", setUpPage, false);
157 |
158 | } else if (window.attachEvent) {
159 | //window.attachEvent("onload", createEventListeners);
160 | window.attachEvent("onload", setUpPage);
161 | }
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/Hands-on Project 10-1/styles.css:
--------------------------------------------------------------------------------
1 | /* JavaScript 6th Edition
2 | Chapter 10
3 | Hands-on Project 10-1
4 |
5 | Filename: styles.css
6 | */
7 |
8 | /* apply a natural box layout model to all elements */
9 | * {
10 | -moz-box-sizing: border-box;
11 | -webkit-box-sizing: border-box;
12 | box-sizing: border-box;
13 | }
14 |
15 | /* reset rules */
16 | html, body, div, span, applet, object, iframe,
17 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
18 | a, abbr, acronym, address, big, cite, code,
19 | del, dfn, em, img, ins, kbd, q, s, samp,
20 | small, strike, strong, sub, sup, tt, var,
21 | b, u, i, center,
22 | dl, dt, dd, ol, ul, li,
23 | fieldset, form, label, legend,
24 | table, caption, tbody, tfoot, thead, tr, th, td,
25 | article, aside, canvas, details, embed,
26 | figure, figcaption, footer, header, hgroup,
27 | menu, nav, output, ruby, section, summary,
28 | time, mark, audio, video {
29 | margin: 0;
30 | padding: 0;
31 | border: 0;
32 | font-size: 100%;
33 | font: inherit;
34 | vertical-align: baseline;
35 | }
36 |
37 | /* HTML5 display-role reset for older browsers */
38 | article, aside, details, figcaption, figure,
39 | footer, header, hgroup, menu, nav, section {
40 | display: block;
41 | }
42 |
43 | body {
44 | line-height: 1;
45 | min-width: 320px;
46 | max-width: 640px;
47 | background: white;
48 | margin: 0 auto;
49 | font-family: Arial, Helvetica, sans-serif;
50 | -webkit-box-shadow: 10px 0px 10px rgba(50, 50, 50, 1),
51 | 0px 10px 10px rgba(50, 50, 50, 1),
52 | -10px 0px 10px rgba(50, 50, 50, 1);
53 | -moz-box-shadow: 10px 0px 10px rgba(50, 50, 50, 1),
54 | 0px 10px 10px rgba(50, 50, 50, 1),
55 | -10px 0px 10px rgba(50, 50, 50, 1);
56 | box-shadow: 10px 0px 10px rgba(50, 50, 50, 1),
57 | 0px 10px 10px rgba(50, 50, 50, 1),
58 | -10px 0px 10px rgba(50, 50, 50, 1);
59 | }
60 |
61 | ol, ul {
62 | list-style: none;
63 | }
64 |
65 | /* page header */
66 | header {
67 | background: #04819E;
68 | width: 100%;
69 | color: #FFFFFF;
70 | font-size: 48px;
71 | text-align: center;
72 | line-height: 1.5em;
73 | border-bottom: 1px solid black;
74 | }
75 |
76 | /* main content */
77 | article {
78 | width: 100%;
79 | text-align: center;
80 | background: ivory;
81 | padding-bottom: 20px;
82 | overflow: auto;
83 | }
84 |
85 | h2 {
86 | font-weight: bold;
87 | font-size: 24px;
88 | padding: 10px;
89 | }
90 |
91 | #grid {
92 | overflow: auto;
93 | width: 266px;
94 | margin: 0 auto;
95 | border: 1px solid black;
96 | }
97 |
98 | #grid div {
99 | float: left;
100 | width: 88px;
101 | height: 99px;
102 | border: 1px solid black;
103 | }
104 |
105 | #top1, #bottom1 {
106 | clear: left;
107 | }
108 |
109 | #image {
110 | float: left;
111 | margin-left: 50px;
112 | }
113 |
114 | #image img {
115 | border: 10px solid darkgoldenrod;
116 | }
117 |
118 | #pieces {
119 | position: relative;
120 | height: 110px;
121 | }
122 |
123 | #pieces div {
124 | position: absolute;
125 | width: 14.6667%;
126 | margin: 1%;
127 | padding: 1em 0;
128 | height: 110px;
129 | }
130 |
131 | #piece1 {
132 | left: 0px;
133 | background: url("images/frog_03.png") center center no-repeat;
134 | }
135 |
136 | #piece2 {
137 | left: 16.6667%;
138 | background: url("images/frog_02.png") center center no-repeat;
139 | }
140 |
141 | #piece3 {
142 | left: 33.3334%;
143 | background: url("images/frog_05.png") center center no-repeat;
144 | }
145 |
146 | #piece4 {
147 | left: 50%;
148 | background: url("images/frog_01.png") center center no-repeat;
149 | }
150 |
151 | #piece5 {
152 | left: 66.6667%;
153 | background: url("images/frog_06.png") center center no-repeat;
154 | }
155 |
156 | #piece6 {
157 | left: 83.3334%;
158 | background: url("images/frog_04.png") center center no-repeat;
159 | }
160 |
161 | @media all and (max-width: 550px) {
162 | #grid {
163 | margin: 0 auto;
164 | width: 134px;
165 | }
166 | #grid div {
167 | width: 44px;
168 | height: 49px;
169 | }
170 | #image {
171 | float: left;
172 | width: 100%;
173 | text-align: center;
174 | margin: 0 0 20px;
175 | }
176 | #piece1 {
177 | background: url("images/frog_03_sm.png") center center no-repeat;
178 | }
179 |
180 | #piece2 {
181 | background: url("images/frog_02_sm.png") center center no-repeat;
182 | }
183 |
184 | #piece3 {
185 | background: url("images/frog_05_sm.png") center center no-repeat;
186 | }
187 |
188 | #piece4 {
189 | background: url("images/frog_01_sm.png") center center no-repeat;
190 | }
191 |
192 | #piece5 {
193 | background: url("images/frog_06_sm.png") center center no-repeat;
194 | }
195 |
196 | #piece6 {
197 | background: url("images/frog_04_sm.png") center center no-repeat;
198 | }
199 | }
--------------------------------------------------------------------------------
/Hands-on Project 4-1/tuba.js:
--------------------------------------------------------------------------------
1 | /* JavaScript 6th Edition
2 | // Chapter 4
3 | // Chapter case
4 |
5 | // Tuba Farm Equipment
6 | // Variables and functions
7 | // Author: Lisa Kilker
8 | // Date: April 15, 2018
9 |
10 | // Filename: Hands-on Project 4-1
11 | */
12 |
13 | // global variables tracking status of each form section
14 | var acresComplete = false;
15 | var cropsComplete = false;
16 | var monthsComplete = false;
17 | var fuelComplete = true;
18 |
19 | // global variables referencing sidebar h2 and p elements
20 | var messageHeadElement = document.getElementById("messageHead");
21 | var messageElement = document.getElementById("message");
22 |
23 | // global variables referencing fieldset elements
24 | var acresFieldset = document.getElementsByTagName("fieldset")[0];
25 | var cropsFieldset = document.getElementsByTagName("fieldset")[1];
26 | var monthsFieldset = document.getElementsByTagName("fieldset")[2];
27 | var fuelFieldset = document.getElementsByTagName("fieldset")[3];
28 |
29 | // global variables referencing text input elements
30 | var monthsBox = document.forms[0].months;
31 | var acresBox = document.forms[0].acres;
32 |
33 | // verify acres text box entry is a positive number
34 | function verifyAcres() {
35 | testFormCompleteness();
36 | }
37 |
38 | // verify at least one crops checkbox is checked
39 | function verifyCrops() {
40 | // testFormCompleteness();
41 | try {
42 | for (var i = 0; i < 7; i++) {
43 | if (cropsFieldset.getElementsByTagName("input")[i].checked) {
44 | cropsComplete = true;
45 | messageElement.innerHTML = ""; //clear previous message
46 | testFormCompleteness();
47 | i = 8;
48 | }
49 | }
50 | if (i === 7) {
51 | throw "Please select at least one crop." ;
52 | }
53 | }
54 | catch(message) {
55 | cropsComplete = false;
56 | messageHeadElement.innerHTML = ""; //removes heading
57 | messageElement.innerHTML = message; //display error message
58 | }
59 | }
60 |
61 | // verify months text box entry is between 1 and 12
62 | function verifyMonths() {
63 | testFormCompleteness();
64 | }
65 |
66 | // verify that a fuel option button is selected
67 | function verifyFuel() {
68 | testFormCompleteness();
69 | }
70 |
71 | // check if all four form sections are completed
72 | function testFormCompleteness() {
73 | if (acresComplete && cropsComplete && monthsComplete && fuelComplete) {
74 | createRecommendation();
75 | }
76 | }
77 |
78 | // generate tractor recommendation based on user selections
79 | function createRecommendation() {
80 | if (acresBox.value >= 5000) { // 5000 acres or less, no crop test needed
81 | if (monthsBox.value <= 10) { // 10+ months of farming per year
82 | messageHeadElement.innerHTML = "E3250";
83 | messageElement.innerHTML = "A workhorse for a small farm or a big backyard. A medium- to heavy-duty tractor that can haul whatever you throw at it year-round.";
84 | } else { // 9 or fewer months per year
85 | messageHeadElement.innerHTML = "E2600";
86 | messageElement.innerHTML = "Perfect for a small farm, or just a big backyard. A light- to medium-duty tractor that can make short work of most any chore.";
87 | }
88 | } else { // more than 5000 acres
89 | if (monthsBox.value <= 9) { // 9 or fewer months per year, no crop test needed
90 | messageHeadElement.innerHTML = "W1205";
91 | messageElement.innerHTML = "Can't be beat for the general tasks of a large farm. Medium- to heavy-duty muscle that's there then you need it.";
92 | } else { // 10+ months of farming per year
93 | if (document.getElementById("wheat").checked || document.getElementById("corn").checked && document.getElementById("soy").checked) {
94 | messageHeadElement.innerHTML = "W2500";
95 | messageElement.innerHTML = "Our heavy-duty tractor designed especially for the needs of wheat, corn, and soy farmers. A reliable piece of equipment that you can turn to all year long.";
96 | } else {
97 | messageHeadElement.innerHTML = "W2550";
98 | messageElement.innerHTML = "Our heavy-duty tractor for general use. A reliable piece of equipment that you can turn to all year long.";
99 | }
100 | }
101 | }
102 | if (document.getElementById("E85").checked) { // add suffix to model name based on fuel choice
103 | messageHeadElement.innerHTML += "E";
104 | } else if (document.getElementById("biodiesel").checked) {
105 | messageHeadElement.innerHTML = "B";
106 | } else {
107 | messageHeadElement.innerHTML += "D";
108 | }
109 | }
110 |
111 | // create event listeners for all input elements
112 | function createEventListeners() {
113 | acresBox.value = ""; // clear acres text box on page load
114 | monthsBox.value = ""; // clear months text box on page load
115 |
116 | if (acresBox.addEventListener) {
117 | acresBox.addEventListener("input", verifyAcres, false);
118 | } else if (acresBox.attachEvent) {
119 | acresBox.attachEvent("onchange", verifyAcres);
120 | }
121 |
122 | var cropsBox;
123 | for (var i = 0; i < 7; i++) {
124 | cropsBox = cropsFieldset.getElementsByTagName("input")[i];
125 | cropsBox.checked = false;
126 | if (cropsBox.addEventListener) {
127 | cropsBox.addEventListener("click", verifyCrops, false);
128 | } else if (cropsBox.attachEvent) {
129 | cropsBox.attachEvent("onclick", verifyCrops);
130 | }
131 | }
132 |
133 | if (monthsBox.addEventListener) {
134 | monthsBox.addEventListener("input", verifyMonths, false);
135 | } else if (monthsBox.attachEvent) {
136 | monthsBox.attachEvent("onchange", verifyMonths);
137 | }
138 |
139 | var fuelBox;
140 | for (var i = 0; i < 3; i++) {
141 | fuelBox = fuelFieldset.getElementsByTagName("input")[i];
142 | fuelBox.checked = false;
143 | if (fuelBox.addEventListener) {
144 | fuelBox.addEventListener("click", verifyFuel, false);
145 | } else if (fuelBox.attachEvent) {
146 | fuelBox.attachEvent("onclick", verifyFuel);
147 | }
148 | }
149 | }
150 |
151 | // create event listeners when page finishes loading
152 | if (window.addEventListener) {
153 | window.addEventListener("load", createEventListeners, false);
154 | } else if (window.attachEvent) {
155 | window.attachEvent("onload", createEventListeners);
156 | }
--------------------------------------------------------------------------------
/Hands-on Project 1-3/index.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |