Hi guys!
Here I bring you a very useful mod that adds a button to noVNC that sends the text entered in an input (clipboard or anything).
In file /usr/share/novnc-pve/index.html.tpl
Add:
on line 118 after:
In file /usr/share/novnc-pve/app.js
Add:
on line 7751 after:
Add:
on line 10829 after:
and finally, add:
on line 12131 after:
It's working well with my spanish keyboard, if you use US keyboard try to change the line:
with:
or adapt to your keyboard.
Do not forget to clean the browser cache. I hope you find it useful.
Regards.
Here I bring you a very useful mod that adds a button to noVNC that sends the text entered in an input (clipboard or anything).
In file /usr/share/novnc-pve/index.html.tpl
Add:
HTML:
<input type="image" alt="Input" src="/novnc/app/images/clipboard.svg"
id="noVNC_send_paste" class="noVNC_button"
title="Send user input" />
on line 118 after:
HTML:
<input type="image" alt="Ctrl+Alt+Del" src="/novnc/app/images/ctrlaltdel.svg"
id="noVNC_send_ctrl_alt_del_button" class="noVNC_button"
title="Send Ctrl-Alt-Del" />
In file /usr/share/novnc-pve/app.js
Add:
HTML:
sendPaste: function () {
if (this._rfb_connection_state !== 'connected' || this._view_only) { return false; }
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)");
if (t){
t = t.split("");
while(t.length){
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = character.match(/[A-Zª!\"·$%&/()=?¿*Ç_:;>]/);
if (needs_shift) {
this.sendKey($$$core$input$keysym$$default.XK_Shift_L, character,1);
}
this.sendKey(code, character, 1);
this.sendKey(code, character,0);
if (needs_shift) {
this.sendKey($$$core$input$keysym$$default.XK_Shift_L, character,0);
}
}
$$$core$util$logging$$.Info("Sending user input");
return true;
} else {
return false;
}
},
on line 7751 after:
HTML:
sendCtrlAltDel: function () {
if (this._rfb_connection_state !== 'connected' || this._view_only) { return false; }
$$$core$util$logging$$.Info("Sending Ctrl-Alt-Del");
this.sendKey($$$core$input$keysym$$default.XK_Control_L, "ControlLeft", true);
this.sendKey($$$core$input$keysym$$default.XK_Alt_L, "AltLeft", true);
this.sendKey($$$core$input$keysym$$default.XK_Delete, "Delete", true);
this.sendKey($$$core$input$keysym$$default.XK_Delete, "Delete", false);
this.sendKey($$$core$input$keysym$$default.XK_Alt_L, "AltLeft", false);
this.sendKey($$$core$input$keysym$$default.XK_Control_L, "ControlLeft", false);
return true;
},
Add:
HTML:
document.getElementById("noVNC_send_paste")
.addEventListener('click', app$ui$$UI.sendPaste);
on line 10829 after:
HTML:
document.getElementById("noVNC_send_ctrl_alt_del_button")
.addEventListener('click', app$ui$$UI.sendCtrlAltDel);
and finally, add:
HTML:
sendPaste: function() {
app$ui$$UI.rfb.sendPaste();
},
on line 12131 after:
HTML:
sendCtrlAltDel: function() {
app$ui$$UI.rfb.sendCtrlAltDel();
},
It's working well with my spanish keyboard, if you use US keyboard try to change the line:
HTML:
var needs_shift = character.match(/[A-Zª!\"·$%&/()=?¿*Ç_:;>]/);
with:
HTML:
var needs_shift = character.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/);
or adapt to your keyboard.
Do not forget to clean the browser cache. I hope you find it useful.
Regards.