better copy paste

This commit is contained in:
Richard Klafter 2017-05-22 15:45:11 -07:00
parent 42a33ba0c4
commit 797136d033
1 changed files with 18 additions and 4 deletions

View File

@ -80,7 +80,7 @@
<textarea id="copyBox" style="height:752px;width:98%;overflow:scroll;"></textarea> <textarea id="copyBox" style="height:752px;width:98%;overflow:scroll;"></textarea>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
@ -182,18 +182,21 @@
var xvpbuttons; var xvpbuttons;
xvpbuttons = $D('noVNC_xvp_buttons'); xvpbuttons = $D('noVNC_xvp_buttons');
if (ver >= 1) { if (ver >= 1) {
xvpbuttons.style.display = 'inline'; xvpbuttons.style.display = 'inline';yakpal.setClipboard
} else { } else {
xvpbuttons.style.display = 'none'; xvpbuttons.style.display = 'none';
} }
} }
function onClipboard(rfb, text){ function onClipboard(rfb, text){
$D('copyBox').value = text $D('copyBox').value = text
if(window.yakpal && window.yakpal.setClipboard){
yakpal.setClipboard(text);
}
} }
window.onscriptsload = function () { window.onscriptsload = function () {
var host, port, password, path, token; var host, port, password, path, token, lastClipboard;
//$D('sendCtrlAltDelButton').style.display = "inline"; //$D('sendCtrlAltDelButton').style.display = "inline";
//$D('sendCtrlAltDelButton').onclick = sendCtrlAltDel; //$D('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
@ -204,11 +207,22 @@
$D('vnc-input').focus(); $D('vnc-input').focus();
}); });
function updateClipboard(){ function updateClipboard(){
lastClipboard = $D('copyBox').value;
rfb.clipboardPasteFrom($D('copyBox').value); rfb.clipboardPasteFrom($D('copyBox').value);
} }
$D('copyBox').addEventListener('change', updateClipboard); $D('copyBox').addEventListener('change', updateClipboard);
$D('copyBox').addEventListener('paste', updateClipboard); $D('copyBox').addEventListener('paste', updateClipboard);
setInterval(function(){
if(!window.yakpal || !window.yakpal.getClipboard) return;
window.yakpal.getClipboard().then((result)=>{
if(result !== lastClipboard){
$D('copyBox').value = result;
updateClipboard();
}
})
}, 100)
WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn')); WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
document.title = unescape(WebUtil.getConfigVar('title', 'noVNC')); document.title = unescape(WebUtil.getConfigVar('title', 'noVNC'));
// By default, use the host and port of server that served this file // By default, use the host and port of server that served this file