Adding paste functionality to SolusVM's noVNC. - Tech

  1. Portal Home
  2. Tech

Adding paste functionality to SolusVM's noVNC.

In SolusVM's master directory of.

/usr/local/solusvm/www/admincp/include/util.js
/usr/local/solusvm/www/include/util.js

Add the following.

function paste() {
    return !(function() {
        var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
        var o = [];
        for (let letter of t) {
            o.push(letter);
            console.log(letter);
        }

        function f() {
            var character = o.shift();
            var i = [];
            var code = character.charCodeAt();
            var needs_shift = "[email protected]#$%^&*()_+{}:"<>?~|".indexOf(character) !== -1
            var shift = XK_Shift_L; // To help with minification             
            if (needs_shift) {
                rfb.sendKey(shift, 1);
            }
            rfb.sendKey(code, 1);
            rfb.sendKey(code, 0);
            if (needs_shift) {
                rfb.sendKey(shift, 0);
            }
            if (o.length > 0) {
                setTimeout(f, 10);
            }
        }
        f();
    })();
}
window.onload = function() {
    addbutton = document.getElementById('noVNC_buttons');
    addbutton.innerHTML += ('');
};