Skip to content

Commit

Permalink
Replace clipboard text input with button.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 20, 2020
1 parent a8df693 commit e3bb8fb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 31 deletions.
6 changes: 2 additions & 4 deletions Server/Pages/RemoteControl.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@
<div style="color:white; font-size:12px">
Shared Clipboard
</div>
<textarea id="clipboardTransferTextArea"></textarea>
<div style="color:white; font-size:12px; text-align: left">
<input id="clipboardTransferTypeCheckbox" type="checkbox" />
<label for="clipboardTransferTypeCheckbox">Type Input</label>
<div style="color:white; font-size:12px;">
<button id="typeClipboardButton" class="horizontal-bar-button">Type Clipboard</button>
</div>
</div>

Expand Down
3 changes: 0 additions & 3 deletions Server/wwwroot/scripts/RemoteControl/ClipboardWatcher.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Server/wwwroot/scripts/RemoteControl/ClipboardWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ClipboardTransferTextArea } from "./UI.js";
import { MainRc } from "./Main.js";
import { MainRc } from "./Main.js";

export class ClipboardWatcher {
ClipboardTimer: number;
Expand All @@ -21,7 +20,6 @@ export class ClipboardWatcher {
navigator.clipboard.readText().then(newText => {
if (this.LastClipboardText != newText) {
this.LastClipboardText = newText;
ClipboardTransferTextArea.value = newText;
MainRc.MessageSender.SendClipboardTransfer(newText, false);
}
})
Expand All @@ -33,7 +31,6 @@ export class ClipboardWatcher {
this.PauseMonitoring = true;
this.LastClipboardText = text;
navigator.clipboard.writeText(text);
ClipboardTransferTextArea.value = text;
this.PauseMonitoring = false;
}
}
18 changes: 9 additions & 9 deletions Server/wwwroot/scripts/RemoteControl/UI.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/wwwroot/scripts/RemoteControl/UI.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Server/wwwroot/scripts/RemoteControl/UI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export var FileTransferButton = document.getElementById("fileTransferButton") as
export var CtrlAltDelButton = document.getElementById("ctrlAltDelButton") as HTMLButtonElement;
export var TouchKeyboardTextArea = document.getElementById("touchKeyboardTextArea") as HTMLTextAreaElement;
export var ClipboardTransferBar = document.getElementById("clipboardTransferBar") as HTMLDivElement;
export var ClipboardTransferTextArea = document.getElementById("clipboardTransferTextArea") as HTMLTextAreaElement;
export var ClipboardTransferButton = document.getElementById("clipboardTransferButton") as HTMLButtonElement;
export var ClipboardTransferTypeCheckbox = document.getElementById("clipboardTransferTypeCheckbox") as HTMLInputElement;
export var TypeClipboardButton = document.getElementById("typeClipboardButton") as HTMLButtonElement;
export var ConnectionP2PIcon = document.getElementById("connectionP2PIcon") as HTMLElement;
export var ConnectionRelayedIcon = document.getElementById("connectionRelayedIcon") as HTMLElement;
export var ToastsWrapper = document.getElementById("toastsWrapper") as HTMLDivElement;
Expand Down Expand Up @@ -72,13 +71,14 @@ export function ApplyInputHandlers() {
closeAllHorizontalBars("clipboardTransferBar");
ClipboardTransferBar.classList.toggle("open");
});
ClipboardTransferTextArea.addEventListener("input", (ev) => {
if (ClipboardTransferTextArea.value.length == 0) {
return;
}
MainRc.MessageSender.SendClipboardTransfer(ClipboardTransferTextArea.value, ClipboardTransferTypeCheckbox.checked);
ClipboardTransferTextArea.blur();
ShowMessage("Clipboard sent!");
TypeClipboardButton.addEventListener("click", (ev) => {
navigator.clipboard.readText().then(text => {
MainRc.MessageSender.SendClipboardTransfer(text, true);
ShowMessage("Clipboard sent!");
}, reason => {
alert("Unable to read clipboard. Please check your permissions.");
console.log("Unable to read clipboard. Reason: " + reason);
});
});
ConnectButton.addEventListener("click", (ev) => {
MainRc.ConnectToClient();
Expand Down

0 comments on commit e3bb8fb

Please sign in to comment.