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

Class SendTextDialog

client/scripts/ui.js:313–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312
313class SendTextDialog extends Dialog {
314 constructor() {
315 super('sendTextDialog');
316 Events.on('text-recipient', e => this._onRecipient(e.detail))
317 this.$text = this.$el.querySelector('#textInput');
318 const button = this.$el.querySelector('form');
319 button.addEventListener('submit', e => this._send(e));
320 }
321
322 _onRecipient(recipient) {
323 this._recipient = recipient;
324 this._handleShareTargetText();
325 this.show();
326
327 const range = document.createRange();
328 const sel = window.getSelection();
329
330 range.selectNodeContents(this.$text);
331 sel.removeAllRanges();
332 sel.addRange(range);
333
334 }
335
336 _handleShareTargetText() {
337 if (!window.shareTargetText) return;
338 this.$text.textContent = window.shareTargetText;
339 window.shareTargetText = '';
340 }
341
342 _send(e) {
343 e.preventDefault();
344 Events.fire('send-text', {
345 to: this._recipient,
346 text: this.$text.innerText
347 });
348 }
349}
350
351class ReceiveTextDialog extends Dialog {
352 constructor() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected