技术解析

为solusvm的noVNC增加粘贴功能
0
2021-04-30 16:32:41
idczone

在solusvm的主控目录的:/usr/local/solusvm/www/admincp/include 与 /usr/local/solusvm/www/include 的util.js最后增加以下内容即可

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 = "!@#$%^&*()_+{}:\"<>?~|".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+=('<input type="button" value="粘贴" id="sendpasteButton" onclick="paste()" style="display: inline;">');
};

参考至:
https://gist.github.com/croepha/7b53f211ae4be3c526c3
https://gist.github.com/byjg/a6378edb420a1c654c5f27bb494ca1c8


数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服