MCPcopy Create free account
hub / github.com/SnapDrop/snapdrop / ReceiveTextDialog

Class ReceiveTextDialog

client/scripts/ui.js:351–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351class 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
382class Toast extends Dialog {
383 constructor() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected