zoukankan      html  css  js  c++  java
  • guacamole实现剪切复制

    主要功能是实现把堡垒机的内容复制到浏览器端,把浏览器端的文本复制到堡垒机上。

    借助一个中间的文本框,现将堡垒机内容复制到一个文本框,然后把文本框内容复制出来。或者将需要传递到堡垒机的内容先复制到文本框,然后在传递到堡垒机上。

        //监听堡垒机端往剪切板复制事件,然后写入文本框中
        client.onclipboard = function(stream, mimetype){
            if (/^text//.exec(mimetype)) {
                var stringReader = new Guacamole.StringReader(stream);
                var json = "";
                stringReader.ontext = function ontext(text) {
                    json += text
                }
    
                stringReader.onend = function() {
                    var clipboardElement = document.getElementById("clipboard");
                    clipboardElement.value = '';
                    clipboardElement.value = json;
                }
            } 
        }
        
        //将内容传送到往堡垒机,data是获取到的文本框中的内容
        function setClipboard(data) {
            var stream = client.createClipboardStream("text/plain");
    
            var writer = new Guacamole.StringWriter(stream);
            for (var i=0; i<data.length; i += 4096){
                writer.sendText(data.substring(i, i+4096));
            }
    
            writer.sendEnd();
        }
    
  • 相关阅读:
    linux 文件系统基本结构
    linux bash命令行基本操作
    U盘安装Centos6.2
    linux安装JDK
    linux重启和关闭系统命令
    eclipse安装反编译工具JadClipse
    Linux系统 Centos6 安装
    Linux 发展史
    计算机硬件
    网络 、osi 七层模型、tcp/ip 五层参考
  • 原文地址:https://www.cnblogs.com/redirect/p/10066730.html
Copyright © 2011-2022 走看看