1- /* eslint-disable radix */
2-
3- const domain = 'meet.jit.si' ;
4- const options = {
5- roomName : 'BrainWeb' ,
6- width : "100%" ,
7- height : "100%" ,
8- parentNode : document . querySelector ( '#jitsi' )
9- } ;
10-
11- // eslint-disable-next-line no-undef
12- const api = new JitsiMeetExternalAPI ( domain , options ) ;
13-
14- const feedbackAnimationStep = ( timer , elem ) => {
15- const dx = 500 * Math . random ( ) - 250 ;
16- const x = parseInt ( "0" + elem . style . left ) ;
17- const y = parseInt ( "0" + elem . style . top ) ;
18- const newx = 0.9 * x + 0.1 * ( x + dx ) ;
19- const newy = y - 25 ;
20- elem . style . left = newx + "px" ;
21- elem . style . top = newy + "px" ;
22- if ( newy <= 0 ) {
23- clearInterval ( timer ) ;
24- elem . remove ( ) ;
25- }
26- } ;
27-
28- const feedbackAnimation = ( emoji ) => {
29- const elem = document . createElement ( 'div' ) ;
30- elem . innerText = emoji ;
31- elem . classList . add ( "feedback" ) ;
32- document . body . appendChild ( elem ) ;
33- elem . style . left = window . innerWidth / 2.0 + "px" ;
34- elem . style . top = window . innerHeight + "px" ;
35- const timer = setInterval ( ( ) => {
36- feedbackAnimationStep ( timer , elem ) ;
37- } , 25 ) ;
38- } ;
39-
40- const broadcastMessage = ( msg ) => {
41- // eslint-disable-next-line guard-for-in
42- for ( const participant in api . _participants ) {
43- if ( ! { } . hasOwnProperty . call ( api . _participants , participant ) ) {
44- continue ;
45- }
46- const itsme = ( api . _participants [ participant ] . formattedDisplayName . slice ( - 5 ) === " (me)" ) ;
47- if ( itsme ) {
48- continue ;
49- }
50- api . executeCommand ( 'sendEndpointTextMessage' , participant , JSON . stringify ( msg ) ) ;
51- }
1+ const configureRooms = ( ) => {
2+ document . querySelectorAll ( ".room" ) . forEach ( ( el ) => {
3+ const roomID = "bw-" + el . id ;
4+ const svg = `
5+ <svg class="camera" width=48 height=32 style="display:block">
6+ <g id="${ roomID } " transform="translate(0,0) scale(0.4)">
7+ <path class="bubble" d="M 31.848061,7.6290677 A 28.403238,22.039304 0 0 0 3.596657,29.668006 28.403238,22.039304 0 0 0 10.583386,44.14469 L 7.6648251,56.370967 20.270838,49.740068 A 28.403238,22.039304 0 0 0 32,51.707502 28.403238,22.039304 0 0 0 60.403343,29.668006 28.403238,22.039304 0 0 0 32,7.6290677 a 28.403238,22.039304 0 0 0 -0.151939,0 z"
8+ fill="rgba(255,255,255,0.4)"></path>
9+ <path class="video" d="m 16.837732,20.440612 v 19.377113 h 24.589197 v -8.876977 l 3.412712,1.970421 5.397084,3.11609 v -6.232178 -6.232178 l -5.397084,3.116088 -3.412712,1.970423 v -8.208802 z"
10+ fill="white" stroke-width="5"></path>
11+ <text font-size="30" x="70" y="50" fill="white"></text>
12+ <g transform="translate(30,30)"><circle cx="0" cy="0" r="1" stroke-width="0.1" fill="none" stroke="white" /></g>
13+ </g>
14+ </svg>` ;
15+ el . innerHTML = svg + el . innerHTML ;
16+ } ) ;
5217} ;
18+ configureRooms ( ) ;
5319
54- // eslint-disable-next-line no-unused-vars
55- const feedback = ( emoji ) => {
56- feedbackAnimation ( emoji ) ;
57- broadcastMessage ( { type :"feedback" , emoji} ) ;
58- } ;
59- window . feedback = feedback ;
60-
61- api . addEventListener ( 'endpointTextMessageReceived' , ( rawMsg ) => {
62- const { text} = rawMsg . data . eventData ;
63- const msg = JSON . parse ( text ) ;
64- switch ( msg . type ) {
65- case "feedback" : {
66- const { emoji} = msg ;
67- feedbackAnimation ( emoji ) ;
68- break ;
69- }
70- case "clap" :
71- // playClapSound();
72- break ;
73- }
74- } ) ;
20+ let rooms ;
7521
7622// eslint-disable-next-line no-undef
7723startFirebase ( ) ;
@@ -91,4 +37,30 @@ window.addEventListener('load', () => {
9137 document . querySelectorAll ( ".logged" ) . forEach ( ( el ) => { el . classList . remove ( "logged" ) ; } ) ;
9238 }
9339 } ) ;
40+
41+ rooms = firebase . database ( ) . ref ( 'rooms' ) ;
42+ rooms . on ( 'value' , ( s ) => {
43+ const val = s . val ( ) ;
44+ if ( val === null ) {
45+ return ;
46+ }
47+ console . log ( val ) ;
48+ for ( const key in val ) {
49+ if ( { } . hasOwnProperty . call ( val , key ) ) {
50+ document . querySelector ( `#${ key } > .subject` ) . value = val [ key ] ;
51+ console . log ( key , val [ key ] ) ;
52+ }
53+ }
54+ } ) ;
9455} ) ;
56+
57+ const roomRename = ( ev ) => {
58+ const key = ev . parentElement . id ;
59+ const value = ev . value ;
60+ const object = { } ;
61+ object [ key ] = value ;
62+ console . log ( `roomRename id=${ key } value=${ value } ` ) ;
63+ ev . blur ( ) ;
64+ rooms . update ( object ) ;
65+ } ;
66+ window . roomRename = roomRename ;
0 commit comments