close action / writeText function refactor
This commit is contained in:
parent
c899e20555
commit
b78e84172a
30
app/ui.js
30
app/ui.js
|
|
@ -16,7 +16,6 @@ import keysyms from "../core/input/keysymdef.js";
|
||||||
import Keyboard from "../core/input/keyboard.js";
|
import Keyboard from "../core/input/keyboard.js";
|
||||||
import RFB from "../core/rfb.js";
|
import RFB from "../core/rfb.js";
|
||||||
import * as WebUtil from "./webutil.js";
|
import * as WebUtil from "./webutil.js";
|
||||||
|
|
||||||
const UI = {
|
const UI = {
|
||||||
|
|
||||||
connected: false,
|
connected: false,
|
||||||
|
|
@ -344,6 +343,8 @@ const UI = {
|
||||||
.addEventListener('click', UI.writeText);
|
.addEventListener('click', UI.writeText);
|
||||||
document.getElementById("noVNC_clipboard_clear_button")
|
document.getElementById("noVNC_clipboard_clear_button")
|
||||||
.addEventListener('click', UI.clipboardClear);
|
.addEventListener('click', UI.clipboardClear);
|
||||||
|
document.getElementById("noVNC_clipboard_close_button")
|
||||||
|
.addEventListener('click', UI.clipboardClose);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add a call to save settings when the element changes,
|
// Add a call to save settings when the element changes,
|
||||||
|
|
@ -965,6 +966,13 @@ const UI = {
|
||||||
document.getElementById('noVNC_clipboard_text').value = "";
|
document.getElementById('noVNC_clipboard_text').value = "";
|
||||||
UI.rfb.clipboardPasteFrom("");
|
UI.rfb.clipboardPasteFrom("");
|
||||||
},
|
},
|
||||||
|
clipboardClose() {
|
||||||
|
if (document.getElementById('noVNC_clipboard_button')
|
||||||
|
.classList.contains("noVNC_selected")) {
|
||||||
|
UI.closeClipboardPanel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
writeText() {
|
writeText() {
|
||||||
const text = document.getElementById('noVNC_clipboard_text').value;
|
const text = document.getElementById('noVNC_clipboard_text').value;
|
||||||
|
|
@ -975,14 +983,20 @@ const UI = {
|
||||||
const character = t.shift();
|
const character = t.shift();
|
||||||
if (character === undefined) return;
|
if (character === undefined) return;
|
||||||
|
|
||||||
const code = character.charCodeAt();
|
let code = character.charCodeAt();
|
||||||
const needs_shift = '[A-Z!@#$%^&*()_+{}:"<>?~|]'.indexOf(character) !== -1;
|
const needs_shift = 'A-Z!@#$%^&*()_+{}:"<>?~|'.indexOf(character) !== -1;
|
||||||
const enter = '[\n]'.indexOf(character) !== -1;
|
const enter = '[\n]'.indexOf(character) !== -1;
|
||||||
if (enter) {
|
if (code === 91) {
|
||||||
UI.rfb.sendKey(KeyTable.XK_Return, 'XK_Return', true);
|
UI.rfb.sendKey(KeyTable.XK_bracketleft, 'XK_bracketleft', true);
|
||||||
}
|
UI.rfb.sendKey(KeyTable.XK_bracketleft, 'XK_bracketleft', false);
|
||||||
|
|
||||||
if (!enter) {
|
} else if (code === 93) {
|
||||||
|
UI.rfb.sendKey(KeyTable.XK_bracketright, 'XK_bracketright', true);
|
||||||
|
UI.rfb.sendKey(KeyTable.XK_bracketright, 'XK_bracketright', false);
|
||||||
|
} else if (enter) {
|
||||||
|
UI.rfb.sendKey(KeyTable.XK_Return, 'XK_Return', true);
|
||||||
|
UI.rfb.sendKey(KeyTable.XK_Return, 'XK_Return', false);
|
||||||
|
} else {
|
||||||
if (needs_shift) {
|
if (needs_shift) {
|
||||||
UI.rfb.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", true);
|
UI.rfb.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", true);
|
||||||
}
|
}
|
||||||
|
|
@ -995,7 +1009,7 @@ const UI = {
|
||||||
if (t.length > 0) {
|
if (t.length > 0) {
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
f(t);
|
f(t);
|
||||||
}, 10);
|
}, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
vnc.html
6
vnc.html
|
|
@ -215,6 +215,8 @@
|
||||||
<div id="noVNC_clipboard" class="noVNC_panel">
|
<div id="noVNC_clipboard" class="noVNC_panel">
|
||||||
<div class="noVNC_heading">
|
<div class="noVNC_heading">
|
||||||
<img alt="" src="app/images/clipboard.svg"> Clipboard
|
<img alt="" src="app/images/clipboard.svg"> Clipboard
|
||||||
|
<input type="button" class="noVNC_close" id="noVNC_clipboard_close_button" value="Close">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<textarea id="noVNC_clipboard_text" rows=5></textarea>
|
<textarea id="noVNC_clipboard_text" rows=5></textarea>
|
||||||
<br>
|
<br>
|
||||||
|
|
@ -226,12 +228,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Toggle fullscreen -->
|
<!-- Toggle fullscreen -->
|
||||||
<input type="image" alt="Fullscreen" src="app/images/fullscreen.svg"
|
<input style="display: none" type="image" alt="Fullscreen" src="app/images/fullscreen.svg"
|
||||||
id="noVNC_fullscreen_button" class="noVNC_button noVNC_hidden"
|
id="noVNC_fullscreen_button" class="noVNC_button noVNC_hidden"
|
||||||
title="Fullscreen">
|
title="Fullscreen">
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<input type="image" alt="Settings" src="app/images/settings.svg"
|
<input style="display: none" type="image" alt="Settings" src="app/images/settings.svg"
|
||||||
id="noVNC_settings_button" class="noVNC_button"
|
id="noVNC_settings_button" class="noVNC_button"
|
||||||
title="Settings">
|
title="Settings">
|
||||||
<div class="noVNC_vcenter">
|
<div class="noVNC_vcenter">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue