| 349 | } |
| 350 | |
| 351 | class ReceiveTextDialog extends Dialog { |
| 352 | constructor() { |
| 353 | super('receiveTextDialog'); |
| 354 | Events.on('text-received', e => this._onText(e.detail)) |
| 355 | this.$text = this.$el.querySelector('#text'); |
| 356 | const $copy = this.$el.querySelector('#copy'); |
| 357 | copy.addEventListener('click', _ => this._onCopy()); |
| 358 | } |
| 359 | |
| 360 | _onText(e) { |
| 361 | this.$text.innerHTML = ''; |
| 362 | const text = e.text; |
| 363 | if (isURL(text)) { |
| 364 | const $a = document.createElement('a'); |
| 365 | $a.href = text; |
| 366 | $a.target = '_blank'; |
| 367 | $a.textContent = text; |
| 368 | this.$text.appendChild($a); |
| 369 | } else { |
| 370 | this.$text.textContent = text; |
| 371 | } |
| 372 | this.show(); |
| 373 | window.blop.play(); |
| 374 | } |
| 375 | |
| 376 | async _onCopy() { |
| 377 | await navigator.clipboard.writeText(this.$text.textContent); |
| 378 | Events.fire('notify-user', 'Copied to clipboard'); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | class Toast extends Dialog { |
| 383 | constructor() { |
nothing calls this directly
no outgoing calls
no test coverage detected