-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
755 lines (677 loc) · 21.5 KB
/
index.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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Geek Girl JavaScript</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style type='text/css'>
button {
padding: 8px;
font-weight: bold;
border-radius: 4px;
background-color: #fff;
font-family: 'Trebuchet MS', sans-serif, sans;
font-size: 14px;
}
</style>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Intro to JavaScript</h1>
<p>
<small>Presented by <a href="http://hbrysiewicz.github.io">Heather Brysiewicz</a> / <a href="http://twitter.com/caligoanimus">@caligoanimus</a></small>
</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>Prerequisites</h2>
<p>
Laptop <br>
...with a browser! <br>
Text Editor - <a href='http://www.sublimetext.com/'>SublimeText</a><br>
</p>
<aside class="notes">
to follow along example at end - laptop with chrome or firefox with
dev tools<br>
our example doesn't need text editor - sublime text
</aside>
</section>
<section>
<h2>a bit about this talk</h2>
<p>
<a href="http://lab.hakim.se/reveal-js/#/">Reveal.js</a><br>
interactive examples<br>
</p>
<aside class="notes">
I'm going to be using a presentation tool called reveal.js<br>
its awesome because it actually runs in my browser which means it can run
javascript code inside of my presentation<br>
if you're feeling daring, check it out. but in this talk there will be some interactive examples and this is how they work.<br>
good segway - javascripts pretty awesome because it can run anywhere
</aside>
</section>
<section>
<h2>code that runs anywhere</h2>
<p>
laptop<br>
desktop<br>
tablet<br>
cell phone<br>
television<br>
arduino<br>
</p>
<aside class="notes">
why javascript?<br>
it runs basically anywhere<br>
large reach for what you create. don't need to buy an xbox to play
your game, just load up a browser and you can share your game with anyone
</aside>
</section>
<section>
<h2>You already have an environmet for it</h2>
<p>
all you need is a browser<br>
maybe a text editor
</p>
<aside class="notes">
not only does it run everywhere, but it is easy to get started writing javascript because all you need is a browser that can understand and
execute javascript<br>
if you use wordpress or tumblr, you can easily leave today and start
messing around with javascript in the custom edit sections of those
sites and add some awesome interactivity to your website<br>
</aside>
</section>
<section>
<h2>Game Plan</h2>
<p>
data types<br>
conditionals, if/elseif/else, for loop, functions<br>
events and DOM api<br>
flipbook<br>
</p>
</section>
<section>
<h2>Data Types</h2>
<p>
boolean<br>
number<br>
string<br>
object<br>
kind of arrays...<br>
</p>
<aside class="notes">
for sake of this talk - 4 data types<br>
arrays, which are special objects but ultimately just objects with
special methods and behaviors.
</aside>
</section>
<section>
<h2>boolean</h2>
<p>
<pre><code data-trim style="max-height:none">
if (true) document.write("This is true! <br>");
if (false) document.write("You won't ever see this :( <br>");
</code></pre>
<button id='boolean-btn'>Show Result</button>
<div id='boolean-result' style='display:none'>
<script type="text/javascript">
if (true) document.write("This is true! <br>");
if (false) document.write("You won't ever see this :( <br>");
</script>
</div>
<script type="text/javascript">
document.getElementById('boolean-btn').onclick = function(e) {
document.getElementById('boolean-result').style.display = '';
}
</script>
</p>
<aside class="notes">
what I think is the most simple, true/false<br>
yes/no<br>
document.write is a way for us to write out onto the document. in this instance its the page here.
</aside>
</section>
<section>
<h2>number</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write(4 + 4);
document.write(144 / 12);
document.write(15 * 0.25);
</code></pre>
<button id='number-btn'>Show Result</button>
<div id='number-results' style='display:none'>
<script type="text/javascript">
document.write(4 + 4);
document.write("<br>");
document.write(144 / 12);
document.write("<br>");
document.write(15 * 0.25);
</script>
</div>
<script type="text/javascript">
document.getElementById('number-btn').onclick = function(e) {
document.getElementById('number-results').style.display = '';
}
</script>
</p>
</section>
<section>
<h2>string</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write("I'm a string");
document.write("I'm a string... " + "And I am another string!");
</code></pre>
<button id='string-btn'>Show Result</button>
<div id='string-result' style='display:none'>
<script type="text/javascript">
document.write("I'm a string<br>");
document.write("I'm a string... " + "And I am another string!");
</script>
</div>
<script type="text/javascript">
document.getElementById('string-btn').onclick = function(e) {
document.getElementById('string-result').style.display = '';
}
</script>
</p>
<aside class='notes'>
string of text, characters, numbers, whatever<br>
you can concatenate them together using a plus sign
</aside>
</section>
<section>
<h2>object</h2>
<p>
{ name: "Heather" }
<pre><code data-trim style="max-height:none">
document.write({ name: "Heather" });
document.write({ name: "Heather" }.name);
</code></pre>
<button id='object-btn'>Show Result</button>
<div id='object-result' style='display:none'>
<script type="text/javascript">
document.write({name: "Heather"});
document.write("<br>");
document.write({ name: "Heather" }.name);
</script>
</div>
<script type='text/javascript'>
document.getElementById('object-btn').onclick = function(e) {
document.getElementById('object-result').style.display = '';
}
</script>
</p>
<aside class='notes'>
key value pairs<br>
building block of javascript<br>
</aside>
</section>
<section>
<h2>arrays</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write([1, 2, 3, 4, 5]);
document.write([1, 2, 3, 4, 5][0]);
</code></pre>
<button id='array-btn'>Show Result</button>
<div id='array-result' style='display:none'>
<script type="text/javascript">
document.write([1, 2, 3, 4, 5]);
document.write("<br>");
document.write([1, 2, 3, 4, 5][0]);
</script>
</div>
<script type='text/javascript'>
document.getElementById('array-btn').onclick = function(e) {
document.getElementById('array-result').style.display = '';
}
</script>
</p>
<aside class='notes'>
arrays are merely a special kind of object<br>
array objects have a toString method on them and they know how
to print themselves out
</aside>
</section>
<section>
<h2>variables</h2>
<p>
<pre><code data-trim style="max-height:none">
var myName = "Heather"
document.write(myName);
var myArray = [1, 2, 3, 4, 5];
document.write(myArray[0]);
</code></pre>
<button id='variables-btn'>Show Result</button>
<div id='variables-result' style='display:none'>
<script type="text/javascript">
var myName = "Heather"
document.write(myName);
document.write('<br>');
var myArray = [1, 2, 3, 4, 5];
document.write(myArray[0]);
</script>
</div>
<script type='text/javascript'>
document.getElementById('variables-btn').onclick = function(e) {
document.getElementById('variables-result').style.display = ''
}
</script>
</p>
<aside class='notes'>
variables pretty cool because you can store data and reference it later
</aside>
</section>
<section>
<h2>break for kittens</h2>
<p>
<img src="https://i.imgur.com/F5iJY.jpg">
</p>
</section>
<section>
<h2>conditionals</h2>
<p>
== equal<br>
!= not equal<br>
=== strong (identity) equal<br>
!== strong (identity) not equal<br>
< less than<br>
> greater than<br>
<= less than or equal<br>
>= greater than or equal<br>
</p>
<aside class='notes'>
operators you can use to compare items<br>
is an orange an apple?<br>
is 4 greater than 10<br>
</aside>
</section>
<section>
<h2>== equal<br>=== strong equal</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write(0 == '');
document.write(0 === '');
</code></pre>
<button id='eq-btn'>Show Result</button>
<div id='eq-result' style='display:none'>
<script type="text/javascript">
document.write(0 == '');
document.write("<br>");
document.write(0 === '');
</script>
</div>
<script type='text/javascript'>
document.getElementById('eq-btn').onclick = function(e) {
document.getElementById('eq-result').style.display = '';
}
</script>
</p>
<aside class='notes'>
loose and strong equal<br>
strong or identity equal<br>
loose will do some type conversions before ultimately determining result
</aside>
</section>
<section>
<h2>!= equal<br>!== strong equal</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write(false != '0');
document.write(false !== '0');
</code></pre>
<button id='neq-btn'>Show Result</button>
<div id='neq-result' style='display:none'>
<script type="text/javascript">
document.write(false != '0');
document.write("<br>");
document.write(false !== '0');
</script>
</div>
<script type='text/javascript'>
document.getElementById('neq-btn').onclick = function(e) {
document.getElementById('neq-result').style.display = '';
}
</script>
</p>
</section>
<section>
<h2>< less than<br>> greater than</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write(0 < 4);
document.write(4 < 4);
document.write(0 > 4);
</code></pre>
<button id='ltgt-btn'>Show Result</button>
<div id='ltgt-result' style='display:none'>
<script type="text/javascript">
document.write(0 < 4);
document.write("<br>");
document.write(4 < 4);
document.write("<br>");
document.write(0 > 4);
</script>
</div>
<script type='text/javascript'>
document.getElementById('ltgt-btn').onclick = function(e) {
document.getElementById('ltgt-result').style.display = '';
}
</script>
</p>
</section>
<section>
<h2><= less than or equal<br>>= greater than or equal</h2>
<p>
<pre><code data-trim style="max-height:none">
document.write(4 <= 4);
document.write(7 >= 4);
document.write(4 >= 4);
</code></pre>
<button id='ltegte-btn'>Show Result</button>
<div id='ltegte-result' style='display:none'>
<script type="text/javascript">
document.write(4 <= 4);
document.write("<br>");
document.write(7 >= 4);
document.write("<br>");
document.write(4 >= 4);
</script>
</div>
<script type='text/javascript'>
document.getElementById('ltegte-btn').onclick = function(e) {
document.getElementById('ltegte-result').style.display = '';
}
</script>
</p>
</section>
<section>
<h2>if/else</h2>
<p>remember this example?</p>
<p>
<pre><code data-trim style="max-height:none">
if (true) document.write("This is true! <br>");
if (false) document.write("You won't ever see this :( <br>");
</code></pre>
<script type="text/javascript">
if (true) document.write("This is true! <br>");
if (false) document.write("You won't ever see this :( <br>");
</script>
</p>
<aside class='notes'>
here we used an if to check the value and do stuff<br>
but we can also say if this is true, do this, otherwise do that<br>
</aside>
</section>
<section>
<h2>if/else</h2>
<p>
<pre><code data-trim style="max-height:none">
var score = 0
if (score < 15) {
document.write("Keep playing!");
} else {
document.write("Game over!");
}
</code></pre>
<div id='score-output-1'></div>
<button id='score-example-1'>Increase Score!</button><br>
<div id='score-play-1'></div>
<script type="text/javascript">
var score1 = 0;
document.getElementById('score-output-1').innerHTML = "Score: " + score1;
document.getElementById('score-play-1').innerHTML = "Keep playing! <br>";
document.getElementById('score-example-1').onclick = function(e) {
score1++;
document.getElementById('score-output-1').innerHTML = "Score: " + score1;
if (score1 < 15) {
document.getElementById('score-play-1').innerHTML = "Keep playing! <br>";
} else {
document.getElementById('score-play-1').innerHTML = "Game over! <br>";
document.getElementById('score-example-1').remove();
}
}
</script>
</p>
</section>
<section>
<h2>if/else if/else</h2>
<p>
<pre><code data-trim style="max-height:none">
var score = 0
if (score == 14) {
document.write("Game Point!");
} else if (score < 15) {
document.write("Keep playing!");
} else {
document.write("Game over!")
}
</code></pre>
<div id='score-output-2'></div>
<button id='score-example-2'>Increase Score!</button><br>
<div id='score-play-2'></div>
<script type="text/javascript">
var score2 = 0;
document.getElementById('score-output-2').innerHTML = "Score: " + score2;
document.getElementById('score-play-2').innerHTML = "Keep playing! <br>";
document.getElementById('score-example-2').onclick = function(e) {
score2++;
document.getElementById('score-output-2').innerHTML = "Score: " + score2;
if (score2 == 14) {
document.getElementById('score-play-2').innerHTML = "Game Point! <br>";
} else if (score2 < 15) {
document.getElementById('score-play-2').innerHTML = "Keep playing! <br>";
} else {
document.getElementById('score-play-2').innerHTML = "Game over! <br>";
document.getElementById('score-example-2').remove();
}
}
</script>
</p>
</section>
<section>
<h2>for loops</h2>
<p>
<pre><code data-trim style="max-height:none">
var animals = ['kitten', 'unicorn', 'narwhale'];
for (var i = 0; i < animals.length; i++) {
document.write(animals[i] + "<br>");
}
</code></pre>
<button id='animal-btn'>Show Result</button><br>
<div id='animal-result' style='display:none'>
<script type="text/javascript">
var animals = ['kitten', 'unicorn', 'narwhale'];
for (var i = 0; i < animals.length; i++) {
document.write(animals[i] + "<br>");
}
</script>
</div>
<script type='text/javascript'>
document.getElementById('animal-btn').onclick = function(e) {
document.getElementById('animal-result').style.display = '';
}
</script>
</p>
<aside class='notes'>
there are a few different kind of loops<br>
we're just going to cover the for - used most often<br>
</aside>
</section>
<section>
<h2>functions</h2>
<p>
<pre><code data-trim style="max-height:none">
var printAnimals = function(animals) {
for (var i = 0; i < animals.length; i++) {
document.write(animals[i] + "<br>");
}
}
var animals = ['kitten', 'unicorn', 'narwhale'];
printAnimals(animals);
</code></pre>
<button id='animal-btn-2'>Show Result</button><br>
<div id='animal-result-2' style='display:none'>
<script type="text/javascript">
var printAnimals = function(animals) {
for (var i = 0; i < animals.length; i++) {
document.write(animals[i] + "<br>");
}
}
var animals = ['kitten', 'unicorn', 'narwhale'];
printAnimals(animals);
</script>
</div>
<script type='text/javascript'>
document.getElementById('animal-btn-2').onclick = function(e) {
document.getElementById('animal-result-2').style.display = '';
}
</script>
</p>
<aside class='notes'>
there are a few different kind of loops<br>
we're just going to cover the for - used most often<br>
</aside>
</section>
<section>
<h2>break for kittens</h2>
<p>
<img src="http://38.media.tumblr.com/tumblr_me9l73QBGP1r1bbfqo1_500.gif">
</p>
</section>
<section>
<p>DOM API - getElementById</p>
<p>
<div id='dom-box' style='background-color:#66bbcc'> 4 </div>
<pre><code data-trim style="max-height:none">
<div id='dom-box' style='background-color:#66bbcc'> 4 </div>
</code></pre>
<pre><code data-trim style="max-height:none">
document.getElementById('dom-box').style.backgroundColor = '#bbcc66';
document.getElementById('dom-box').innerHTML = 'I am a box!';
</code></pre>
<button id='dom-btn'>Do It!</button><br>
<script type="text/javascript">
document.getElementById('dom-btn').onclick = function(e) {
document.getElementById('dom-box').style.backgroundColor = '#bbcc66';
document.getElementById('dom-box').innerHTML = 'I am a box!';
}
</script>
</p>
</section>
<section>
<p>DOM API - getElementsByTagName</p>
<p>
<img class='image-1' src="http://i.imgur.com/S3m7nIm.jpg" height="200">
<img class='image-1' src="http://i.imgur.com/OvwXd.jpg" height="200">
<pre><code data-trim style="max-height:none">
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
images[i].style.webkitFilter = 'grayscale(100%)';
}
</code></pre>
<button id='dom-btn-2'>Do It!</button><br>
<script type="text/javascript">
document.getElementById('dom-btn-2').onclick = function(e) {
var images = document.getElementsByClassName('image-1');
for (var i = 0; i < images.length; i++) {
images[i].style.webkitFilter = 'grayscale(100%)';
}
}
</script>
</p>
</section>
<section>
<h2>Events</h2>
<p>
onclick<br>
onmouseover<br>
onfocus<br>
onkeydown<br>
onscroll<br>
many, many more!<br>
</p>
</section>
<section>
<h2>Events</h2>
<p>
<img class='image-2' src="http://i.imgur.com/S3m7nIm.jpg" height="200">
<img class='image-2' src="http://i.imgur.com/OvwXd.jpg" height="200">
<pre><code data-trim style="max-height:none">
document.getElementById('dom-btn').onclick = function(e) {
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
images[i].style.webkitFilter = 'grayscale(100%)';
}
}
</code></pre>
<button id='dom-btn-3'>Do It!</button><br>
<script type="text/javascript">
document.getElementById('dom-btn-3').onclick = function(e) {
var images = document.getElementsByClassName('image-2');
for (var i = 0; i < images.length; i++) {
images[i].style.webkitFilter = 'grayscale(100%)';
}
}
</script>
</p>
</section>
<section>
<h2>flipbook example!</h2>
<p>
<img src="http://www.culivia.ro/wp-content/uploads/2012/08/kitten-and-facebook_email.jpg">
</p>
</section>
<section>
<h2>Thank You!</h2>
<p>
<a href='http://devdocs.io'>Devdocs.io</a><br>
<a href='https://developer.mozilla.org/en-US/'>MDN</a><br>
<img src="http://hbrysiewicz.github.io/assets/img/squirt.jpg" height="300">
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>