-
Notifications
You must be signed in to change notification settings - Fork 2
/
day-9.html
420 lines (370 loc) · 11.2 KB
/
day-9.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Intro to JavaScript Day 9</title>
<meta name="author" content="Cameron Gose"/>
<style type="text/css">
.underline { text-decoration: underline; }
</style>
<link rel="stylesheet" href="./reveal.js/css/reveal.css"/>
<link rel="stylesheet" href="./reveal.js/css/theme/solarized.css" id="theme"/>
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = './reveal.js/css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="sec-title-slide">
<h1 class="title">Intro to JavaScript Day 9</h1><h2 class="author">Cameron Gose</h2><p class="date">Created: 2021-12-05 Sun 21:39</p>
</section>
<section>
<section id="slide-1">
<h2 id="1"><span class="section-number-2">1.</span> Agenda</h2>
<ul>
<li>Take Home Review</li>
<li>Forms</li>
<li>Daily Challenge</li>
<li>HTTP Requests</li>
<li>Take Home Challenge</li>
</ul>
</section>
</section>
<section>
<section id="slide-2">
<h2 id="2"><span class="section-number-2">2.</span> Take Home Review</h2>
<ul>
<li>Overview</li>
</ul>
</section>
<section id="slide-2-1">
<h3 id="2-1"><span class="section-number-3">2.1.</span> Take Home Review</h3>
<ul>
<li>Questions</li>
</ul>
</section>
</section>
<section>
<section id="slide-3">
<h2 id="3"><span class="section-number-2">3.</span> Forms</h2>
<div class="outline-text-2" id="text-3">
</div>
</section>
<section id="slide-3-1">
<h3 id="3-1"><span class="section-number-3">3.1.</span> Forms - Attributes</h3>
<div class="outline-text-3" id="text-3-1">
</div>
</section>
<section id="slide-3-1-1">
<h4 id="3-1-1"><span class="section-number-4">3.1.1.</span> Forms - Attributes - name</h4>
<ul>
<li>Give a name to the form</li>
</ul>
</section>
<section id="slide-3-1-2">
<h4 id="3-1-2"><span class="section-number-4">3.1.2.</span> Forms - Attributes - action</h4>
<ul>
<li>URL form targets when form is submitted</li>
<li>Older way of submitting form</li>
<li>Simple and still works</li>
</ul>
</section>
<section id="slide-3-1-3">
<h4 id="3-1-3"><span class="section-number-4">3.1.3.</span> Forms - Attributes - method</h4>
<ul>
<li>Supports two request methods
<ul>
<li>GET</li>
<li>POST</li>
</ul></li>
</ul>
</section>
<section id="slide-3-2">
<h3 id="3-2"><span class="section-number-3">3.2.</span> Forms - Elements</h3>
<div class="outline-text-3" id="text-3-2">
</div>
</section>
<section id="slide-3-2-1">
<h4 id="3-2-1"><span class="section-number-4">3.2.1.</span> Forms - Elements - Input</h4>
<ul>
<li>Most used element</li>
<li>Almost every form will use this</li>
</ul>
<ol class="org-ol">
<li><a id="3-2-1-1"></a>Forms - Input - Text<br />
<ul>
<li>Allows free typed text input</li>
</ul>
</li>
<li><a id="3-2-1-2"></a>Forms - Input - Radio<br />
<ul>
<li>Allows for one selection out of many options</li>
<li>People inappropriately use checkboxes for this</li>
</ul>
</li>
<li><a id="3-2-1-3"></a>Forms - Input - Checkbox<br />
<ul>
<li>Allows for 0-n selctions out of many options</li>
<li>Do not use this for Radio functionality</li>
</ul>
</li>
<li><a id="3-2-1-4"></a>Forms - Input - Submit<br />
<ul>
<li>Submits the form</li>
<li>Submits form data to value in action using the value in method attribute</li>
</ul>
</li>
<li><a id="3-2-1-5"></a>Forms - Input - Others<br />
<ul>
<li>email</li>
<li>password</li>
<li>tel</li>
<li>file</li>
<li><a href="https://www.w3schools.com/html/html_form_input_types.asp">and more</a></li>
</ul>
</li>
</ol>
</section>
<section id="slide-3-2-2">
<h4 id="3-2-2"><span class="section-number-4">3.2.2.</span> Forms - Elements - Label</h4>
<ul>
<li>Defines a label for form elements</li>
<li>Important for screen-readers</li>
<li>Helps users click on control</li>
<li>for attribute = id of matching element</li>
</ul>
</section>
<section id="slide-3-2-3">
<h4 id="3-2-3"><span class="section-number-4">3.2.3.</span> Forms - Elements - Button</h4>
<ul>
<li>Makes a button</li>
<li>Could for handling events</li>
<li>Can use type attribute
<ul>
<li>Submit</li>
<li>Button</li>
</ul></li>
</ul>
</section>
<section id="slide-3-2-4">
<h4 id="3-2-4"><span class="section-number-4">3.2.4.</span> Forms - Elements - Select/Option</h4>
<ul>
<li>Adds a drop down selection box</li>
<li>Each item in dropdown is defined by an option</li>
<li>Can add multiple attribute to allow multi-select</li>
</ul>
</section>
<section id="slide-3-2-5">
<h4 id="3-2-5"><span class="section-number-4">3.2.5.</span> Forms - Elements - TextArea</h4>
<ul>
<li>Multi line text field</li>
<li>Can use rows and cols attributes to set size
<ul>
<li>or you can just use CSS</li>
</ul></li>
</ul>
</section>
<section id="slide-3-3">
<h3 id="3-3"><span class="section-number-3">3.3.</span> Forms - JavaScript</h3>
<ul>
<li>Sometimes need to prevent form default behavior</li>
<li>event.preventDefault()
<ul>
<li>Can be used to stop events
<ul>
<li>Not all events are preventable</li>
</ul></li>
<li>Used on forms often</li>
<li>Now you have to handle it in JavaScript</li>
</ul></li>
</ul>
</section>
<section id="slide-3-4">
<h3 id="3-4"><span class="section-number-3">3.4.</span> Forms - Examples</h3>
</section>
</section>
<section>
<section id="slide-4">
<h2 id="4"><span class="section-number-2">4.</span> Daily Challenge</h2>
<ul>
<li>Create a new codepen</li>
<li>Create a contact form with a submit button</li>
<li>Using what you learned about DOM manipulation, create a submit function that will do the following:
<ul>
<li>Grab the values entered by the user</li>
<li>Hide the form</li>
<li>Display the information submitted by the user</li>
</ul></li>
</ul>
</section>
<section id="slide-4-1">
<h3 id="4-1"><span class="section-number-3">4.1.</span> Daily Challenge - Review</h3>
<ul>
<li>My implementation</li>
</ul>
</section>
<section id="slide-4-2">
<h3 id="4-2"><span class="section-number-3">4.2.</span> Daily Challenge - Review</h3>
<ul>
<li>Any Questions?</li>
</ul>
</section>
</section>
<section>
<section id="slide-5">
<h2 id="5"><span class="section-number-2">5.</span> HTTP Requests</h2>
<div class="outline-text-2" id="text-5">
</div>
</section>
<section id="slide-5-1">
<h3 id="5-1"><span class="section-number-3">5.1.</span> HTTP Requests</h3>
<ul>
<li>HTTP Protocols determine wheter data is coming from client or server</li>
<li>Each one signifies a specific use case
<ul>
<li>Some not enforced just considered standard practice</li>
</ul></li>
<li>Ways of passing data to server from client
<ul>
<li>Query Params</li>
<li>Route Ids</li>
<li>Form data</li>
<li>Headers</li>
<li>Body</li>
</ul></li>
</ul>
</section>
<section id="slide-5-2">
<h3 id="5-2"><span class="section-number-3">5.2.</span> HTTP Responses</h3>
<ul>
<li>Each HTTP Request has a Response from the server</li>
<li>Each response has a status code
<ul>
<li>1xx Information</li>
<li>2xx Successful</li>
<li>3xx Redirection</li>
<li>4xx Client error</li>
<li>5xx Server error</li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status">Status Codes</a></li>
</ul></li>
</ul>
</section>
<section id="slide-5-3">
<h3 id="5-3"><span class="section-number-3">5.3.</span> HTTP Protocols - GET</h3>
<ul>
<li>Used for retrieving data from server
<ul>
<li>Get a list of items
<ul>
<li>Also used to filter list of items</li>
</ul></li>
<li>Get single item details</li>
</ul></li>
<li>Can pass data using query params</li>
<li>Servers don’t usually accept a body for GET Requests</li>
</ul>
</section>
<section id="slide-5-4">
<h3 id="5-4"><span class="section-number-3">5.4.</span> HTTP Protocols - PUT</h3>
<ul>
<li>Used to update entire item on server</li>
<li>Replacing a file, image, or data</li>
</ul>
</section>
<section id="slide-5-5">
<h3 id="5-5"><span class="section-number-3">5.5.</span> HTTP Protocols - PATCH</h3>
<ul>
<li>Used to signify partial update of data on server
<ul>
<li>Will update fields passed to server that match expected object</li>
<li>Can be all</li>
</ul></li>
</ul>
</section>
<section id="slide-5-6">
<h3 id="5-6"><span class="section-number-3">5.6.</span> HTTP Protocols - POST</h3>
<ul>
<li>Used for Creating new items on server</li>
<li>Was previously used for everything
<ul>
<li>Remember: Forms methods GET and POST</li>
</ul></li>
<li>Will run into older code with only GET and POST</li>
</ul>
</section>
<section id="slide-5-7">
<h3 id="5-7"><span class="section-number-3">5.7.</span> HTTP Protocols - DELETE</h3>
<ul>
<li>As the protocols suggests it deletes items from server</li>
</ul>
</section>
</section>
<section>
<section id="slide-6">
<h2 id="6"><span class="section-number-2">6.</span> Take Home Challenge</h2>
<ul>
<li>Start working on your final project:
<ul>
<li>Your final project will be to build a magic 8 ball app</li>
<li>Create a new repository named: magic8ball</li>
<li>Clone your repository</li>
<li>Add your index file, stylesheet, script file and the provided 8ball images</li>
</ul></li>
</ul>
</section>
<section id="slide-6-1">
<h3 id="6-1"><span class="section-number-3">6.1.</span> Take Home Challenge - Objectives</h3>
<ul>
<li>Create input field for users to ask a question</li>
<li>Create a label for your input field telling your user to “Ask me anything!”</li>
<li>Create an “ask” button (this will run the function that you will insert the images into using javascript)</li>
<li>Create a div with an id of “answers” that you will insert the images into using js</li>
<li>Creat an “ask” function that when clicked, will choose as random 8ball image and insert it into your “answers” div</li>
<li>Replace the input field with the user’s question when displaying the answer</li>
<li>Style your page any way you like</li>
<li>Activate Github Pages for your project</li>
</ul>
</section>
</section>
</div>
</div>
<script src="./reveal.js/lib/js/head.min.js"></script>
<script src="./reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: false,
center: true,
slideNumber: 'c',
rollingLinks: false,
keyboard: true,
mouseWheel: false,
fragmentInURL: false,
hashOneBasedIndex: false,
pdfSeparateFragments: true,
overview: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'convex', // see README of reveal.js for options
transitionSpeed: 'default',
// Optional libraries used to extend reveal.js
dependencies: [
{ src: './reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: './reveal.js/plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: './reveal.js/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }]
});
</script>
</body>
</html>