-
Notifications
You must be signed in to change notification settings - Fork 4
/
KantorAnimation.html
1107 lines (970 loc) · 37.7 KB
/
KantorAnimation.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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="Author" content="Leslie Bondaryk" />
<meta name="Owner" content="Pearson" />
<meta name="Copyright" content="Copyright (c) 2013 Pearson. All rights reserved." />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="Carmen Santiago, Demo Book" name="description" />
<title class="setTitle"></title>
<!-- bootstrap_plus.css contains styling for the dropdown menu and other common core styles -->
<link href="css/bootstrap_plus.css" rel="stylesheet" media="screen">
<!-- widgets.css contains styling for the interactive brix -->
<link href="css/widgets.css" rel="stylesheet">
<!-- eCourse-master.css contains styling for all the navigation -->
<link href="css/eCourse-master.css" rel="stylesheet" media="screen">
<!-- content_styles.css contains styling for the narrative layout and responsive design -->
<link href="css/content_styles.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<div class="span12 lc_ec_page">
<section class="lc_ec_fiftyFifty lc_ec_pageInner">
<div class="lc_ec_content">
<h2 class="lc_ec_bHead"><span class='number setId'></span>
<span class="setTitle"></span>
</h2>
<div class="lc_ec_leading">
<p>Stereoisomerism refers to variations in the three-dimensional organization of atoms for molecules with the same formula and connectivity (constitution). These variances will be the focus of this chapter. Consider but-2-ene for which the connectivity can be described as a CH3 group bonded to a CH, which in turn is doubly bonded to another CH, and then finally singly bonded to a CH3 group. Due to the trigonal planar geometry about the alkenyl carbons, there are two possible ways to express this structure, both of which are shown. </p>
<p>In one case, the two methyl groups are distal to each other, whereas in the second version they are proximal. Select either of the two ball-and-stick models below to see the cis and trans configurations of the but-2-ene molecule. <span id="button0_2"></span></p>
<div id="picture0"></div>
<p>The π bond in but-2-ene restricts rotation about the C2-C3 bond, preventing either of these from converting into the other. Despite their identical connectivity, they are not superposable structures and are, therefore, stereoisomers.</p>
<div id="threedButeneTrans"><span id="buteneslider"></span></div>
</div>
<div class="lc_ec_trailing">
<p>Alkenes are stereogenic if switching two of the groups attached to the same alkenyl carbon results in a stereoisomer. Transposing a hydrogen and a methyl group attached to the same carbon in but-2-ene produces a structure that is not superposable on the original compound. </p>
<span id="button1"></span>
<div id="picture1"></div>
<div class="form-actions">
<p>Touch each compound to simplify it. Then select the two that are the same (not stereoisomers).</p>
<span class="btn-primary" id="button7"></span>
<div id="picture7"></div>
</div>
<p style="color:blue;">TIP: In evaluating whether or not the alkene is stereogenic, it is satisfactory to perform the substituent change on one of the alkenyl carbons.</p>
<p><b>Discovery Exercise 7.1.2 Testing for Stereoisomerism in Alkenes with Identical Substituents on the Same Carbon</b></p>
<p style="color:blue;">Simplify the compounds, then select the two that are identical (not stereoisomers).</p>
<span id="button6"></span>
<div id="picture6"></div>
<p>As the substituents about the alkene increase in complexity it is advantageous to simplify the groups using substitutive labels. For example, the relationship among the three alkene isomers shown is not immediately obvious. The alkyl branches have been inconveniently drawn in different conformations. This precludes a simple inspection of superposability. By replacing the alkyl substituents with their <b>abbreviated labels</b> [Provide a pop-up list; see below after Figure 7.1.7] the conformational permutations, while still occurring, no longer complicate the analysis and the relationships become apparent.</p>
</div>
</div>
</section>
</div>
</div>
<script src="js/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui-1.10.2.custom.js"></script>
<script src="js/toc-structure.js"></script>
<script src="js/eCourse-master.js"></script>
<script src="js/d3.v3.min.js"></script>
<script src="js/brixlib-compiled.js"></script>
<!--
<script src="js/widget-base.js"></script>
<script src="js/widgets.js"></script>
<script src="js/widget-button.js"></script>
<script src="js/widget-sketch.js"></script>
<script src="js/widget-image.js"></script>
<script src="js/widget-carousel.js"></script>
<script src="js/widget-imageviewer.js"></script>
<script src="js/widget-callouts.js"></script>
<script src="js/widget-labelgroup.js"></script>
<script src="js/widget-slider.js"></script>
<script src="js/widget-numeric.js"></script>
<script src="js/eventmanager.js"></script>
!-->
<script>
// local aliases for convenience
var Size = pearson.utils.Size;
var SVGContainer = pearson.brix.SVGContainer;
var Image = pearson.brix.Image;
var CaptionedImage = pearson.brix.CaptionedImage;
var Carousel = pearson.brix.Carousel;
var ImageViewer = pearson.brix.ImageViewer;
var Callouts = pearson.brix.Callouts;
var LabelGroup = pearson.brix.LabelGroup;
var Slider = pearson.brix.Slider;
var Button = pearson.brix.Button;
var Readout = pearson.brix.Readout;
var Sketch = pearson.brix.Sketch;
var EventManager = pearson.utils.EventManager;
var SubmitManager = pearson.brix.SubmitManager;
var MultipleChoiceQuestion = pearson.brix.MultipleChoiceQuestion;
var SelectGroup = pearson.brix.SelectGroup;
var eventManager = new EventManager();
//////////////////////////////////////////////
var svg0 = new SVGContainer({
node: d3.select("#picture0"),
maxWid: 477,
maxHt: 270
});
var sketch0_1 = new Sketch ({
id: "sketch0_1",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.14, .9], length: 0.1, angle: -Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.14, .7], length: 0.1, angle: Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.26, .78], length: 0.1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.26, .82], length: 0.1, angle: 0 }]},
{ shape: "textBit", data: [{ xyPos: [.10, .89], text: 'H3C'}]},
{ shape: "textBit", data: [{ xyPos: [.23, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.4, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.12, .68], text: 'H'}]},
]
});
var sketch0_2 = new Sketch ({
id: "sketch0_2",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.5, .9], length: 0.1, angle: -4*Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.5, .7], length: 0.1, angle: 4*Math.PI/5 }]},
{ shape: "textBit", data: [{ xyPos: [.53, .9], text: 'H' }]},
{ shape: "textBit", data: [{ xyPos: [.54, .68], text: 'H3C' }]},
]
});
var sketch0_3 = new Sketch ({
id: "sketch0_3",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.1, .8], length: .1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.1, .82], length: .1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.1, .8], length: .1, angle: -4*Math.PI/5 }]},
]
});
var sketch0_4 = new Sketch ({
id: "sketch0_4",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.1, .8], length: .08, angle: 3*Math.PI/4 }]},
{ shape: "textBit", data: [{ xyPos: [.02, .88], text: 'H' }]},
]
});
var sketch0_5 = new Sketch ({
id: "sketch0_5",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.2, .8], length: .1, angle: Math.PI/5 }]},
]
});
var sketch0_6 = new Sketch ({
id: "sketch0_6",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.2, .8], length: .08, angle: -Math.PI/4 }]},
{ shape: "textBit", data: [{ xyPos: [.3, .72], text: 'H' }]},
]
});
svg0.append(sketch0_1, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: .6});
svg0.append(sketch0_2, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: .6});
svg0.append(sketch0_3, {topPercentOffset: 0.4, leftPercentOffset: 0.1, heightPercent: 1, widthPercent: .8});
svg0.append(sketch0_4, {topPercentOffset: 0.4, leftPercentOffset: 0.1, heightPercent: 1, widthPercent: .8});
svg0.append(sketch0_5, {topPercentOffset: 0.4, leftPercentOffset: 0.1, heightPercent: 1, widthPercent: .8});
svg0.append(sketch0_6, {topPercentOffset: 0.4, leftPercentOffset: 0.1, heightPercent: 1, widthPercent: .8});
var button0_2 = new Button ({
id: "b0_2",
text: "Show/Hide Hydrogens"
}, eventManager);
button0_2.draw(d3.select('#button0_2'));
//////////////////////////////////////////////
/* ball and stick models in a carousel */
//////////////////////////////////////////////
var ballStick_imgs = new ImageViewer({
items:
[
new Image({
URI: 'img/Trans-but-2-ene-3D-balls.png',
caption: "Trans but-2-ene",
actualSize: {height: 740, width: 1100}
}),
new Image({
URI: 'img/Cis-but-2-ene-3D-balls.png',
caption: "Cis but-2-ene",
actualSize: {height: 740, width: 1100},
})
],
displayWidth: 476/2
}, eventManager);
svg0.append(ballStick_imgs,{topPercentOffset: 0, leftPercentOffset: .5, heightPercent: 1, widthPercent: 0.5});
//eventManager.subscribe(button0_1.pressedEventId, handleClick0_1);
eventManager.subscribe(button0_2.pressedEventId, handleClick0_2);
eventManager.subscribe(ballStick_imgs.selectedEventId, handleSelect);
//set the lite key so we can swap between carousel images
var liteKey = "0";
function handleSelect(eventDetails)
{
sketch0_2.reflect(null, .8, 500, 0);
sketch0_5.reflect(null, .8, 500, 0);
sketch0_6.reflect(null, .8, 500, 0);
liteKey = eventDetails.selectKey;
ballStick_imgs.lite(liteKey);
}
function handleClick0_1 (eventDetails)
{
liteKey = (liteKey == "0") ? "1" : "0";
ballStick_imgs.lite(liteKey);
}
var opaque0 = true;
function handleClick0_2 ()
{
if (opaque0)
{
sketch0_4.setOpacity(0, 500, 0);
sketch0_6.setOpacity(0, 500, 0);
opaque0 = false;
}
else
{
sketch0_4.setOpacity(1, 500, 0);
sketch0_6.setOpacity(1, 500, 0);
opaque0 = true;
}
}
//////////////////////////////////////////////
var svg1 = new SVGContainer({
node: d3.select("#picture1"),
maxWid: 400,
maxHt: 100
});
// original sketch, does not change
var sketch1_1 = new Sketch ({
id: "sketch1_1",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.14, .9], length: 0.1, angle: -Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.14, .7], length: 0.1, angle: Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.26, .78], length: 0.1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.26, .82], length: 0.1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.5, .9], length: 0.1, angle: -4*Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.5, .7], length: 0.1, angle: 4*Math.PI/5 }]},
{ shape: "textBit", data: [{ xyPos: [.12, .89], text: 'H'}]},
{ shape: "textBit", data: [{ xyPos: [.23, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.4, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.08, .69], text: 'H3C'}]},
{ shape: "textBit", data: [{ xyPos: [.56, .9], text: 'CH3' }]},
{ shape: "textBit", data: [{ xyPos: [.56, .7], text: 'H' }]},
]
});
// duplicated sketch is split up so different parts can move separately
var sketch1_2 = new Sketch ({
id: "sketch1_2",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.14, .9], length: 0.1, angle: -Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.14, .7], length: 0.1, angle: Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.26, .78], length: 0.1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.26, .82], length: 0.1, angle: 0 }]},
{ shape: "textBit", data: [{ xyPos: [.12, .89], text: 'H'}]},
{ shape: "textBit", data: [{ xyPos: [.23, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.4, .78], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.08, .69], text: 'H3C'}]},
]
});
// right side of molecule is separated so it can be reflected
var sketch1_3 = new Sketch ({
id: "sketch1_3",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.5, .9], length: 0.1, angle: -4*Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.5, .7], length: 0.1, angle: 4*Math.PI/5 }]},
{ shape: "textBit", data: [{ xyPos: [.56, .9], text: 'CH3' }]},
{ shape: "textBit", data: [{ xyPos: [.56, .7], text: 'H' }]},
]
});
// message is also a sketch - I have turned this off in favor of the
// label implementation, which can also have it's opacity set
var sketch1_4 = new Sketch ({
id: "sketch1_4",
drawShape:
[
{ shape: "textBit", data: [{ xyPos: [.85, .84], text: 'These structures are non-' }]},
{ shape: "textBit", data: [{ xyPos: [.85, .8], text: 'superposable and are' }]},
{ shape: "textBit", data: [{ xyPos: [.85, .76], text: 'therefore stereoisomers.' }]},
]
});
var explain = new LabelGroup({
labels:
[
{content: "These structures are non-superposable and are therefore stereoisomers.",
xyPos: [.4,.9], width: 140 },
]
});
svg1.append(sketch1_1, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 2, widthPercent: .6});
svg1.append(sketch1_2, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 2, widthPercent: .6});
svg1.append(sketch1_3, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 2, widthPercent: .6});
//svg1.append(sketch1_4, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 2, widthPercent: .6});
svg1.append(explain);
// message starts out invisible
//sketch1_4.setOpacity(0, 0, 0);
explain.setOpacity(0, 0, 0);
// button used to advance the animation
var button1 = new Button ({
id: "b1",
text: "Reflect and Compare"
}, eventManager);
button1.draw(d3.select('#button1'));
eventManager.subscribe(button1.pressedEventId, handleClick1);
// animation is advanced by clicking a button
var click1 = 0;
function handleClick1 ()
{
// move duplicate sketch to the side
if (click1 == 0)
{
sketch1_2.move(.7, 0, 1000, 0);
sketch1_3.move(.7, 0, 1000, 0);
click1 ++;
}
// switch
else if (click1 == 1)
{
sketch1_3.reflect(null, .8, 500, 0);
click1 ++;
}
// superimpose second sketch on top of the first and display the message
else if (click1 == 2)
{
sketch1_2.move(-.7, -.07, 1000, 0);
sketch1_3.move(-.7, -.07, 1000, 0);
//sketch1_4.setOpacity(1, 500, 1000);
explain.setOpacity(1,500,1000);
click1 ++;
}
// reset
else if (click1 == 3)
{
sketch1_2.move(0, .07, 0, 0);
sketch1_3.move(0, .07, 0, 0);
sketch1_3.reflect(null, .8, 0, 0);
//sketch1_4.setOpacity(0, 0, 0);
explain.setOpacity(0, 0, 0);
click1 = 0;
}
}
//////////////////////////////////////////////
/* ball and stick models in a carousel */
//////////////////////////////////////////////*
var svg3D = new SVGContainer({
node: d3.select("#threedButeneTrans"),
maxWid: 477,
maxHt: 1100
});
var fullrot = new ImageViewer({
items:
[
new Image({
URI: 'img/butene/trans01.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/trans03.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/trans05.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/trans07.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/trans09.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/trans11.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
],
}, eventManager);
var fullrot2 = new ImageViewer({
items:
[
new Image({
URI: 'img/butene/cis01.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/cis03.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/cis05.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/cis07.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/cis09.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
new Image({
URI: 'img/butene/cis11.jpg',
caption: "",
actualSize: {height: 375, width: 400}
}),
],
}, eventManager);
svg3D.append(fullrot, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: .5, widthPercent: 1});
svg3D.append(fullrot2, {topPercentOffset: 0.5, leftPercentOffset: 0, heightPercent: .5, widthPercent: 1});
var buteneExtent = [1, 6];
var buteneSlide1 = new Slider ({
id: "b1Val",
startVal: 1,
minVal: buteneExtent[0],
maxVal: buteneExtent[1],
stepVal: 1,
label: "Image set 1",
format: d3.format('5.0f'),
}, eventManager);
buteneSlide1.draw(d3.select("#buteneslider"));
eventManager.subscribe(buteneSlide1.changedValueEventId, buteneHandleChangedValue1);
eventManager.subscribe(fullrot.selectedEventId, buteneHandleSelection1);
function buteneHandleChangedValue1 (newValue)
{
var newval = d3.round(buteneSlide1.getValue(), 1);
fullrot.selectItemAtIndex(newval - 1);
}
function buteneHandleSelection1 ()
{
var newImage = fullrot.selectedItem();
var newval = fullrot.itemKeyToIndex(newImage.key);
buteneSlide1.setValue(newval + 1);
}
///////////////////////////////////////////////
var svg6 = new SVGContainer({
node: d3.select("#picture6"),
maxWid: 300,
maxHt: 300
});
// original sketch is divided into two parts
var sketch6_1 = new Sketch ({
id: "sketch6_1",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.14, .8], length: 0.1, angle: -Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.14, .6], length: 0.1, angle: Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.26, .68], length: 0.1, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.26, .72], length: 0.1, angle: 0 }]},
{ shape: "textBit", data: [{ xyPos: [.12, .79], text: 'H'}]},
{ shape: "textBit", data: [{ xyPos: [.23, .68], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.4, .68], text: 'C'}]},
{ shape: "textBit", data: [{ xyPos: [.08, .59], text: 'H3C'}]},
]
});
// the right side of the molecule can be flipped
var sketch6_2 = new Sketch ({
id: "sketch6_2",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.5, .8], length: 0.1, angle: -4*Math.PI/5 }]},
{ shape: "line", data: [{ xyPos: [.5, .6], length: 0.1, angle: 4*Math.PI/5 }]},
{ shape: "textBit", data: [{ xyPos: [.54, .8], text: 'Cl' }]},
{ shape: "textBit", data: [{ xyPos: [.54, .6], text: 'Cl' }]},
]
});
// message to be displayed
var sketch6_3 = new Sketch ({
id: "sketch6_3",
drawShape:
[
{ shape: "textBit", data: [{ xyPos: [.4, .9], text: "Not a stereocenter" }]},
{ shape: "line", data: [{ xyPos: [.4, .88], length: .13, angle: -Math.PI/2, type: "vector" }]},
{ shape: "textBit", data: [{ xyPos: [.35, .5], text: "Not a stereocenter" }]},
{ shape: "line", data: [{ xyPos: [.32, .54], length: .12, angle: 2*Math.PI/3, type: "vector" }]},
{ shape: "textBit", data: [{ xyPos: [.7, .7], text: "Identical" }]},
{ shape: "line", data: [{ xyPos: [.6, .73], length: .04, angle: 2*Math.PI/3, type: "vector" }]},
{ shape: "line", data: [{ xyPos: [.6, .69], length: .04, angle: -2*Math.PI/3, type: "vector" }]},
]
});
// button used to reset animation
var button6 = new Button ({
id: "b6",
text: "Click to advance"
}, eventManager);
button6.draw(d3.select('#button6'));
svg6.append(sketch6_1, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg6.append(sketch6_2, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg6.append(sketch6_3, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
// message starts out invisible
sketch6_3.setOpacity(0, 0, 0);
eventManager.subscribe(button6.pressedEventId, handleClick6);
// animation can be played once and reset using the button
var click6 = 0;
function handleClick6 ()
{
// play the animation
if (click6 == 0)
{
sketch6_2.reflect(null, .7, 800, 0);
sketch6_3.setOpacity(1, 600, 1000);
click6 ++;
}
// reset
else if (click6 == 1)
{
sketch6_3.setOpacity(0, 0, 0);
click6 = 0;
}
}
///////////////////////////////////////////
var svg7 = new SVGContainer({
node: d3.select("#picture7"),
maxWid: 400,
maxHt: 400
});
// message for part 1 of interactive exercise
var sketch7_0 = new Sketch ({
id: "sketch7_0",
drawShape:
[
{ shape: "textBit", data: [{ xyPos: [.98, .8], text: "Touch each structure" }]},
{ shape: "textBit", data: [{ xyPos: [.98, .76], text: "to simplify it" }]}
]
});
// message for part 2 of interactive exercise
var sketch7_01 = new Sketch ({
id: "sketch7_01",
drawShape:
[
{ shape: "textBit", data: [{ xyPos: [.98, .45], text: "Touch the two" }]},
{ shape: "textBit", data: [{ xyPos: [.98, .41], text: "identical structures" }]},
]
});
// left molecule (clickable)
var sketch7_1 = new Sketch ({
id: "sketch7_1",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.15, .8], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.15, .8], length: .05, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.15, .8], length: .05, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.108, .775], length: .05, angle: 5*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.065, .8], length: .05, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.15, .79], length: .04, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.192, .775], length: .05, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.192, .775], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.192, .725], length: .05, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.15, .7], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.235, .8], length: .05, angle: -Math.PI/6 }]},
]
});
var hotspot7_1 = new Sketch ({
id: "hotspot7_1",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [0, .85], width: .3, height: .2 }]},
]
}, eventManager);
// middle molecule (clickable)
var sketch7_2 = new Sketch ({
id: "sketch7_2",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.4, .75], length: .05, angle: 5*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.358, .775], length: .05, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.358, .825], length: .05, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.4, .75], length: .05, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.442, .775], length: .05, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.41, .745], length: .04, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.4, .75], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.4, .7], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.442, .775], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.484, .75], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.484, .7], length: .05, angle: -Math.PI/6 }]},
]
});
var hotspot7_2 = new Sketch ({
id: "hotspot7_2",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [.35, .85], width: .2, height: .2 }]},
]
}, eventManager);
// right molecule (clickable)
var sketch7_3 = new Sketch ({
id: "sketch7_3",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.7, .775], length: .05, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.658, .75], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.658, .7], length: .05, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.7, .775], length: .05, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.7, .775], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.7, .765], length: .04, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.742, .75], length: .05, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.742, .7], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.742, .75], length: .05, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.784, .775], length: .05, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.784, .825], length: .05, angle: Math.PI/6 }]},
]
});
var hotspot7_3 = new Sketch ({
id: "hotspot7_3",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [.6, .85], width: .25, height: .2 }]},
]
}, eventManager);
// arrow with left molecule
var sketch7_4 = new Sketch ({
id: "sketch7_4",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.15, .625], length: .05, angle: -Math.PI/2, type: "vector" }]},
]
});
// arrow with middle molecule
var sketch7_5 = new Sketch ({
id: "sketch7_5",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.442, .625], length: .05, angle: -Math.PI/2, type: "vector" }]},
]
});
// arrow with right molecule
var sketch7_6 = new Sketch ({
id: "sketch7_6",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.72, .625], length: .05, angle: -Math.PI/2, type: "vector" }]},
]
});
// simplified left molecule (clickable)
var sketch7_7 = new Sketch ({
id: "sketch7_7",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.125, .45], length: .04, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.125, .45], length: .04, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.125, .45], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.135, .455], length: .04, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.167, .425], length: .04, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.167, .425], length: .04, angle: Math.PI/6 }]},
{ shape: "textBit", data: [{ xyPos: [.125, .5], text: 'Me' }]},
{ shape: "textBit", data: [{ xyPos: [.065, .41], text: 'Pr' }]},
{ shape: "textBit", data: [{ xyPos: [.22, .45], text: 'Et' }]},
{ shape: "textBit", data: [{ xyPos: [.165, .355], text: 'Pr' }]},
]
});
var hotspot7_4 = new Sketch ({
id: "hotspot7_4",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [.05, .55], width: .2, height: .2 }]},
]
}, eventManager);
// simplified middle molecule (clickable)
var sketch7_8 = new Sketch ({
id: "sketch7_8",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.437, .425], length: .04, angle: 5*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.437, .425], length: .04, angle: -Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.437, .425], length: .05, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.447, .42], length: .04, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.479, .45], length: .04, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.479, .45], length: .04, angle: -Math.PI/6 }]},
{ shape: "textBit", data: [{ xyPos: [.48, .5], text: 'Me' }]},
{ shape: "textBit", data: [{ xyPos: [.385, .45], text: 'Pr' }]},
{ shape: "textBit", data: [{ xyPos: [.435, .355], text: 'Et' }]},
{ shape: "textBit", data: [{ xyPos: [.535, .41], text: 'Pr' }]},
]
});
var hotspot7_5 = new Sketch ({
id: "hotspot7_5",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [.35, .55], width: .2, height: .2 }]},
]
}, eventManager);
// simplified right molecule (clickable)
var sketch7_9 = new Sketch ({
id: "sketch7_9",
drawShape:
[
{ shape: "line", data: [{ xyPos: [.715, .45], length: .04, angle: 7*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.715, .45], length: .04, angle: Math.PI/2 }]},
{ shape: "line", data: [{ xyPos: [.715, .45], length: .05, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.725, .455], length: .04, angle: -Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.757, .425], length: .04, angle: Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.757, .425], length: .04, angle: -Math.PI/2 }]},
{ shape: "textBit", data: [{ xyPos: [.715, .5], text: 'Me' }]},
{ shape: "textBit", data: [{ xyPos: [.655, .41], text: 'Pr' }]},
{ shape: "textBit", data: [{ xyPos: [.81, .45], text: 'Pr' }]},
{ shape: "textBit", data: [{ xyPos: [.755, .355], text: 'Et' }]},
]
});
var hotspot7_6 = new Sketch ({
id: "hotspot7_6",
type: "hot",
drawShape:
[
{ shape: "rectangle", fill: "Black", data: [{ xyPos: [.6, .55], width: .2, height: .2 }]},
]
}, eventManager);
// message to be displayed upon incorrect answer
var sketch7_10 = new Sketch ({
id: "sketch7_10",
drawShape:
[
{ shape: "textBit", data: [{ xyPos: [.5, .2], text: "Incorrect" }]}
]
});
// message to be displayed upon correct answer
var sketch7_11 = new Sketch ({
id: "sketch7_11",
drawShape:
[
{ shape: "rectangle", data: [{ xyPos: [.04, .54], width: .22, height: .2 }]},
{ shape: "rectangle", data: [{ xyPos: [.355, .54], width: .48, height: .2 }]},
{ shape: "line", data: [{ xyPos: [.58, .45], length: .03, angle: 0 }]},
{ shape: "line", data: [{ xyPos: [.58, .435], length: .03, angle: 0 }]},
{ shape: "textBit", data: [{ xyPos: [.6, .3], text: "homomers" }]},
{ shape: "textBit", data: [{ xyPos: [.32, .26], text: "stereoisomers" }]},
{ shape: "line", data: [{ xyPos: [.25, .29], length: .1, angle: 5*Math.PI/6 }]},
{ shape: "line", data: [{ xyPos: [.39, .29], length: .1, angle: Math.PI/6 }]},
{ shape: "textBit", data: [{ xyPos: [.5, .2], text: "Correct" }]},
]
});
// button used to reset animation
var button7 = new Button ({
id: "b7",
text: "Click to reset"
}, eventManager);
button7.draw(d3.select("#button7"));
// draw all the sketches
svg7.append(sketch7_0, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_01, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_1, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_2, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_3, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_4, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_5, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_6, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_7, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_8, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_9, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_10, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(sketch7_11, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
// draw all the hotspots
svg7.append(hotspot7_1, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(hotspot7_2, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(hotspot7_3, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(hotspot7_4, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(hotspot7_5, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
svg7.append(hotspot7_6, {topPercentOffset: 0, leftPercentOffset: 0, heightPercent: 1, widthPercent: 1});
// hotspots and button trigger events
eventManager.subscribe(hotspot7_1.selectedEventId, handleClick7_1);
eventManager.subscribe(hotspot7_2.selectedEventId, handleClick7_2);
eventManager.subscribe(hotspot7_3.selectedEventId, handleClick7_3);
eventManager.subscribe(hotspot7_4.selectedEventId, handleClick7_4);
eventManager.subscribe(hotspot7_5.selectedEventId, handleClick7_5);
eventManager.subscribe(hotspot7_6.selectedEventId, handleClick7_6);
eventManager.subscribe(button7.pressedEventId, handleClick7_7);
// much of the exercise starts out invisible
sketch7_01.setOpacity(0, 0, 0);
sketch7_4.setOpacity(0, 0, 0);
sketch7_5.setOpacity(0, 0, 0);
sketch7_6.setOpacity(0, 0, 0);
sketch7_7.setOpacity(0, 0, 0);
sketch7_8.setOpacity(0, 0, 0);
sketch7_9.setOpacity(0, 0, 0);
sketch7_10.setOpacity(0, 0, 0);
sketch7_11.setOpacity(0, 0, 0);
var reveal7_1 = 0; // flag for when simplified left molecule is revealed
var reveal7_2 = 0; // flag for when simplified middle molecule is revealed
var reveal7_3 = 0; // flag for when simplified right molecule is revealed
var click7 = 0; // keeps track of how many simplified molecules have been clicked
var first7 = 0; // marks which simplified molecule was chosen first
var second7 = 0; // marks which simplified molecule was chosen second
var canclick7 = true; // false if nothing can be clicked (animation running)
// reveal left simplifed molecule
function handleClick7_1 ()
{
sketch7_4.setOpacity(1, 500, 0);
sketch7_7.setOpacity(1, 500, 0);
reveal7_1 = 1;
// reveal message if all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1) sketch7_01.setOpacity(1, 500, 0);
}
// reveal middle simplified molecule
function handleClick7_2 ()
{
sketch7_5.setOpacity(1, 500, 0);
sketch7_8.setOpacity(1, 500, 0);
reveal7_2 = 1;
// reveal message if all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1) sketch7_01.setOpacity(1, 500, 0);
}
// reveal right simplified molecule
function handleClick7_3 ()
{
sketch7_6.setOpacity(1, 500, 0);
sketch7_9.setOpacity(1, 500, 0);
reveal7_3 = 1;
// reveal message if all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1) sketch7_01.setOpacity(1, 500, 0);
}
// click left simplified molecule
function handleClick7_4 (eventDetails)
{
// not clickable until all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1)
{
canclick7 = false;
sketch7_7.setColor("blue", 200, 0);
if (click7 == 0) first7 = 1;
else if (click7 == 1) second7 == 1;
click7 ++;
checkAnswer7();
setTimeout(function () {canclick7 = true;}, 500);
}
}
// click middle simplified molecule
function handleClick7_5 (eventDetails)
{
// not clickable until all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1)
{
canclick7 = false;
sketch7_8.setColor("blue", 200, 0);
if (click7 == 0) first7 = 2;
else if (click7 == 1) second7 = 2;
click7 ++;
checkAnswer7();
setTimeout(function () {canclick7 = true;}, 500);
}
}
// click right simplified molecule
function handleClick7_6 (eventDetails)
{
// not clickable until all simplified molecules have been revealed
if (reveal7_1 == 1 && reveal7_2 == 1 && reveal7_3 == 1)
{
canclick7 = false;
sketch7_9.setColor("blue", 200, 0);
if (click7 == 0) first7 = 3;
else if (click7 == 1) second7 = 3;
click7 ++;
checkAnswer7();
setTimeout(function () {canclick7 = true;}, 500);
}
}
// reset
function handleClick7_7 ()
{
if (canclick7)