forked from claudeck/ppt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.html
882 lines (807 loc) · 26.4 KB
/
javascript.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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Javascript Study Guide</title>
<meta name="description" content="How to study Javascript">
<meta name="author" content="Claude Jiang">
<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">
<link rel="stylesheet" href="lib/css/github.css">
-->
<link rel="stylesheet" href="lib/css/xcode.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Javascript</h1>
<h1>Study Guide</h1>
<p>
<small>Speaker : <a href="http://www.claudejiang.com">Claude Jiang</a></small>
</p>
</section>
<section>
<h2>Outlines</h2>
<ul>
<li>My Javascript Exp</li>
<li>The Important parts</li>
<li>Debugging</li>
<li>Modular</li>
</ul>
</section>
<!-- Example of nested vertical slides -->
<section>
<section>
<h2>My Javascript Exp</h2>
<ul>
<li>IE6 age</li>
<li>Ajax</li>
<li>Rise of JS Library</li>
<li>NodeJS</li>
<li>Modular</li>
<li>HTML5</li>
</ul>
</section>
</section>
<section>
<h2>IE6 age</h2>
<ul>
<li>DHTML(DOM/HTML/CSS/JS)</li>
</ul>
<pre><code contenteditable class="javascript">
// depot/castro/wwwroot/ehealthinsurance/js/EHI_JavaScript.js
function hide_confirm(){
// use document.getElementById
// use dom navigate api directly
document.getElementById('_shield')
.parentNode.removeChild(document.getElementById('_shield'));
document.getElementById('_confirm')
.parentNode.removeChild(document.getElementById('_confirm'));
var button = document.getElementById('mcei.html.button.clicked:BidMethodCancel');
if(button!=null)
button.click();
}
</code></pre>
<pre><code contenteditable class="html">
<!-- event binding -->
<body onLoad="quickPopup.init();resetWaitMsg();" onUnload="resetPageVariables()">
</code></pre>
</section>
<section>
<section>
<h2>Ajax</h2>
<ul>
<li>Asynchronous</li>
<li>JavaScript</li>
<li>XML - Data</li>
</ul>
</section>
<section>
<h2>Asynchronous</h2>
<a class="test" href="http://www.adaptivepath.com/ideas/ajax-new-approach-web-applications">
<img width="600" height="500" src="http://www.adaptivepath.com/uploads/archive/images/publications/essays/ajax-fig2_small.png" alt="Unicorn">
</a>
</section>
<section>
<h2>XMLHttpRequest</h2>
<pre><code contenteditable class="javascript">
// depot/castro/wwwroot/ehealthinsurance/js/replayController.js
function loadXMLDoc(url,callback) {
var req = false;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if(window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
callback(req);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
};
req.open("GET", url, true);
req.send("");
}
}
</code></pre>
</section>
<section>
<h2>jQuery ajax</h2>
<pre><code contenteditable class="javascript">
////depot/castro/jsproot/ui-service/provider-search/provider-search.js
function removeProvider(clientId, uid, providerListLimit, searchResultId) {
var action = "removeProvider";
var parameters = "clientId=" + clientId + "&providerIdAndAddressId=" + uid;
var providerListElement = document.getElementById("provider-list");
$.ajax({
url: "provider-search-list-refresh!" + action,
data: parameters,
type: 'POST',
success: function(response) {callbackRefreshProviderList(response, providerListElement, searchResultId);},
error: handleAjaxError
});
}
</code></pre>
</section>
<section>
<h2>Data</h2>
<ul>
<li>HTML Segment/Plain Text</li>
<li>XML</li>
<li>JSON</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Rise of JS Library</h2>
<ul>
<li>PrototypeJS</li>
<li>ExtJS</li>
<li>jQuery</li>
</ul>
</section>
<section>
<h2>ExtJS(Sencha)</h2>
<ul>
<li>Fat Client/Single Page Application</li>
<li>Object-oriented</li>
</ul>
<a class="test" href="#">
<img width="400" height="300" src="img/sencha.png" alt="Unicorn">
</a>
</section>
<section>
<h2>jQuery</h2>
<ul>
<li>Selector/DOM/Events/Ajax</li>
<li>plug-ins</li>
</ul>
</section>
<section>
<h2>jQuery Sample</h2>
<pre><code contenteditable class="javascript">
// //depot/castro/wwwroot/ehealthinsurance/js/shopByAllPlans.js
$(document).ready(function(){
var filterClickHandler = function(event) {
var shopByForm = $("form[name='shop-by']")
if(shopByForm.length > 0){
shopByForm.submit();
}
}
$("#refine-search input.benefithotspot").hide(); // for js-enabled, hide the clear layers
$("#anyCompanyLayer").show();
$("#refine-search input:radio").click(filterClickHandler);
$("#refine-search input:checkbox").click(filterClickHandler);
});
</code></pre>
</section>
</section>
<section>
<section>
<h2>NodeJS</h2>
<ul>
<li>Node.js is a platform built on <font color="yellow">Chrome's JavaScript runtime</font> for easily building fast, scalable network applications. Node.js uses an <font color="yellow">event-driven</font>, <font color="yellow">non-blocking I/O</font> model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.</li>
</ul>
</section>
<section>
<h2>HTTP Server</h2>
<pre><code contenteditable class="javascript">
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
</code></pre>
<pre><code contenteditable class="bash">
% node example.js
Server running at http://127.0.0.1:1337/
</code></pre>
</section>
<section>
<h2>TCP Server</h2>
<pre><code contenteditable class="javascript">
var net = require('net');
var server = net.createServer(function (socket) {
socket.write('Echo server\r\n');
socket.pipe(socket);
});
server.listen(1337, '127.0.0.1');
</code></pre>
</section>
</section>
<section>
<h2>Modular</h2>
<ul>
<li>MVC/MVP/MVVM</li>
<li>AMD/CMD</li>
</ul>
<p></p>
<a class="test" href="#">
<img width="600" height="400" src="img/wad.png" alt="Unicorn">
</a>
</section>
<section>
<h2>HTML5</h2>
<ul>
<li>HTML Tags</li>
<li>Application Cache</li>
<li>Media Queries</li>
<li>Canvas</li>
<li>WebSocket</li>
<li>CSS3 Transform</li>
</ul>
</section>
<section>
<h2>The Important parts</h2>
<ul>
<li>Scope</li>
<li>Prototype Chain/Object-Oriented</li>
<li>Functional programming & Closure</li>
<li>this keyword</li>
<li>Asynchronous Programming</li>
</ul>
</section>
<section>
<section>
<h2>Scope</h2>
<ul>
<li>Function Scope</li>
<li>Global</li>
<li>Anonymous Function</li>
<li>Scope & Namespaces</li>
</ul>
</section>
<section>
<h2>Function Scope</h2>
<ul>
<li>Hoisting</li>
<li>Function Scope</li>
</ul>
<pre><code contenteditable class="javascript">
bar(); // works
var bar = function() {};
var someValue = 42;
function test() { // a scope
for(var i = 0; i < 10; i++) { // not a scope
// count
}
console.log(i); // 10
}
</code></pre>
</section>
<section>
<h2>Function Scope 2</h2>
<p>single var pattern</p>
<pre><code contenteditable class="javascript">
function updateElement() {
var el = document.getElementById("result"),
style = el.style;
// do something with el and style...
}
</code></pre>
</section>
<section>
<h2>Global</h2>
<ul>
<li>Browser - window object</li>
</ul>
<pre><code contenteditable class="javascript">
myglobal = "hello"; // antipattern
console.log(myglobal); // "hello"
console.log(window.myglobal); // "hello"
console.log(window["myglobal"]); // "hello"
console.log(this.myglobal); // "hello"
</code></pre>
</section>
<section>
<h2>Anonymous Function</h2>
<p>anonymous wrapper</p>
<pre><code contenteditable class="javascript">
;(function($){
var x = 0;
function test(){
return 1+1;
}
})(jQuery);
</code></pre>
</section>
<section>
<h2>Scope & Namespaces</h2>
<pre><code contenteditable class="javascript">
(function() {
// a self contained "namespace"
windows.myApp = {};
myApp.routers = myApp.routers || {};
myApp.model = myApp.model || {};
myApp.model.special = myApp.model.special || {};
})(); // execute the function immediately
</code></pre>
<aside class="notes">
使用匿名函数避免污染全局作用域
模块化开发,模拟命名空间
</aside>
</section>
</section>
<section>
<section>
<h2>Prototype Chain/Object-Oriented</h2>
</section>
<section>
<h2>Object-Oriented</h2>
<pre><code contenteditable class="javascript" >
function Foo() {
this.value = 42;
}
Foo.prototype = {
method: function() {}
};
var obj = {};
</code></pre>
<aside class="notes">
JavaScript的对象可以作为哈希表使用。
通过{}可以创建一个对象
被创建的函数指向构造函数的Prototype
</aside>
</section>
<section>
<h2>prototypal inheritance</h2>
<pre><code contenteditable class="javascript">
function Foo() {
this.value = 42;
}
Foo.prototype = {
method: function() {}
};
function Bar() {}
// Set Bar's prototype to a new instance of Foo
Bar.prototype = new Foo();
Bar.prototype.foo = 'Hello World';
// Make sure to list Bar as the actual constructor
Bar.prototype.constructor = Bar;
var test = new Bar(); // create a new bar instance
// The resulting prototype chain
test [instance of Bar]
Bar.prototype [instance of Foo]
{ foo: 'Hello World' }
Foo.prototype
{ method: ... }
Object.prototype
{ toString: ... /* etc. */ }
</code></pre>
<aside class="notes">
当查找一个对象的属性时,JavaScript 会向上遍历原型链,直到找到给定名称的属性为止。
到查找到达原型链的顶部 - 也就是 Object.prototype - 但是仍然没有找到指定的属性,就会返回 undefined
</aside>
</section>
</section>
<section>
<section>
<h2>Functional programming & Closure</h2>
<ul>
<li>Functional programming</li>
<li>Closure</li>
</ul>
</section>
<section>
<h2>Functional programming</h2>
<pre><code contenteditable class="javascript">
//First class
var func = function(a){console.log(a)};
//Functions as object
func.apply(window, [1]);
//Function as variable
var myarray=[25, 8, 7, 41]
myarray.sort(function(a,b){return a - b}) //Array now becomes [7, 8, 25, 41]
//Function as return value
var setup = function () {
console.log(1);
return function () {
console.log(2);
};
};
// using the setup function
var my = setup(); // alerts 1
my(); // alerts 2
</code></pre>
</section>
<section>
<h2>Closure</h2>
<pre><code contenteditable class="javascript" id="this_4">
function Counter(start) {
var count = start;
return {
increment: function() {
count++;
},
get: function() {
return count;
}
}
}
var foo = Counter(4);
foo.increment();
foo.get(); // 5
// depot/castro/wwwroot/ehealthinsurance/assets/js/quote/v1/quote.tip.popup.js
loadData: function(e){
// if the ajax data exist in the cookie.
var that = this;
$.ajax({
url: this.$el.attr('href'),
beforeSend: function() {
//TODO...
},
success: function(data) {
// add the exist ajax data to the old one.
that.$el.data('data', data);
$("#ehi-tip-popup").find("div.ehi-tip-popup-content").html(data);
// set position of the popup
if(that.tipPos == 'auto'){
that.setTipPosition(options, that.$el);
}else{
that.setTipPosition(options, that.$el.parents(that.tipPos));
}
},
error: function() {
//TODO...
},
statusCode: {
// if 404...
404: function() {
// set default text.
$('#ehi-tip-popup').html('page not found');
}
}
});
},
</code></pre>
<button jsrun="this_4">Run it</button>
<aside class="notes">
当前作用域总能访问外部作用域的变量
模拟私有变量
读取函数内部的变量
</aside>
</section>
</section>
<section>
<section>
<h2>this keyword</h2>
<ul>
<li>Function call</li>
<li>Use as Object method</li>
<li>Use as Object constructor</li>
<li>apply/call</li>
</ul>
</section>
<section>
<h2>Function call</h2>
<pre><code contenteditable class="javascript" id="this_1">
// depot/castro/wwwroot/ehealthinsurance/js/ehiTPIExitPopupChecker.js
function hasExited() {
realParent = window.opener;
var cookieVal = getCookie(cookieName);
if (cookieVal != null && cookieVal.toLowerCase() == "t") {
if ( this.document.domain != realParent.document.domain )
{ // Trap the error. If the parent and child domains differ then
// an error will be generated on attempting to read the parent value.
}
setTimeout ("hasExited();", 10 );
} else {
window.close();
}
}
</code></pre>
<button jsrun="this_1">Run it</button>
<aside class="notes">
this 指向global
</aside>
</section>
<section>
<h2>Use as Object method</h2>
<pre><code contenteditable class="javascript" id="this_2">
// depot/castro/wwwroot/ehealthinsurance/js/provider_v3.js
function PageMasker(){}
PageMasker.prototype.show = function(){
$('body').append('<div class="pageMasker" style="background-color: #ffffff;position:absolute;z-index: 99999;top: 0;left: 0;"><div class="loadingImage" style="position:relative;float:left;"><img alt="loading" src="/ehealthinsurance/images_new/loadinfo.gif"/></div></div>');
this.$el = $('.pageMasker');
this.$el.height($(document).height())
.width($(document).width())
.css('opacity', '0.5');
this.$el.find('.loadingImage').css({
left: ($(window).width() - this.$el.find('.loadingImage img').width()) / 2,
top: ($(window).height() - this.$el.find('.loadingImage img').height()) / 2
});
};
PageMasker.prototype.hide = function(){
this.$el.remove()
}
$(document).ready(function(){
$('form').submit(function(){
var masker = new PageMasker();
masker.show();
})
});
</code></pre>
<button jsrun="this_2">Run it</button>
<aside class="notes">
this 指向对象
</aside>
</section>
<section>
<h2>Use in Object constructor</h2>
<pre><code contenteditable class="javascript" id="this_3">
function Bar(x){
this.x = x;
}
Bar.prototype.hello = function(){
alert('hello,' + this.x);
};
var foo = new Bar('claude');
foo.hello();
</code></pre>
<button jsrun="this_3">Run it</button>
<aside class="notes">
this 指向新创建的对象
</aside>
</section>
<section>
<h2>apply/call</h2>
<pre><code contenteditable class="javascript" id="this_4">
function foo(a, b, c) {
alert(a + b + c);
}
var bar = {};
foo.apply(bar, [1, 2, 3]); // array will expand to the below
foo.call(bar, 1, 2, 3); // results in a = 1, b = 2, c = 3
// create function with special context.
function hoo(context){
return function(data){
foo.apply(context, [data]);
}
};
$.ajax({
url: 'data.json',
dataType: 'json',
success: hoo(context)
})
</code></pre>
<button jsrun="this_4">Run it</button>
<aside class="notes">
this 显式的指向函数调用的第一个对象
</aside>
</section>
</section>
<section>
<section>
<h2>Asynchronous Programming</h2>
<ul>
<li>Callback Function</li>
<li>Observer Pattern|Event|Pub/Sub</li>
<li>Promises</li>
<li>Wind.js</li>
</ul>
</section>
<section>
<h2>Callback Function</h2>
<pre><code contenteditable class="javascript" id="this_4">
$.ajax({
url: "test.html",
context: document.body,
success: function(data){
$(this).addClass("done");
}
});
</code></pre>
<button jsrun="this_4">Run it</button>
</section>
<section>
<h2>Observer Pattern(Listener|Pub/Sub)</h2>
<pre><code contenteditable class="javascript" id="this_4">
$.bind('ajaxSuccess', function(e, data){
alert(data);
});
$.ajax({
url: "test.html",
context: document.body,
success: function(data){
$.trigger('ajaxSuccess', [data]);
}
});
</code></pre>
<button jsrun="this_4">Run it</button>
</section>
<section>
<h2>Promises/jQuery deferred</h2>
<pre><code contenteditable class="javascript" id="this_4">
// new jQuery ajax api
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$(this).addClass("done");
});
//without deferred
$.get("/token", params, function (data) {
$.get("/order/last", params2, function(data) {
$.delete("/order", params3, function(data) {
$("#some_div").text("OK");
});
});
});
//with deferred
$.get("/token", params)
.pipe(function(data){
// Note that here "this" refers to the
// jqXHR, which also is a deferred
return $.get("/order/last", params);
})
.pipe(function(data){
return $.delete("/order", params);
})
.pipe(function(data){
$("#some_div").text("OK");
});
</code></pre>
<button jsrun="this_4">Run it</button>
</section>
<section>
<h2>Wind.js</h2>
<pre><code contenteditable class="javascript" id="this_4">
var val = $await($.ajax({url: 'text.html'}));
</code></pre>
<button jsrun="this_4">Run it</button>
</section>
</section>
<section>
<section>
<h2>Debugging</h2>
<ul>
<li>Debugger tool</li>
<li>The debugger; statement</li>
<li>console.log</li>
</ul>
</section>
<section>
<h2>Debugger tool</h2>
<ul>
<li>Chrome webkit interceptor</li>
<li>Firefox firebug</li>
<li>IE developer tool</li>
</ul>
</section>
<section>
<h2>The debugger; statement</h2>
<pre><code contenteditable class="javascript" id="debugger">
function test(){
debugger;
alert(this.x);
}
var o = {};
o.x = 1;
o.m = test;
o.m();
</code></pre>
<button jsrun="debugger">Run it</button>
</section>
<section>
<h2>console.log</h2>
<pre><code contenteditable class="javascript" id="console">
function test(){
console.log(this.x);
alert(this.x);
}
var o = {};
o.x = 1;
o.m = test;
o.m();
</code></pre>
<button jsrun="console">Run it</button>
</section>
</section>
<section>
<section>
<h2>Modular Development</h2>
<p>AMD</p>
<p>MVC</p>
</section>
<section>
<h2>AMD</h2>
<p>Common/JS</p>
<p>RequestJS</p>
<p>SeaJS</p>
</section>
<section>
<h2>MVC</h2>
<p>BackboneJS</p>
<p>AngularJS</p>
</section>
</section>
<section>
<h2>The Future of Javascript</h2>
<ul>
<li>ECMAScript</li>
<li>jsVM - CoffeeScript/Dart/TypeScript</li>
<li>HTML5</li>
<li>Server Side</li>
<li>Desktop</li>
</ul>
</section>
<section>
<h1>THE END</h1>
<h3>BY Claude Jiang</h3>
</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
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/showdown.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; } },
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
{ src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
Reveal.addEventListener('ready', function(){
var jsRuns = document.querySelectorAll('[jsrun]');
for(var i = 0; i < jsRuns.length; i++){
jsRuns[i].addEventListener('click', function(){
var jsrun = this.getAttribute('jsrun');
var js = document.getElementById(jsrun);
eval(js.innerText);
});
}
});
</script>
</body>
</html>