|
| 1 | +MEETING = { |
| 2 | + |
| 3 | + html: ` |
| 4 | + <div id="videos" style="pointer-events:none"></div> |
| 5 | + <div id="chat" aria-live="assertive" aria-relevant></div> |
| 6 | + <div id="chatfooter"> |
| 7 | + <div id="chatbar"> |
| 8 | + <input id="chatline" type="text" placeholder=""></input> |
| 9 | + </div> |
| 10 | + <button id="showchat" class="btn">show chat</button> |
| 11 | + </div> |
| 12 | + </div> |
| 13 | + `, |
| 14 | + |
| 15 | + init: (el) => new Proxy({ |
| 16 | + |
| 17 | + scene: null, |
| 18 | + enabled: false, |
| 19 | + active: false, |
| 20 | + //$overlay: $overlay = el.querySelector('#overlay'), |
| 21 | + // |
| 22 | + install(opts){ |
| 23 | + this.scene = opts.scene |
| 24 | + window.meeting.buttons.push(`<a class="btn" aria-label="button" aria-description="start text/audio/video chat" id="meeting" onclick="MEETING.toggle()" target="_blank">🧑🤝🧑 meeting</a><br>`) |
| 25 | + document.body.appendChild( el ) |
| 26 | + |
| 27 | + }, |
| 28 | + |
| 29 | + start(){ |
| 30 | + this.scene.addEventListener('meeting.peer.add', () => console.log("$meeting.peer.add") ) |
| 31 | + this.scene.addEventListener('meeting.peer.remove', () => console.log("$meeting.peer.remove") ) |
| 32 | + }, |
| 33 | + |
| 34 | + toggle: () => MEETING.collapsed = !MEETING.collapsed, |
| 35 | + install: (opts) => { |
| 36 | + document.body.appendChild(el) |
| 37 | + document.dispatchEvent( new CustomEvent("MEETING:ready", {detail: opts}) ) |
| 38 | + } |
| 39 | + |
| 40 | + },{ |
| 41 | + |
| 42 | + get(data,k,v){ return data[k] }, |
| 43 | + set(data,k,v){ |
| 44 | + data[k] = v |
| 45 | + switch( k ){ |
| 46 | + case "css": document.head.innerHTML += v; break; |
| 47 | + } |
| 48 | + }, |
| 49 | + |
| 50 | + }) |
| 51 | +} |
| 52 | + |
| 53 | +// reactify component! |
| 54 | +document.addEventListener('XRFMENU:ready', (opts) => { |
| 55 | + opts = opts.detail |
| 56 | + $meeting = document.createElement('div') |
| 57 | + $meeting.innerHTML = MEETING.html |
| 58 | + MEETING = MEETING.init($meeting) |
| 59 | + MEETING.install(opts) |
| 60 | +}) |
| 61 | + |
1 | 62 | // alpine component for displaying meetings
|
2 | 63 |
|
3 |
| -$XRFMEETING = $el( |
4 |
| - `<div x-show="enabled" id="meeting" x-data="XRFMEETING"> |
| 64 | +MEETING.css = ` |
5 | 65 | <style type="text/css">
|
6 | 66 | #videos{
|
7 | 67 | display:grid-auto-columns;
|
@@ -112,48 +172,4 @@ $XRFMEETING = $el(
|
112 | 172 | font-family:monospace;
|
113 | 173 | font-size:15px;
|
114 | 174 | }
|
115 |
| - </style> |
116 |
| - <div id="videos" style="pointer-events:none"></div> |
117 |
| - <div id="chat" aria-live="assertive" aria-relevant></div> |
118 |
| - <div id="chatfooter"> |
119 |
| - <div id="chatbar"> |
120 |
| - <input id="chatline" type="text" placeholder=""></input> |
121 |
| - </div> |
122 |
| - <button id="showchat" class="btn">show chat</button> |
123 |
| - </div> |
124 |
| - </div>` |
125 |
| -) |
126 |
| - |
127 |
| -window.XRFMEETING = { |
128 |
| - |
129 |
| - scene: null, |
130 |
| - enabled: false, |
131 |
| - active: false, |
132 |
| - init(){ |
133 |
| - window.XRFMEETING = this.$data // replace so we can modify state in global scope |
134 |
| - window.meeting |
135 |
| - }, |
136 |
| - toggle(){ |
137 |
| - this.enabled = !this.enabled |
138 |
| - if( !this.active ) this.start() |
139 |
| - }, |
140 |
| - |
141 |
| - install(opts){ |
142 |
| - this.scene = opts.scene |
143 |
| - window.XRFMENU.buttons.push(`<a class="btn" aria-label="button" aria-description="start text/audio/video chat" id="meeting" onclick="XRFMEETING.toggle()" target="_blank">🧑🤝🧑 meeting</a><br>`) |
144 |
| - document.body.appendChild( $XRFMEETING ) |
145 |
| - |
146 |
| - }, |
147 |
| - |
148 |
| - start(){ |
149 |
| - this.scene.addEventListener('meeting.peer.add', () => console.log("$meeting.peer.add") ) |
150 |
| - this.scene.addEventListener('meeting.peer.remove', () => console.log("$meeting.peer.remove") ) |
151 |
| - } |
152 |
| -} |
153 |
| - |
154 |
| -// finally we alpinify |
155 |
| -document.addEventListener('XRFMENU:ready', (opts) => { |
156 |
| - opts = opts.detail |
157 |
| - Alpine.data('XRFMEETING', () => window.XRFMEETING) |
158 |
| - XRFMEETING.install(opts) |
159 |
| -}) |
| 175 | + </style>` |
0 commit comments