@@ -11,32 +11,37 @@ const ctx = canvas.getContext('2d');
1111const strip = document . querySelector ( '.strip' ) ;
1212const snapSound = document . querySelector ( '.sound-snap' ) ;
1313const snapLimit = document . querySelector ( '#limit' ) ;
14- const allSelects = document . querySelectorAll ( 'select' ) ;
15-
1614const alertMsgs = document . querySelectorAll ( '.alert' ) ;
1715const alertMsgCam = document . querySelector ( '#msg_cam' ) ;
1816const alertMsgFx = document . querySelector ( '#msg_fx' ) ;
1917const alertMsgErr = document . querySelector ( '#msg_err' ) ;
2018// const alertFx = ctrlFx.querySelector('.alert');
2119
2220/* F/X controls */
23- /* main select/option for F/X */
21+ /* select/option for main F/X control */
2422const selectFx = document . querySelector ( '#fx' ) ;
23+ /* select/option for deeper F/X controls */
24+ const selectsFx = document . querySelectorAll ( '.select_fx' ) ;
25+
2526/* array of tables of control interfaces */
2627const ctrlFx = document . querySelector ( '.ctrl_fx' ) ;
2728const ctrlTables = ctrlFx . querySelectorAll ( 'table' ) ;
29+
2830/* video channel colorize controls */
2931const ctrlColorize = document . querySelector ( '#table-colorize' ) ;
3032const selectColorize = document . querySelector ( '#colorize' ) ;
31- const btnsApply = document . querySelectorAll ( '.btn_apply' ) ;
33+
3234/* video channel split controls */
3335const ctrlSplit = document . querySelector ( '#table-split' ) ;
3436const selectSplit = document . querySelector ( '#split' ) ;
37+
3538/* video croma key controls */
3639const ctrlChroma = document . querySelector ( '#table-chroma' ) ;
3740const inputsChroma = document . querySelectorAll ( '#table-chroma input' )
3841
3942/* buttons */
43+ const btnsApply = document . querySelectorAll ( '.btn_apply' ) ;
44+ // const btnsClear = document.querySelectorAll('.btn_clear');
4045const btnOn = document . querySelector ( '.ctrl_camera .btn_on' ) ;
4146const btnOff = document . querySelector ( '.ctrl_camera .btn_off' ) ;
4247const btnClearCam = document . querySelector ( '.ctrl_camera .btn_clear' ) ;
@@ -82,29 +87,10 @@ function toggleControls () {
8287 hide ( ctrlTables ) ;
8388 hide ( alertMsgs ) ;
8489 show ( alertMsgCam ) ;
85- // console.log('...hide all alerts...');
86- // hide(alertMsgs);
87- // for (var i = 0; i < alertMsgs.length; i++) {
88- // alertMsgs[i].style.display = 'none';
89- // }
9090 if ( selectFx . selectedIndex > 0 ) {
9191 console . log ( '...then show __' + selectFx . selectedIndex + '__ controls!' ) ;
9292 hide ( alertMsgs ) ;
93- /* manipulate pixels */
9493 show ( ctrlTables [ selectFx . selectedIndex - 1 ] ) ;
95- // switch(selectFx.selectedIndex) {
96- // case 'chroma':
97- // show(ctrlChroma);
98- // break;
99- // case 'split':
100- // show(ctrlSplit);
101- // break;
102- // case 'colorize':
103- // show(ctrlColorize);
104- // break;
105- // default:
106- // break;
107- // }
10894 } else {
10995 console . log ( '...then done!' ) ;
11096 }
@@ -168,10 +154,6 @@ if (navigator.mediaDevices) {
168154 show ( alertMsgCam ) ;
169155 }
170156
171- // for (var i = 0; i < allSelects.length; i++) {
172- // allSelects[i].selectedIndex = 0;
173- // }
174-
175157 // selectFx.selectedIndex = 0;
176158 // hide(selectFx);
177159 // selectFx.disabled = true;
@@ -464,27 +446,24 @@ if (navigator.mediaDevices) {
464446 pixelsToCanvas ( ) ;
465447 } ) ;
466448
467- /* listen to change on master F/X select/option */
449+ /* listen for change on master F/X select/option */
468450 selectFx . addEventListener ( 'change' , ( e ) => {
469451 console . log ( 'selectFx: ' , e . target . value ) ;
470452 toggleControls ( ) ;
471453 } ) ;
472454
473- /* listen to change on video channel split F/X select/option */
474- selectSplit . addEventListener ( 'change' , ( e ) => {
475- console . log ( 'selectSplit: ' , e . target . value ) ;
476- startStream ( ) ;
477- } ) ;
478-
479- /* listen to change on video channel colorize F/X select/option */
480- selectColorize . addEventListener ( 'change' , ( e ) => {
481- console . log ( 'selectColorize: ' , e . target . value ) ;
482- startStream ( ) ;
455+ /* listen for change on deeper F/X select/option */
456+ selectsFx . forEach ( btn => {
457+ btn . addEventListener ( 'change' , ( e ) => {
458+ console . log ( 'selectsFx: ' , e . target ) ;
459+ startStream ( ) ;
460+ } )
483461 } ) ;
484462
463+ /* listen for click on all "apply" buttons */
485464 btnsApply . forEach ( btn => {
486465 btn . addEventListener ( 'click' , ( e ) => {
487- console . log ( e . target ) ;
466+ console . log ( 'btnsApply: ' , e . target ) ;
488467 startStream ( ) ;
489468 } )
490469 } ) ;
0 commit comments