LH_Jzs
2021-04-26 dcf5a87de927e683d4bbfad3978c3d608c06e48c
init
4个文件已添加
328 ■■■■■ 已修改文件
fileupload.htm 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.htm 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
websocket.htm 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
在线文档index.htm 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fileupload.htm
New file
@@ -0,0 +1,58 @@
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="file" id="files" style="display: none" onchange="fileImport();">
        <input type="button" id="fileImport" value="导入">
    </div>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <!-- <script src="../js/jQuery/jquery-1.11.1.js"></script> -->
    <script>
        //点击导入按钮,使files触发点击事件,然后完成读取文件的操作
        $("#fileImport").click(function () {
            $("#files").click();
        })
        function fileImport() {
            //获取读取我文件的File对象
            var selectedFile = document.getElementById('files').files[0];
            var name = selectedFile.name; //读取选中文件的文件名
            var size = selectedFile.size; //读取选中文件的大小
            console.log("文件名:" + name + "大小:" + size);
            var reader = new FileReader(); //这是核心,读取操作就是由它完成.
            reader.readAsText(selectedFile, "utf-8"); //读取文件的内容,也可以读取文件的URL
            reader.onload = function () {
                //当读取完成后回调这个函数,然后此时文件的内容存储到了result中,直接操作即可
                console.log(this.result);
                var data = {
                    name: name,
                    da: this.result
                }
                console.log(data);
                // data.da
                const base64String = window.btoa('asdasd');
                console.log(base64String);
            }
        }
        function arrayBufferToBase64(buffer) {
            var binary = '';
            var bytes = new Uint8Array(buffer);
            var len = bytes.byteLength;
            console.log(len);
            for (var i = 0; i < len; i++) {
                binary += String.fromCharCode(bytes[i]);
            }
            return window.btoa(binary);
        }
    </script>
</body>
</html>
index.htm
New file
@@ -0,0 +1,104 @@
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="file" id="files" style="display: none" onchange="fileImport();">
        <input type="button" id="fileImport" value="导入">
        <input type="button" id="c" value="测试" onclick="ccccc()">
    </div>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <!-- <script src="../js/jQuery/jquery-1.11.1.js"></script> -->
    <script>
        //点击导入按钮,使files触发点击事件,然后完成读取文件的操作
        $("#fileImport").click(function () {
            $("#files").click();
        })
        function fileImport() {
            //获取读取我文件的File对象
            var selectedFile = document.getElementById('files').files[0];
            console.log(selectedFile);
            var reqData = {
                name: selectedFile.name,
                size: selectedFile.size,
                lastModified: selectedFile.lastModified,
                type: selectedFile.type,
                data: null
            }
            var name = selectedFile.name; //读取选中文件的文件名
            var size = selectedFile.size; //读取选中文件的大小
            var lastModified = selectedFile.lastModified; //文件时间戳
            var type = selectedFile.type;   //文件类型
            console.log("文件名:" + name + "大小:" + size);
            var reader = new FileReader(); //这是核心,读取操作就是由它完成.
            reader.readAsDataURL(selectedFile);
            // reader.readAsText(selectedFile, "utf-8"); //读取文件的内容,也可以读取文件的URL
            reader.onload = function () {
                //当读取完成后回调这个函数,然后此时文件的内容存储到了result中,直接操作即可
                console.log(this.result);
                // console.log(typeof (this.result));
                // console.log(JSON.stringify(this.result));
                reqData.data = this.result;
                $.ajax({
                    type: "POST",
                    url: "http://localhost:10000/SerialPortService/Test",
                    data: JSON.stringify(reqData),
                    success: function (d) {
                        console.log(d);
                    },
                    error: function (jqXHR) {
                        console.error(jqXHR);
                    }
                });
                //var base64String = window.btoa(this.result);
                //console.log(base64String);
                // var temp = window.atob(reqData);
                // console.log(temp);
            }
        }
        function ccccc() {
            $.ajax({
                type: "POST",
                url: "http://139.129.89.252:8080/StatisticsService.asmx/ToDaySales",
                dataType: "json",
                success: function (d) {
                    console.log(d);
                },
                error: function (jqXHR) {
                    console.log(jqXHR);
                }
            });
        }
        function arrayBufferToBase64(buffer) {
            var binary = '';
            var bytes = new Uint8Array(buffer);
            var len = bytes.byteLength;
            console.log(len);
            for (var i = 0; i < len; i++) {
                binary += String.fromCharCode(bytes[i]);
            }
            return window.btoa(binary);
        }
        let str = "测试", escapeStr = "";
        escapeStr = escape(str)
        console.log(escapeStr);
        console.log(unescape(escapeStr));
        str = "ceshi";
        escapeStr = escape(str)
        console.log(escapeStr);
        console.log(unescape(escapeStr));
    </script>
</body>
</html>
websocket.htm
New file
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
</head>
<body>
    <div>
        <input style="width: max-content;" id="input_init" type="text">
        <input type="button" value="初始化" onclick="Init()">
    </div>
    <div>
        <input id="input_text" type="text">
        <input type="button" value="发送" onclick="Send()">
    </div>
    <script type="text/javascript">
        //高拍仪主服务指令控制地址
        var url = "ws://192.168.1.2:25014/";
        var ws_test;
        if ('WebSocket' in window) {
            ws_test = new WebSocket(url);
        }
        else if ('MozWebSocket' in window) {
            ws_test = new MozWebSocket(url);
        }
        else {
            alert("浏览器不支持WebSocket");
        }
        ws_test.onopen = function (evt) {
            console.log("Connection open ...");
            //ws.send("Hello WebSockets!");
        };
        ws_test.onmessage = function (evt) {
            console.log(evt.data);
            //ws.close();
        };
        ws_test.onclose = function (evt) {
            console.log("Connection closed.");
        };
        function Init() {
            var str = document.getElementById('input_init');
            console.log(str.value);
            ws_test.send(str.value);
        }
        function Send() {
            var str = document.getElementById('input_text');
            console.log(str.value);
            ws_test.send(str.value);
        }
    </script>
</body>
</html>
ÔÚÏßÎĵµindex.htm
New file
@@ -0,0 +1,109 @@
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>demo</title>
    <script id="scriptApi" type="text/javascript" src="https://www.51jianxie.com/ds-vpath/web-apps/apps/api/documents/api.js"></script>
</head>
<body>
    <div  id="placeholder"></div>
    <script type="text/javascript">
        window.onload=function(){
            initEditor("","http://sdk.51changxie.com/demo/TravelList.xlsx",true,true,true,true,"a8a62dd9-dbef-4840-b610-791d666bb92f","edit","",{"comment":false,"download":true,"edit":true,"print":true,"review":false})
        }
        function initEditor(username,docUrl, titlebarFlag, rightPanelFlag, leftPanelFlag, toobarFlag, docKey, mode, type, permission) {
            //mode for editor
            window.mode = window.mode || mode || "view";
            mode = window.mode;
            //mode for editor
            window.type = window.type || type || "desktop";
            type = window.type;
            //url for document
            // window.docUrl = document.getElementById("documentUrl").value;
            window.docUrl = docUrl;
            //key for chaching and collaborate editing
            window.docKey = docKey;
            //type for document
            var docType = docUrl.substring(docUrl.lastIndexOf(".") + 1).trim().toLowerCase();
            //type for editor
            var documentType = getDocumentType(docType);
            window.permission = permission;
            window.user = username;
            window.user = window.user || "测试"
            var id = window.user + "-4"
            //CXO_API.CXEditor
            //creating object editing
            var onDocumentReady = function() {
                //editor.destroyEditor();
            }
            var onAppReady = function() {
            }
            var editor = new CXO_API.CXEditor("placeholder", {
                type: type,
                width: (type == "desktop" ? "100%" : undefined),
                height: (type == "desktop" ? "900px" : undefined),
                documentType: documentType,
                token: "eyJ0eXBlIjoiMSIsImFsZyI6IkhTNTEyIn0.e30.RgxbmTaMyvL4cYnOg2DH03JghyUeIlLTiFDZrxqM4Ai_8XGv0K1qw0DB2r9EDRmiLb9ROxzzg36J62V-2IvaXA",
                document: {
                    title: docUrl,
                    url: docUrl,
                    fileType: docType,
                    key: docKey + 2,
                    permissions: window.permission
                },
                editorConfig: {
                    mode: mode,
                    user: {
                        "id": id,
                        "name": window.user
                    },
                    customization: {
                        about: true,
                        chat: false,
                        comments: true,
                        zoom: 50,
                        leftMenu: leftPanelFlag,
                        rightMenu: rightPanelFlag,
                toolbar: toobarFlag,
                displayTitle:titlebarFlag,
                        header: true,
                        statusBar: true,
                autosave: false,
                    forcesave: false
                    },
                },
                events: {
                    'onDocumentReady': onDocumentReady,
                    'onAppReady': onAppReady
                }
            });
        }
        function key(k) {
            // var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_") + (new Date()).getTime();
            var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_");
            return result.substring(result.length - Math.min(result.length, 20));
        };
        var getDocumentType = function(ext) {
            if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
            if (".xls.xlsx.xlsm.xlt.xltx.xltm.ods.fods.ots.csv".indexOf(ext) != -1) return "spreadsheet";
            if (".pps.ppsx.ppsm.ppt.pptx.pptm.pot.potx.potm.odp.fodp.otp".indexOf(ext) != -1) return "presentation";
            return null;
        };
    </script>
</body>
</html>