-
Notifications
You must be signed in to change notification settings - Fork 0
/
prez_bundle.js
1432 lines (1267 loc) · 130 KB
/
prez_bundle.js
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
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var MIN_TOP = '95px';
var LINE_HEIGHT = '0.57em';
var ADDITIONNAL_HEIGHT = '0.4em';
var COL_WIDTH = 35;
var LEFT_TAB = '100px';
var HighlightCodeHelper = exports.HighlightCodeHelper = function () {
function HighlightCodeHelper(_ref) {
var _this = this;
var keyElt = _ref.keyElt,
positionArray = _ref.positionArray;
_classCallCheck(this, HighlightCodeHelper);
this.eltHiglight = document.getElementById('highlight-' + keyElt);
this.positionArray = positionArray;
this.progress = Reveal.getProgress();
Reveal.addEventListener('code-' + keyElt, function () {
try {
var currentProgress = Reveal.getProgress();
_this._applyProperties(currentProgress > _this.progress ? _this.positionArray[0] : _this.positionArray[_this.positionArray.length - 1]);
_this._listenFragments();
} catch (e) {
console.error(e);
}
});
Reveal.addEventListener('stop-code-' + keyElt, function () {
try {
_this.progress = Reveal.getProgress();
_this._unregisterFragments();
} catch (e) {
console.error(e);
}
});
}
_createClass(HighlightCodeHelper, [{
key: '_applyProperties',
value: function _applyProperties(properties) {
try {
var keys = Object.keys(properties);
var area = {};
var position = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
switch (true) {
case key === 'line':
case key === 'nbLines':
case key === 'col':
case key === 'nbCols':
case key === 'topMargin':
case key === 'leftMargin':
position[key] = properties[key];
break;
case key === 'height':
case key === 'width':
case key === 'top':
case key === 'left':
area[key] = properties[key];
break;
default:
}
}
if (position.topMargin === undefined) {
position.topMargin = MIN_TOP;
}
if (position.nbLines === undefined && area.height === undefined) {
area.height = LINE_HEIGHT;
}
if (position.line === undefined && area.top === undefined) {
area.top = 0;
}
if (position.nbCols === undefined && area.width === undefined) {
area.width = 0;
}
if (position.col === undefined && area.left === undefined) {
area.left = 0;
}
this.eltHiglight.area = area;
this.eltHiglight.position = position;
} catch (e) {}
}
}, {
key: '_progressFragment',
value: function _progressFragment(event) {
try {
var properties = null;
if (event.type === 'fragmentshown') {
var index = +event.fragment.getAttribute('data-fragment-index');
properties = this.positionArray[index + 1];
} else {
var _index = +event.fragment.getAttribute('data-fragment-index');
properties = this.positionArray[_index];
}
if (!properties) {
return;
}
this._applyProperties(properties);
} catch (e) {
console.error(e);
}
}
}, {
key: '_listenFragments',
value: function _listenFragments() {
Reveal.addEventListener('fragmentshown', this._progressFragment.bind(this));
Reveal.addEventListener('fragmenthidden', this._progressFragment.bind(this));
}
}, {
key: '_unregisterFragments',
value: function _unregisterFragments() {
Reveal.removeEventListener('fragmentshown', this._progressFragment.bind(this));
Reveal.removeEventListener('fragmenthidden', this._progressFragment.bind(this));
}
}]);
return HighlightCodeHelper;
}();
},{}],2:[function(require,module,exports){
'use strict';
var _revealEngineEvents = require('./prez/revealEngineEvents.js');
(function () {
function pageLoad() {
new _revealEngineEvents.RevealEngineEvents();
}
window.addEventListener('load', pageLoad);
})();
},{"./prez/revealEngineEvents.js":4}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HighlightEvents = undefined;
var _highlightCodeHelper = require("../helpers/highlightCodeHelper.js");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var LINE_HEIGHT = 1.15;
var ADDITIONNAL_HEIGT = 0.4;
var COL_WIDTH = 35;
var LEFT_FIRST = "60px";
var HighlightEvents = exports.HighlightEvents = function HighlightEvents() {
_classCallCheck(this, HighlightEvents);
// Bluetooth: Scan + Connect
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'connect-ble',
// We start with the first fragment (the initial position is fixed by css)
positionArray: [{
width: '600px',
line: 5,
left: LEFT_FIRST
}, {
line: 2,
width: '900px',
left: LEFT_FIRST
}, {
line: 7,
width: '600px',
left: LEFT_FIRST
}]
});
// Ble Code Read Characteristic
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'read-charact',
// We start with the first fragment (the initial position is fixed by css)
positionArray: [{
width: '700px',
line: 2
}, {
line: 4,
width: '90%'
}, {
line: 6,
width: '90%'
}, {
line: 8,
nbLines: 2,
width: '90%'
}]
});
// Ble Code Write Characteristic
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'write-charact',
// We start with the first fragment (the initial position is fixed by css)
positionArray: [{
width: '700px',
line: 2
}, {
line: 4,
width: '90%'
}, {
line: 7,
nbLines: 3,
width: '90%'
}]
});
// Ble Code Read Characteristic
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'notif-charact',
// We start with the first fragment (the initial position is fixed by css)
positionArray: [{
width: '700px',
line: 2
}, {
line: 4,
width: '90%'
}, {
line: 6,
width: '90%',
nbLines: 3
}]
});
// Code Web Speech
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'web-speech',
positionArray: [{
width: '600px',
line: 1
}, {
line: 2,
width: '450px'
}, {
line: 3,
width: '550px'
}, {
line: 4,
width: '550px'
}, {
line: 6,
width: '350px'
}, {
line: 7,
width: '350px'
}, {
line: 8,
left: '280px',
width: '500px'
}]
});
// Code Web Speech Grammar
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'web-speech-grammar',
positionArray: [{
width: '1200px',
line: 1
}, {
line: 3,
width: '750px'
}, {
line: 4,
width: '700px'
}, {
line: 5,
width: '650px'
}]
});
// Code Web Speech Synthesis
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'web-speech-synthesis',
positionArray: [{
width: '900px',
line: 1
}, {
line: 2,
width: '400px'
}, {
line: 3,
width: '400px'
}, {
line: 4,
width: '450px'
}, {
line: 5,
width: '600px'
}]
});
// Code image capture zoom
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: 'image-capture-zoom',
positionArray: [{
width: '90%',
line: 1
}, {
line: 3,
width: '90%'
}, {
line: 4,
width: '90%'
}, {
line: 6,
width: '90%'
}, {
line: 7,
width: '90%'
}]
});
// Code image capture
new _highlightCodeHelper.HighlightCodeHelper({
keyElt: "image-capture",
positionArray: [{
width: "90%",
line: 5,
left: LEFT_FIRST
}, {
line: 7,
left: LEFT_FIRST,
width: "90%",
nbLines: 3
}]
});
};
},{"../helpers/highlightCodeHelper.js":1}],4:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RevealEngineEvents = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _highlightEvents = require('./highlightEvents.js');
var _blePrezControler = require('../sensors/blePrezControler.js');
var _voiceRecognitionControler = require('../sensors/voiceRecognitionControler.js');
var _speechSynthesisControler = require('../sensors/speechSynthesisControler.js');
var _imageCapture = require('../sensors/imageCapture.js');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var RevealEngineEvents = exports.RevealEngineEvents = function () {
function RevealEngineEvents() {
_classCallCheck(this, RevealEngineEvents);
var inIFrame = window.top != window.self;
// Management of actions in prez mode (not in preview mode)
if (!inIFrame) {
// Init all ble actions
this._blePrezControler = new _blePrezControler.BlePrezControler();
this._bleEvents();
// Init Voice and Speech controlers
this.voiceRecognition = new _voiceRecognitionControler.VoiceRecognitionControler();
this.speechSynthesis = new _speechSynthesisControler.SpeechSynthesisControler();
this._voiceEvents();
// Init Image Capture
this._imageCaptureEvents();
}
// In al case we init the highlight of code.
this._initHighlightCode();
}
_createClass(RevealEngineEvents, [{
key: '_imageCaptureEvents',
value: function _imageCaptureEvents() {
var imageCaptureController = null;
Reveal.addEventListener('stop-image-capture-demo', function (event) {
if (imageCaptureController) {
imageCaptureController._destroy();
}
});
Reveal.addEventListener('image-capture-demo', function (event) {
imageCaptureController = new _imageCapture.ImageCaptureControler();
});
}
}, {
key: '_bleEvents',
value: function _bleEvents() {
var _this = this;
Reveal.addEventListener('stop-code-read-charact', function (event) {
if (_this._blePrezControler._currentBleDevice) {
_this._blePrezControler._currentBleDevice.gatt.disconnect();
}
});
Reveal.addEventListener('disconnect-heart-rate-sensor', function (event) {
// Try to disconnect heart rate sensor
if (frames[0].heartRateSensor.device) {
frames[0].heartRateSensor.device.gatt.disconnect();
}
});
}
}, {
key: '_voiceEvents',
value: function _voiceEvents() {
var _this2 = this;
document.getElementById('google-assistant').addEventListener('click', function (_) {
_this2._voiceCallBack();
});
Reveal.addEventListener('end-recognition', function (_) {
try {
_this2.voiceRecognition.stop();
} catch (e) {}
});
}
}, {
key: '_voiceCallBack',
value: function _voiceCallBack() {
var _this3 = this;
document.getElementById('demoSpeech').style.display = '';
this.voiceRecognition.start(function (finalStr) {
document.getElementById('speech_input').innerHTML = finalStr;
if (finalStr.toLowerCase().includes('ça va')) {
document.getElementById('demoSpeech').style.display = 'none';
_this3.speechSynthesis.speak({
value: 'je vais très bien merci. Comment se passe ta conférence ? François est-il gentil avec toi ?'
}).then(function (_) {
return _this3._voiceCallBack.bind(_this3);
}).catch(function (error) {
console.error(error);
});
} else if (finalStr.toLowerCase().includes('anglais')) {
_this3.speechSynthesis.speak({
value: 'hello every one, welcome to the best talk of this event !',
langFr: false
}).then(function (_) {
return _this3._voiceCallBack.bind(_this3);
}).catch(function (error) {
console.error(error);
});
} else if (finalStr.toLowerCase().includes('voix')) {
_this3.speechSynthesis.speak({
value: 'comme ça c\'est assez bizarre pour toi ?',
pitch: 2,
rate: 0.3
}).then(function (_) {
return _this3._voiceCallBack.bind(_this3);
}).catch(function (error) {
console.error(error);
});
} else if (finalStr.toLowerCase().includes('sommes-nous')) {
_this3.speechSynthesis.speak({
value: 'Voyons François, nous sommes dans ta session, je trouve que tu n\'as pas l\'air très réveillé'
}).then(function (_) {
return _this3._voiceCallBack.bind(_this3);
}).catch(function (error) {
console.error(error);
});
} else if (finalStr.toLowerCase().includes('suivant')) {
_this3.speechSynthesis.speak({
value: 'Très bien passons au slide suivant'
}).then(function (_) {
return Reveal.next();
}).catch(function (error) {
console.error(error);
});
} else {
var unknowArray = ['Articule s\'il te plait', 'Kamoulox !', 'Tu pourrais faire un effort quand même', 'Retire ton chewing gum avant de parler'];
_this3.speechSynthesis.speak({
value: unknowArray[Math.floor(Math.random() * unknowArray.length)]
}).then(function (_) {
return _this3._voiceCallBack.bind(_this3);
}).catch(function (error) {
console.error(error);
});
}
});
}
}, {
key: '_initHighlightCode',
value: function _initHighlightCode() {
new _highlightEvents.HighlightEvents();
}
}]);
return RevealEngineEvents;
}();
},{"../sensors/blePrezControler.js":5,"../sensors/imageCapture.js":6,"../sensors/speechSynthesisControler.js":7,"../sensors/voiceRecognitionControler.js":8,"./highlightEvents.js":3}],5:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BlePrezControler = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _myoControler = require('../webbluetooth/myoControler.js');
var _mbotControler = require('../webbluetooth/mbotControler.js');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var BlePrezControler = exports.BlePrezControler = function () {
function BlePrezControler() {
_classCallCheck(this, BlePrezControler);
this._currentBleDevice = null;
this._basicBleBinding();
//this._myoBinding();
// Just comment mbot part because it can always be usefull !
//this._mbotBinding();
}
_createClass(BlePrezControler, [{
key: '_basicBleBinding',
value: function _basicBleBinding() {
var _this = this;
document.getElementById('connectBle').addEventListener('click', function (event) {
var filters = {
filters: [{
services: ['battery_service']
}]
};
navigator.bluetooth.requestDevice(filters).then(function (device) {
return device.gatt.connect();
}).then(function (server) {
console.log('Bluetooth device is connected.');
_this._currentBleDevice = server.device;
});
});
document.getElementById('readCharact').addEventListener('click', function (event) {
_this._currentBleDevice.gatt.getPrimaryService('battery_service').then(function (service) {
return service.getCharacteristic('battery_level');
}).then(function (characteristic) {
return characteristic.readValue();
}).then(function (value) {
var batteryLevel = value.getUint8(0);
console.log('Battery percentage is ' + batteryLevel + '%.');
});
});
}
}, {
key: '_myoBinding',
value: function _myoBinding() {
var lastDoubleTap = 0;
var myo = new _myoControler.MyoControler();
document.getElementById('connectMyo').addEventListener('click', function () {
if (!myo.connected) {
myo.request().then(function (_) {
return myo.connect();
}).then(function () {
return myo.init();
}).then(function () {
return myo.registerGestures(function (gesture) {
if (gesture && gesture.gesture === 'double-tap') {
if (Date.now() - lastDoubleTap < 2000) {
Reveal.next();
}
lastDoubleTap = Date.now();
}
});
});
}
});
Reveal.addEventListener('disconnect-myo', function (_) {
myo.disconnect();
});
}
}, {
key: '_mbotBinding',
value: function _mbotBinding() {
// Check the connection
var stepConnect = document.getElementById('connectMBot');
var stepControl = document.getElementById('part-button-mbot');
document.getElementById("connectMBot").addEventListener('click', function (_) {
// Request the device
var mBot = new _mbotControler.MBot();
mBot.request().then(function (_) {
// Connect to the mbot
return mBot.connect();
}).then(function (_) {
// Connection is done, we show the controls
stepConnect.style.display = "none";
stepControl.style.display = "flex";
var partBtn = document.querySelector('.part-button');
// Control the robot by buttons
var btnUp = document.getElementById('mBotBtnUp');
var btnDown = document.getElementById('mBotBtnDown');
var btnLeft = document.getElementById('mBotBtnLeft');
var btnRight = document.getElementById('mBotBtnRight');
btnUp.addEventListener('mousedown', function (_) {
mBot.processMotor(-250, 250);
});
btnDown.addEventListener('mousedown', function (_) {
mBot.processMotor(250, -250);
});
btnLeft.addEventListener('mousedown', function (_) {
mBot.processMotor(250, 250);
});
btnRight.addEventListener('mousedown', function (_) {
mBot.processMotor(-250, -250);
});
btnUp.addEventListener('mouseup', function (_) {
mBot.processMotor(0, 0);
});
btnDown.addEventListener('mouseup', function (_) {
mBot.processMotor(0, 0);
});
btnLeft.addEventListener('mouseup', function (_) {
mBot.processMotor(0, 0);
});
btnRight.addEventListener('mouseup', function (_) {
mBot.processMotor(0, 0);
});
});
});
}
}]);
return BlePrezControler;
}();
},{"../webbluetooth/mbotControler.js":9,"../webbluetooth/myoControler.js":10}],6:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ImageCaptureControler = exports.ImageCaptureControler = function () {
function ImageCaptureControler() {
_classCallCheck(this, ImageCaptureControler);
navigator.mediaDevices.getUserMedia({
video: true
}).then(this._gotMedia.bind(this)).catch(function (error) {
return console.error('getUserMedia() error:', error);
});
this.mediaStreamTrack = null;
this.imageCapture = null;
this.brightnessElt = document.getElementById('brightness');
this.contrastElt = document.getElementById('contrast');
this.saturationElt = document.getElementById('saturation');
this.sharpnessElt = document.getElementById('sharpness');
this.imageCaptureElt = document.getElementById('imageCapture');
}
_createClass(ImageCaptureControler, [{
key: '_destroy',
value: function _destroy() {
if (this.mediaStreamTrack) {
this.mediaStreamTrack.stop();
}
}
}, {
key: '_gotMedia',
value: function _gotMedia(mediaStream) {
var _this = this;
this.mediaStreamTrack = mediaStream.getVideoTracks()[0];
this.imageCapture = new ImageCapture(this.mediaStreamTrack);
this.imageCaptureElt.srcObject = mediaStream;
setTimeout(function () {
var constraints = _this.imageCapture.track.getConstraints();
var settings = _this.imageCapture.track.getSettings();
var capabilities = _this.imageCapture.track.getCapabilities();
for (var capabilityName in capabilities) {
var capability = capabilities[capabilityName];
if (capability.toString() === '[object MediaSettingsRange]') {
var value = settings[capabilityName];
switch (capabilityName) {
case 'brightness':
_this._initRange(_this.brightnessElt, capabilityName, value, capability);
break;
case 'contrast':
_this._initRange(_this.contrastElt, capabilityName, value, capability);
break;
case 'saturation':
_this._initRange(_this.saturationElt, capabilityName, value, capability);
break;
case 'sharpness':
_this._initRange(_this.sharpnessElt, capabilityName, value, capability);
break;
}
}
}
console.log(_this.imageCapture);
}, 500);
}
}, {
key: '_initRange',
value: function _initRange(capabilityElt, capabilityName, value, range) {
var _this2 = this;
capabilityElt.min = range.min;
capabilityElt.max = range.max;
capabilityElt.step = Math.round(range.step * 100) / 100;
capabilityElt.value = value;
capabilityElt.setAttribute('data-name', capabilityName);
capabilityElt.oninput = function (event) {
var options = {};
options[capabilityName] = event.target.value;
_this2._applyConstraints(options);
};
}
}, {
key: '_applyConstraints',
value: function _applyConstraints(options) {
this.imageCapture.track.applyConstraints({
advanced: [options]
}).then(function (_) {});
}
}, {
key: '_changeConstraint',
value: function _changeConstraint(brightnessValue, contrastValue, saturationValue, sharpnessValue) {
mediaStreamTrack.applyConstraints({
advanced: [{
brightness: brightnessValue,
constrast: contrastValue,
saturation: saturationValue,
sharpness: sharpnessValue
}]
}).catch(function (error) {
return console.error('Uh, oh, applyConstraints() error:', error);
});
}
}]);
return ImageCaptureControler;
}();
},{}],7:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SpeechSynthesisControler = exports.SpeechSynthesisControler = function () {
function SpeechSynthesisControler() {
_classCallCheck(this, SpeechSynthesisControler);
this.synth = window.speechSynthesis;
this.voiceFR = null;
this.voiceEN = null;
this._configure();
}
_createClass(SpeechSynthesisControler, [{
key: '_configure',
value: function _configure() {
this._populateVoiceList();
if (speechSynthesis.onvoiceschanged !== undefined) {
speechSynthesis.onvoiceschanged = this._populateVoiceList.bind(this);
}
}
}, {
key: '_populateVoiceList',
value: function _populateVoiceList() {
var voices = this.synth.getVoices();
for (var i = 0; i < voices.length; i++) {
if (voices[i].lang === 'fr-FR') {
console.debug("%s, %O ", voices[i].lang, voices[i]);
this.voiceFR = voices[i];
} else if (voices[i].lang === 'en-GB') {
console.debug("%s, %O ", voices[i].lang, voices[i]);
this.voiceEN = voices[i];
}
}
}
}, {
key: 'speak',
value: function speak(_ref) {
var _this = this;
var value = _ref.value,
_ref$langFr = _ref.langFr,
langFr = _ref$langFr === undefined ? true : _ref$langFr,
_ref$pitch = _ref.pitch,
pitch = _ref$pitch === undefined ? 1 : _ref$pitch,
_ref$rate = _ref.rate,
rate = _ref$rate === undefined ? 1 : _ref$rate;
return new Promise(function (resolve, reject) {
if (!_this.voiceFR) {
reject();
}
var utterThis = new SpeechSynthesisUtterance(value);
utterThis.voice = langFr ? _this.voiceFR : _this.voiceEN;
utterThis.pitch = pitch;
utterThis.rate = rate;
utterThis.onend = function () {
resolve();
};
_this.synth.speak(utterThis);
});
}
}]);
return SpeechSynthesisControler;
}();
},{}],8:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var VoiceRecognitionControler = exports.VoiceRecognitionControler = function () {
function VoiceRecognitionControler() {
_classCallCheck(this, VoiceRecognitionControler);
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
this.recognition = new SpeechRecognition();
this._configure();
}
_createClass(VoiceRecognitionControler, [{
key: 'start',
value: function start(callback) {
this.recognition.onresult = function (event) {
var finalStr = event.results[0][0].transcript;
console.debug('Confidence: ' + finalStr);
if (callback) {
callback(finalStr);
}
};
this.recognition.start();
}
}, {
key: 'stop',
value: function stop() {
this.recognition.stop();
}
}, {
key: '_configure',
value: function _configure() {
var _this = this;
this.recognition.lang = 'fr-FR';
// We detect end
this.recognition.onend = function (_) {
console.debug('End of recognition');
_this.recognition.stop();
};
// We detect errors
this.recognition.onerror = function (event) {
if (event.error == 'no-speech') {
console.debug('No Speech');
}
if (event.error == 'audio-capture') {
console.debug('No microphone');
}
if (event.error == 'not-allowed') {
console.debug('Not Allowed');
}
};
}
}]);
return VoiceRecognitionControler;
}();
},{}],9:[function(require,module,exports){
'use strict';
/**
* Code from https://github.com/binomed/mbot-webbluetooth
*
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var DEVICE_NAME = "Makeblock_LE",
SERVICE_UUID = "0000ffe1-0000-1000-8000-00805f9b34fb",
CHARACTERISTIC_UUID = "0000ffe3-0000-1000-8000-00805f9b34fb";
/**
* General configuration (UUID)
*/
var Config = function () {
function Config() {
_classCallCheck(this, Config);
}
_createClass(Config, [{
key: "name",
value: function name() {
return "Makeblock_LE";
}
}, {
key: "service",
value: function service() {
return "0000ffe1-0000-1000-8000-00805f9b34fb";
}
}, {
key: "charateristic",
value: function charateristic() {
return "0000ffe3-0000-1000-8000-00805f9b34fb";
}
}]);
return Config;
}();
// Const for instructions types
var TYPE_MOTOR = 0x0a,
TYPE_RGB = 0x08,
TYPE_SOUND = 0x07;
// Const for the ports
var PORT_1 = 0x01,
PORT_2 = 0x02,
PORT_3 = 0x03,
PORT_4 = 0x04,
PORT_5 = 0x05,
PORT_6 = 0x06,
PORT_7 = 0x07,
PORT_8 = 0x08,
M_1 = 0x09,
M_2 = 0x0a;
/**
* Class for the robot
* */
var MBot = exports.MBot = function () {
function MBot() {
_classCallCheck(this, MBot);
this.device = null;
this.config = new Config();
this.onDisconnected = this.onDisconnected.bind(this);
this.buzzerIndex = 0;
}
/*